From 62ca9b71ff940221126bf1189eace9de7c485f5f Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Thu, 23 Feb 2012 15:43:04 +1300 Subject: [PATCH] Add two more examples: dup_and_replay.py and modify_querystring.py --- examples/README | 2 ++ examples/dup_and_replay.py | 4 ++++ examples/modify_querystring.py | 7 +++++++ 3 files changed, 13 insertions(+) create mode 100644 examples/dup_and_replay.py create mode 100644 examples/modify_querystring.py diff --git a/examples/README b/examples/README index 24b5c2fe1..9ea6f9a26 100644 --- a/examples/README +++ b/examples/README @@ -1,6 +1,8 @@ add_header.py Simple script that just adds a header to every request. +dup_and_replay.py Duplicates each request, changes it, and then replays the modified request. flowbasic Basic use of mitmproxy as a library. modify_form.py Modify all form submissions to add a parameter. +modify_querystring.py Modify all query strings to add a parameters. stub.py Script stub with a method definition for every event. stickycookies An example of writing a custom proxy with libmproxy. upsidedownternet.py Rewrites traffic to turn PNGs upside down. diff --git a/examples/dup_and_replay.py b/examples/dup_and_replay.py new file mode 100644 index 000000000..9c58d3a4d --- /dev/null +++ b/examples/dup_and_replay.py @@ -0,0 +1,4 @@ +def request(ctx, flow): + f = ctx.duplicate_flow(flow) + f.request.path = "/changed" + ctx.replay_request(f) diff --git a/examples/modify_querystring.py b/examples/modify_querystring.py new file mode 100644 index 000000000..b1abcc1ee --- /dev/null +++ b/examples/modify_querystring.py @@ -0,0 +1,7 @@ + +def request(context, flow): + q = flow.request.get_query() + if q: + q["mitmproxy"] = ["rocks"] + flow.request.set_query(q) +