diff options
author | Maximilian Hils <git@maximilianhils.com> | 2017-03-04 11:42:44 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-04 11:42:44 +0100 |
commit | 78fd5a9dadbf16cebe46243ef706069b857ff3d9 (patch) | |
tree | 56f57e0cf785cebddf0fde1683ca19f7cdcc741b /test | |
parent | bae4cdf8d5cc434938c74a041f762075513dd8e4 (diff) | |
parent | 50ebdf3081d4cf3b16532c4a8bdea6bfa94cbbba (diff) | |
download | mitmproxy-78fd5a9dadbf16cebe46243ef706069b857ff3d9.tar.gz mitmproxy-78fd5a9dadbf16cebe46243ef706069b857ff3d9.tar.bz2 mitmproxy-78fd5a9dadbf16cebe46243ef706069b857ff3d9.zip |
Merge pull request #2053 from krsoninikhil/on-issues
Adds --keep-host-header option (#2039)
Diffstat (limited to 'test')
-rw-r--r-- | test/mitmproxy/proxy/test_server.py | 20 | ||||
-rw-r--r-- | test/mitmproxy/test_examples.py | 2 |
2 files changed, 20 insertions, 2 deletions
diff --git a/test/mitmproxy/proxy/test_server.py b/test/mitmproxy/proxy/test_server.py index 8b133085..56b09b9a 100644 --- a/test/mitmproxy/proxy/test_server.py +++ b/test/mitmproxy/proxy/test_server.py @@ -481,6 +481,26 @@ class TestHTTPSNoCommonName(tservers.HTTPProxyTest): class TestReverse(tservers.ReverseProxyTest, CommonMixin, TcpMixin): reverse = True + def test_host_header(self): + self.config.options.keep_host_header = True + p = self.pathoc() + with p.connect(): + resp = p.request("get:/p/200:h'Host'='example.com'") + assert resp.status_code == 200 + + req = self.master.state.flows[0].request + assert req.host_header == "example.com" + + def test_overridden_host_header(self): + self.config.options.keep_host_header = False # default value + p = self.pathoc() + with p.connect(): + resp = p.request("get:/p/200:h'Host'='example.com'") + assert resp.status_code == 200 + + req = self.master.state.flows[0].request + assert req.host_header == "127.0.0.1" + class TestReverseSSL(tservers.ReverseProxyTest, CommonMixin, TcpMixin): reverse = True diff --git a/test/mitmproxy/test_examples.py b/test/mitmproxy/test_examples.py index f3603fca..668d0d4a 100644 --- a/test/mitmproxy/test_examples.py +++ b/test/mitmproxy/test_examples.py @@ -114,13 +114,11 @@ class TestScripts(tservers.MasterTest): # Rewrite by reverse proxy mode f.request.scheme = "https" - f.request.host = "mitmproxy.org" f.request.port = 443 m.request(f) assert f.request.scheme == "http" - assert f.request.host == original_host assert f.request.port == 80 assert f.request.headers["Host"] == original_host |