aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_protocol_http.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2015-04-14 12:01:37 +1200
committerAldo Cortesi <aldo@nullcube.com>2015-04-14 12:01:37 +1200
commit937a358aa9396d5a5c18bc69e89e11af5dad40a5 (patch)
tree1d52a64527f93aeb5299d59e502ab792a052f7a2 /test/test_protocol_http.py
parentbea0bd236a60e3e6c80027448e51b7802394304a (diff)
parentcbf6cad8524b2b46a364898274871eba5dca776f (diff)
downloadmitmproxy-937a358aa9396d5a5c18bc69e89e11af5dad40a5.tar.gz
mitmproxy-937a358aa9396d5a5c18bc69e89e11af5dad40a5.tar.bz2
mitmproxy-937a358aa9396d5a5c18bc69e89e11af5dad40a5.zip
Merge branch 'master' of ssh.github.com:mitmproxy/mitmproxy
Diffstat (limited to 'test/test_protocol_http.py')
-rw-r--r--test/test_protocol_http.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/test_protocol_http.py b/test/test_protocol_http.py
index 08ed114c..6b949ce3 100644
--- a/test/test_protocol_http.py
+++ b/test/test_protocol_http.py
@@ -59,6 +59,14 @@ class TestHTTPRequest:
r.update_host_header()
assert "Host" in r.headers
+ def test_expect_header(self):
+ s = StringIO("GET / HTTP/1.1\r\nContent-Length: 3\r\nExpect: 100-continue\r\n\r\nfoobar")
+ w = StringIO()
+ r = HTTPRequest.from_stream(s, wfile=w)
+ assert w.getvalue() == "HTTP/1.1 100 Continue\r\n\r\n"
+ assert r.content == "foo"
+ assert s.read(3) == "bar"
+
def test_authority_form_in(self):
s = StringIO("CONNECT oops-no-port.com HTTP/1.1")
tutils.raises("Bad HTTP request line", HTTPRequest.from_stream, s)
@@ -117,6 +125,20 @@ class TestHTTPRequest:
r = tutils.treq()
assert repr(r)
+ def test_pretty_host(self):
+ r = tutils.treq()
+ assert r.pretty_host(True) == "address"
+ assert r.pretty_host(False) == "address"
+ r.headers["host"] = ["other"]
+ assert r.pretty_host(True) == "other"
+ assert r.pretty_host(False) == "address"
+ r.host = None
+ assert r.pretty_host(True) == "other"
+ assert r.pretty_host(False) is None
+ del r.headers["host"]
+ assert r.pretty_host(True) is None
+ assert r.pretty_host(False) is None
+
def test_get_form_for_urlencoded(self):
r = tutils.treq()
r.headers.add("content-type", "application/x-www-form-urlencoded")