diff options
author | Maximilian Hils <git@maximilianhils.com> | 2016-07-15 23:17:57 -0700 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2016-07-15 23:17:57 -0700 |
commit | 3602fd7a36d963311339ab11ed36ff00df860f71 (patch) | |
tree | 5834a98b35c02639c876544bc645f205068fac99 /examples/modify_response_body.py | |
parent | a3c7c84d49c3e6563e7f37ef60c989f99ed96788 (diff) | |
parent | 17305643bc482c0b185eec5c64d506790cd26587 (diff) | |
download | mitmproxy-3602fd7a36d963311339ab11ed36ff00df860f71.tar.gz mitmproxy-3602fd7a36d963311339ab11ed36ff00df860f71.tar.bz2 mitmproxy-3602fd7a36d963311339ab11ed36ff00df860f71.zip |
Merge remote-tracking branch 'origin/master' into message-body-encoding
Diffstat (limited to 'examples/modify_response_body.py')
-rw-r--r-- | examples/modify_response_body.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/examples/modify_response_body.py b/examples/modify_response_body.py index 03dfeaa4..b4632248 100644 --- a/examples/modify_response_body.py +++ b/examples/modify_response_body.py @@ -3,16 +3,19 @@ import sys -def start(context): +state = {} + + +def start(): if len(sys.argv) != 3: raise ValueError('Usage: -s "modify_response_body.py old new"') # You may want to use Python's argparse for more sophisticated argument # parsing. - context.old, context.new = sys.argv[1], sys.argv[2] + state["old"], state["new"] = sys.argv[1].encode(), sys.argv[2].encode() -def response(context, flow): +def response(flow): flow.response.content = flow.response.content.replace( - context.old, - context.new + state["old"], + state["new"] ) |