aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_http.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-07-24 11:39:49 +1200
committerAldo Cortesi <aldo@nullcube.com>2012-07-24 11:41:18 +1200
commit91752990d5863526745e5c31cfb4b7459d11047e (patch)
tree5309c036f76f78aac3056ed98935f0f766379994 /test/test_http.py
parenteb88cea3c74a253d3a08d010bfd328aa845c6d5b (diff)
downloadmitmproxy-91752990d5863526745e5c31cfb4b7459d11047e.tar.gz
mitmproxy-91752990d5863526745e5c31cfb4b7459d11047e.tar.bz2
mitmproxy-91752990d5863526745e5c31cfb4b7459d11047e.zip
Handle HTTP responses that have a body but no content-length or transfer encoding
We check if the server sent a connection:close header, and read till the socket closes. Closes #2
Diffstat (limited to 'test/test_http.py')
-rw-r--r--test/test_http.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/test/test_http.py b/test/test_http.py
index 0174a4aa..0b83e65a 100644
--- a/test/test_http.py
+++ b/test/test_http.py
@@ -64,7 +64,28 @@ def test_read_http_body_response():
h = odict.ODictCaseless()
h["content-length"] = [7]
s = cStringIO.StringIO("testing")
- assert http.read_http_body_response(s, h, False, None) == "testing"
+ assert http.read_http_body_response(s, h, None) == "testing"
+
+
+ h = odict.ODictCaseless()
+ s = cStringIO.StringIO("testing")
+ assert not http.read_http_body_response(s, h, None)
+
+ h = odict.ODictCaseless()
+ h["connection"] = ["close"]
+ s = cStringIO.StringIO("testing")
+ assert http.read_http_body_response(s, h, None) == "testing"
+
+
+def test_get_header_tokens():
+ h = odict.ODictCaseless()
+ assert http.get_header_tokens(h, "foo") == []
+ h["foo"] = ["bar"]
+ assert http.get_header_tokens(h, "foo") == ["bar"]
+ h["foo"] = ["bar, voing"]
+ assert http.get_header_tokens(h, "foo") == ["bar", "voing"]
+ h["foo"] = ["bar, voing", "oink"]
+ assert http.get_header_tokens(h, "foo") == ["bar", "voing", "oink"]
def test_read_http_body_request():