From 3da8532bed3305b01e3f3ab556f9dbc652177c6b Mon Sep 17 00:00:00 2001 From: Nikhil Soni Date: Thu, 2 Mar 2017 15:59:44 +0530 Subject: [PATCH] Adds test for --keep-host-header --- test/mitmproxy/proxy/test_server.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/mitmproxy/proxy/test_server.py b/test/mitmproxy/proxy/test_server.py index 0be772a41..46beea41d 100644 --- a/test/mitmproxy/proxy/test_server.py +++ b/test/mitmproxy/proxy/test_server.py @@ -482,6 +482,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