From 6852eb9d0af5cf7196da5cad2ccf3b036e348226 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Fri, 10 Apr 2015 14:59:38 +0200 Subject: fix #553 --- test/test_protocol_http.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test') diff --git a/test/test_protocol_http.py b/test/test_protocol_http.py index 23c3f469..c6fad508 100644 --- a/test/test_protocol_http.py +++ b/test/test_protocol_http.py @@ -55,6 +55,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) -- cgit v1.2.3 From 923503260ed48510da63e4dd1d6b36b4b859b110 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Fri, 10 Apr 2015 19:42:32 +0200 Subject: add tests --- test/test_protocol_http.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test') diff --git a/test/test_protocol_http.py b/test/test_protocol_http.py index c6fad508..e3593ae3 100644 --- a/test/test_protocol_http.py +++ b/test/test_protocol_http.py @@ -121,6 +121,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") -- cgit v1.2.3 From c0a318566ae0fb5a264bfaa130f3ff3a09ea5bf5 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Sun, 12 Apr 2015 03:47:58 +0200 Subject: add flowwriter example --- test/test_examples.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') 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 -- cgit v1.2.3