aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2015-02-27 15:24:27 +0100
committerMaximilian Hils <git@maximilianhils.com>2015-02-27 15:24:27 +0100
commite1b6cf940146ca91c6f583a3333b4b50b72875bb (patch)
tree80cedc8e9e15881bc1662ae04e9bb3a488a1646e /test
parent8d975e80ffbbf2af5f1d097a21dbb33e17acc6a1 (diff)
downloadmitmproxy-e1b6cf940146ca91c6f583a3333b4b50b72875bb.tar.gz
mitmproxy-e1b6cf940146ca91c6f583a3333b4b50b72875bb.tar.bz2
mitmproxy-e1b6cf940146ca91c6f583a3333b4b50b72875bb.zip
fix #319
Diffstat (limited to 'test')
-rw-r--r--test/scripts/stream_modify.py7
-rw-r--r--test/test_server.py6
2 files changed, 13 insertions, 0 deletions
diff --git a/test/scripts/stream_modify.py b/test/scripts/stream_modify.py
new file mode 100644
index 00000000..9a98a7ee
--- /dev/null
+++ b/test/scripts/stream_modify.py
@@ -0,0 +1,7 @@
+def modify(chunks):
+ for prefix, content, suffix in chunks:
+ yield prefix, content.replace("foo", "bar"), suffix
+
+
+def responseheaders(context, flow):
+ flow.response.stream = modify \ No newline at end of file
diff --git a/test/test_server.py b/test/test_server.py
index e387293f..26770f29 100644
--- a/test/test_server.py
+++ b/test/test_server.py
@@ -266,6 +266,12 @@ class TestHTTP(tservers.HTTPProxTest, CommonMixin, AppMixin):
assert self.master.state.view[-1].response.content == CONTENT_MISSING
self.master.set_stream_large_bodies(None)
+ def test_stream_modify(self):
+ self.master.load_script(tutils.test_data.path("scripts/stream_modify.py"))
+ d = self.pathod('200:b"foo"')
+ assert d.content == "bar"
+ self.master.unload_scripts()
+
class TestHTTPAuth(tservers.HTTPProxTest):
authenticator = http_auth.BasicProxyAuth(http_auth.PassManSingleUser("test", "test"), "realm")
def test_auth(self):