From 77bb0b74ed9cf156490f52a162a4d1856694db4f Mon Sep 17 00:00:00 2001 From: Youhei Sakurai Date: Fri, 27 Feb 2015 02:44:47 +0900 Subject: Maybe it should work; https://github.com/mitmproxy/mitmproxy/issues/319 --- examples/stream_modify.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 examples/stream_modify.py (limited to 'examples') 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 -- cgit v1.2.3