aboutsummaryrefslogtreecommitdiffstats
path: root/examples/stream_modify.py
diff options
context:
space:
mode:
authorYouhei Sakurai <sakurai.youhei@gmail.com>2015-02-27 02:44:47 +0900
committerYouhei Sakurai <sakurai.youhei@gmail.com>2015-02-27 02:44:47 +0900
commit77bb0b74ed9cf156490f52a162a4d1856694db4f (patch)
treeebaf0bd2e67052e5c3e1c56783abf0265225f02c /examples/stream_modify.py
parentbd6c3f64c1f3102a4e91d4a964757821773781e0 (diff)
downloadmitmproxy-77bb0b74ed9cf156490f52a162a4d1856694db4f.tar.gz
mitmproxy-77bb0b74ed9cf156490f52a162a4d1856694db4f.tar.bz2
mitmproxy-77bb0b74ed9cf156490f52a162a4d1856694db4f.zip
Maybe it should work; https://github.com/mitmproxy/mitmproxy/issues/319
Diffstat (limited to 'examples/stream_modify.py')
-rw-r--r--examples/stream_modify.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/examples/stream_modify.py b/examples/stream_modify.py
new file mode 100644
index 00000000..517f730a
--- /dev/null
+++ b/examples/stream_modify.py
@@ -0,0 +1,11 @@
+def modify(chunks):
+ """
+ chunks is a generator that can be used to iterate over all chunks.
+ Each chunk is a (prefix, content, suffix) tuple.
+ For example, in the case of chunked transfer encoding: ("3\r\n","foo","\r\n")
+ """
+ for prefix, content, suffix in chunks:
+ yield prefix, content.replace("foo","bar"), suffix
+
+def responseheaders(ctx, flow):
+ flow.response.stream = modify