diff options
author | Tiago Natel de Moura <t.nateldemoura@f5.com> | 2020-02-05 13:29:41 +0000 |
---|---|---|
committer | Tiago Natel de Moura <t.nateldemoura@f5.com> | 2020-02-05 13:29:41 +0000 |
commit | 12e15ba43b97fe54485c6251e7d17bcb563cf0fd (patch) | |
tree | 1f967d10023a29731861d4362f08aaaca8cd6ff9 /test/python | |
parent | d3e218a8c379baf1af4759097d3c9c2fedb01432 (diff) | |
download | unit-12e15ba43b97fe54485c6251e7d17bcb563cf0fd.tar.gz unit-12e15ba43b97fe54485c6251e7d17bcb563cf0fd.tar.bz2 |
Tests: added test for uploading files with SSL.
* * *
[mq]: multipart
Diffstat (limited to '')
-rw-r--r-- | test/python/upload/wsgi.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/python/upload/wsgi.py b/test/python/upload/wsgi.py new file mode 100644 index 00000000..37ee89eb --- /dev/null +++ b/test/python/upload/wsgi.py @@ -0,0 +1,27 @@ +from tempfile import TemporaryFile +import os, cgi + +def read(environ): + length = int(environ.get('CONTENT_LENGTH', 0)) + + body = TemporaryFile(mode='w+b') + body.write(bytes(environ['wsgi.input'].read(length))) + body.seek(0) + + environ['wsgi.input'] = body + return body + +def application(environ, start_response): + file = read(environ) + + form = cgi.FieldStorage(fp=file, environ=environ, keep_blank_values=True) + + filename = form['file'].filename + data = filename.encode() + form['file'].file.read() + + start_response('200 OK', [ + ('Content-Type', 'text/plain'), + ('Content-Length', str(len(data))), + ]) + + return data |