aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_utils.py
diff options
context:
space:
mode:
authorThomas Kriechbaumer <thomas@kriechbaumer.name>2015-08-05 21:32:53 +0200
committerThomas Kriechbaumer <thomas@kriechbaumer.name>2015-08-10 20:34:27 +0200
commit690b8b4f4e00d60b373b5a1481930f21bbc5054a (patch)
treedd0091035e4027e792174cb2dcf63eb37afa0a56 /test/test_utils.py
parentc2832ef72bd4eed485a1c8d4bcb732da69896444 (diff)
downloadmitmproxy-690b8b4f4e00d60b373b5a1481930f21bbc5054a.tar.gz
mitmproxy-690b8b4f4e00d60b373b5a1481930f21bbc5054a.tar.bz2
mitmproxy-690b8b4f4e00d60b373b5a1481930f21bbc5054a.zip
add move tests and code from mitmproxy
Diffstat (limited to 'test/test_utils.py')
-rw-r--r--test/test_utils.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/test_utils.py b/test/test_utils.py
index 5e681eb6..aafa1571 100644
--- a/test/test_utils.py
+++ b/test/test_utils.py
@@ -101,3 +101,34 @@ def test_get_header_tokens():
assert utils.get_header_tokens(h, "foo") == ["bar", "voing"]
h["foo"] = ["bar, voing", "oink"]
assert utils.get_header_tokens(h, "foo") == ["bar", "voing", "oink"]
+
+
+
+
+
+def test_multipartdecode():
+ boundary = 'somefancyboundary'
+ headers = odict.ODict(
+ [('content-type', ('multipart/form-data; boundary=%s' % 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)
+
+ form = utils.multipartdecode(headers, content)
+
+ assert len(form) == 2
+ assert form[0] == ('field1', 'value1')
+ assert form[1] == ('field2', 'value2')
+
+
+def test_parse_content_type():
+ p = utils.parse_content_type
+ assert p("text/html") == ("text", "html", {})
+ assert p("text") is None
+
+ v = p("text/html; charset=UTF-8")
+ assert v == ('text', 'html', {'charset': 'UTF-8'})