Commit Graph

21 Commits

Author SHA1 Message Date
Sebastian Lohff f668fc3fe6 Release 0.5.4 2023-01-23 23:40:14 +01:00
MasterofJOKers 0b010d5c10 Upload to uploaddir instead of /tmp
When uploading larger files, cgi.FieldStorage decides to store the files
in an unnamed temporary file in /tmp while parsing the form-data. This
is counter-intuitive and might not work, if the partition hosting /tmp/
is too small. Therefore, we overwrite FieldStorage's make_file() method
to use the targetDir as upload path.

While we're at it, we also use NamedTemporaryFile instead of
TemporaryFile, because that lets us use os.link() to create a "copy" of
the file-data without writing it to disk a second time. This does not
work for small data, because small data is kept in an BytesIO object and
thus never written to file automatically. For this case, we keep the old
code, that's writing down files manually.

We have to inline-define CustomFieldStorage, because FieldStorage will
instantiate a new FieldStorage instance for parsing the parts of a
multipart/form-data body and thus we cannot pass targetDir via
__init__() argument.

Signed-off-by: MasterofJOKers <joker@someserver.de>
2022-01-18 22:52:44 +01:00
Sebastian Lohff c7af20388d Release v0.5.3 2021-11-18 00:32:41 +01:00
Sebastian Pipping 8b16b7626c tests: Drop unused arguments 2021-11-16 21:08:56 +01:00
Sebastian Pipping 8f9ba0e387 tests: Replace hardcoded timeouts by retries
This (1) fixes test timeouts for some machines
and (2) speeds up test execution by 20% on my machine.
2021-11-16 21:05:39 +01:00
Sebastian Lohff cd28811fcf Release v0.5.2 2021-09-08 00:23:11 +02:00
Sebastian Lohff 46d4433a1d Explicitly set encoding for http requests in tests
Due to the upgrade to charset-normalizer 2.0.4 guessing the encoding
inside the tests did not work anymore and caused the umlaut tests to
fail. Explicitly specifying the encoding on the requests' response
object fixes this.
2021-09-07 23:24:57 +02:00
Paweł Chojnacki 6537c054e5 Fix PUT uploads
PUT uploads were broken on python 3.9 and were lacking tests.
2021-07-14 00:11:16 +02:00
Sebastian Lohff 9fa4ed0026 Quote filenames in Location header on redirect
When we redirect the user to the "correct" file name this name should
end up quoted in the header, else we would end up in an infinite
redirect loop.
2021-06-08 23:46:30 +02:00
Sebastian Lohff 1f451e0f29 Allow ports for tests to be specified via env
SERVEFILE_DEFAULT_PORT and SERVEFILE_SECONDARY_PORT can be used to
specify ports used in the servefile tests. This can be useful if the
default port 8080 and the secondary port 8081 (for the -p test) are
already in use. To allow automatic choosing of a free port 0 can be
specified to tell the test code to automatically select a free port.
2021-04-21 01:04:20 +02:00
Sebastian Lohff 058de2f39c Fix exception on transmission abort with python3
With python3 sys.exc_value does no longer exist, but we can replace it
with sys.exc_info().
2021-01-27 01:31:15 +01:00
Sebastian Lohff 11a7d8bd13 Release v0.5.1 2020-09-30 01:44:57 +02:00
Sebastian Lohff f2594c2adf Release v0.5.0 2020-09-30 01:28:48 +02:00
Sebastian Lohff ef41f65996 Workaround for python2 deprecation in tests
When checking the version the test now gets a
CryptographyDeprecationWarning plus an import code line instead of the
version. As a workaround we now ignore the first two lines when checking
for the version string.
2020-09-07 00:31:10 +02:00
Sebastian Lohff 19c1b000a4 Make servefile a python package
servefile is now a valid python package. The single servefile.py can
still be used as a script by just putting it into PATH and making it
executable. Additionally when installed via pip a wrapper script is
created, calling the module's main(). python -m servefile works as well.
2020-09-07 00:26:20 +02:00
Sebastian Pipping 0819d23f47 tests: Use sys.executable during tests 2020-02-08 01:26:47 +01:00
Sebastian Pipping a7d273f13f tests: Prepare version-specific code for extension 2020-02-08 01:15:27 +01:00
Sebastian Lohff ccd01e8b6e Fix -4/-6 crash caused by broken filter statement
In python3 filter returns a generator instead of a list. When -4 or
-6 is used or if the host system has either of those address
families disabled len() gets called onto this filter expression
which results into a crash. This commit makes a filter expression
out of this statement and also adds a test for ipv4-only downloading.
2020-01-15 00:48:06 +01:00
MasterofJOKers 907013522c Make `targetDir` absolute by default
When serving a `../` as directory (with `-l`), servefile creates an
endless 301-redirect loop. Having an absolute path fixes this. Since
this error might come up any time again, we're setting `targetDir` to
its absolute path right from the beginning and never have to worry about
it later on.
2020-01-15 00:07:07 +01:00
Sebastian Lohff 6e27ecfe8c Python3 SSL socket handling 2019-02-24 13:59:12 +01:00
Sebastian Lohff 93e0c3dd7e Initial tests 2019-02-17 21:29:23 +01:00