diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2016-05-31 19:07:55 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2016-05-31 19:07:55 +1200 |
commit | ec34cae6181d6af0150ac730d70b96104a07e9d5 (patch) | |
tree | 875987f36e83f92ce9a38cd6e22326a948f29609 /test/netlib/http/test_multipart.py | |
parent | 15b2374ef9d6a8cbafdff7c79694921387836ff3 (diff) | |
download | mitmproxy-ec34cae6181d6af0150ac730d70b96104a07e9d5.tar.gz mitmproxy-ec34cae6181d6af0150ac730d70b96104a07e9d5.tar.bz2 mitmproxy-ec34cae6181d6af0150ac730d70b96104a07e9d5.zip |
utils.multipartdecode -> http.multipart.decode
also
utils.parse_content_type -> http.headers.parse_content_type
Diffstat (limited to 'test/netlib/http/test_multipart.py')
-rw-r--r-- | test/netlib/http/test_multipart.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/netlib/http/test_multipart.py b/test/netlib/http/test_multipart.py new file mode 100644 index 00000000..45ae996b --- /dev/null +++ b/test/netlib/http/test_multipart.py @@ -0,0 +1,23 @@ +from netlib.http import Headers +from netlib.http import multipart + +def test_decode(): + boundary = 'somefancyboundary' + headers = Headers( + content_type='multipart/form-data; boundary=' + boundary + ) + content = ( + "--{0}\n" + "Content-Disposition: form-data; name=\"field1\"\n\n" + "value1\n" + "--{0}\n" + "Content-Disposition: form-data; name=\"field2\"\n\n" + "value2\n" + "--{0}--".format(boundary).encode() + ) + + form = multipart.decode(headers, content) + + assert len(form) == 2 + assert form[0] == (b"field1", b"value1") + assert form[1] == (b"field2", b"value2") |