mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 08:11:00 +00:00
Adds test for --keep-host-header
This commit is contained in:
parent
317d183ba4
commit
3da8532bed
@ -482,6 +482,26 @@ class TestHTTPSNoCommonName(tservers.HTTPProxyTest):
|
|||||||
class TestReverse(tservers.ReverseProxyTest, CommonMixin, TcpMixin):
|
class TestReverse(tservers.ReverseProxyTest, CommonMixin, TcpMixin):
|
||||||
reverse = True
|
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):
|
class TestReverseSSL(tservers.ReverseProxyTest, CommonMixin, TcpMixin):
|
||||||
reverse = True
|
reverse = True
|
||||||
|
Loading…
Reference in New Issue
Block a user