diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/test_examples.py | 2 | ||||
-rw-r--r-- | test/test_protocol_http.py | 22 |
2 files changed, 23 insertions, 1 deletions
diff --git a/test/test_examples.py b/test/test_examples.py index daf4b902..fd901b5d 100644 --- a/test/test_examples.py +++ b/test/test_examples.py @@ -11,7 +11,7 @@ def test_load_scripts(): tmaster = tservers.TestMaster(config.ProxyConfig()) for f in scripts: - if "har_extractor" in f: + if "har_extractor" in f or "flowwriter" in f: f += " -" if "iframe_injector" in f: f += " foo" # one argument required 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") |