aboutsummaryrefslogtreecommitdiffstats
path: root/test/netlib/http
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2016-04-03 08:17:30 -0700
committerMaximilian Hils <git@maximilianhils.com>2016-04-03 08:17:30 -0700
commit0259f479974f4f61e28bf1dac0d0f5229e468c36 (patch)
tree7bf64d328bf6dcbe12d4e8f4b6cba20125b3bf34 /test/netlib/http
parent84f650aabf739f40b3ff414c646257141babd6e1 (diff)
parent806aa0f41c7816b2859a6961939ed19499b73fe7 (diff)
downloadmitmproxy-0259f479974f4f61e28bf1dac0d0f5229e468c36.tar.gz
mitmproxy-0259f479974f4f61e28bf1dac0d0f5229e468c36.tar.bz2
mitmproxy-0259f479974f4f61e28bf1dac0d0f5229e468c36.zip
Merge branch 'better-replace'
Diffstat (limited to 'test/netlib/http')
-rw-r--r--test/netlib/http/test_headers.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/netlib/http/test_headers.py b/test/netlib/http/test_headers.py
index d50fee3e..8c1db9dc 100644
--- a/test/netlib/http/test_headers.py
+++ b/test/netlib/http/test_headers.py
@@ -150,3 +150,22 @@ class TestHeaders(object):
assert headers != headers2
headers2.set_state(headers.get_state())
assert headers == headers2
+
+ def test_replace_simple(self):
+ headers = Headers(Host="example.com", Accept="text/plain")
+ replacements = headers.replace("Host: ", "X-Host: ")
+ assert replacements == 1
+ assert headers["X-Host"] == "example.com"
+ assert "Host" not in headers
+ assert headers["Accept"] == "text/plain"
+
+ def test_replace_multi(self):
+ headers = self._2host()
+ headers.replace(r"Host: example\.com", r"Host: example.de")
+ assert headers.get_all("Host") == ["example.de", "example.org"]
+
+ def test_replace_remove_spacer(self):
+ headers = Headers(Host="example.com")
+ replacements = headers.replace(r"Host: ", "X-Host ")
+ assert replacements == 0
+ assert headers["Host"] == "example.com"