aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2016-01-17 19:54:59 +0100
committerMaximilian Hils <git@maximilianhils.com>2016-01-17 19:54:59 +0100
commit0f54f2990c0a32960ec5c82c620f79c68ad5f4b6 (patch)
treedfe43a773f4ef600dc35af06d936804bbcf893e9 /test
parentadd33f873336c510dd171fe3665f686216b18488 (diff)
parente766838a1a6bbb0b2290a3986ba8ae71c736f6f6 (diff)
downloadmitmproxy-0f54f2990c0a32960ec5c82c620f79c68ad5f4b6.tar.gz
mitmproxy-0f54f2990c0a32960ec5c82c620f79c68ad5f4b6.tar.bz2
mitmproxy-0f54f2990c0a32960ec5c82c620f79c68ad5f4b6.zip
Merge pull request #872 from bazzinotti/inline-tcp
Add "tcp_message" Inline Script Hook
Diffstat (limited to 'test')
-rw-r--r--test/scripts/tcp_stream_modify.py3
-rw-r--r--test/test_server.py12
2 files changed, 15 insertions, 0 deletions
diff --git a/test/scripts/tcp_stream_modify.py b/test/scripts/tcp_stream_modify.py
new file mode 100644
index 00000000..9870dddf
--- /dev/null
+++ b/test/scripts/tcp_stream_modify.py
@@ -0,0 +1,3 @@
+def tcp_message(ctx,tm):
+ if tm.sender == tm.server_conn:
+ tm.message = tm.message.replace("foo", "bar")
diff --git a/test/test_server.py b/test/test_server.py
index 5f348121..2e21fce7 100644
--- a/test/test_server.py
+++ b/test/test_server.py
@@ -502,6 +502,18 @@ class TestHttps2Http(tservers.ReverseProxTest):
class TestTransparent(tservers.TransparentProxTest, CommonMixin, TcpMixin):
ssl = False
+ def test_tcp_stream_modify(self):
+ self.master.load_script(
+ tutils.test_data.path("scripts/tcp_stream_modify.py"))
+
+ self._tcpproxy_on()
+ d = self.pathod('200:b"foo"')
+ self._tcpproxy_off()
+
+ assert d.content == "bar"
+
+ self.master.unload_scripts()
+
class TestTransparentSSL(tservers.TransparentProxTest, CommonMixin, TcpMixin):
ssl = True