aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-02-23 14:57:43 +1300
committerAldo Cortesi <aldo@nullcube.com>2012-02-23 14:57:43 +1300
commitbc3bf969bac7f4e7a70324fd1736e20abd4b204d (patch)
tree5cded435977eb89858e543ff21d5b5aac802d021
parent3f6619ff5944e41d484b97b064039de238161226 (diff)
downloadmitmproxy-bc3bf969bac7f4e7a70324fd1736e20abd4b204d.tar.gz
mitmproxy-bc3bf969bac7f4e7a70324fd1736e20abd4b204d.tar.bz2
mitmproxy-bc3bf969bac7f4e7a70324fd1736e20abd4b204d.zip
Add an example showing the new form API.
-rw-r--r--examples/README2
-rw-r--r--examples/modify_form.py8
2 files changed, 9 insertions, 1 deletions
diff --git a/examples/README b/examples/README
index 696705a5..24b5c2fe 100644
--- a/examples/README
+++ b/examples/README
@@ -1,6 +1,6 @@
add_header.py Simple script that just adds a header to every request.
flowbasic Basic use of mitmproxy as a library.
+modify_form.py Modify all form submissions to add a parameter.
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/modify_form.py b/examples/modify_form.py
new file mode 100644
index 00000000..2d839aed
--- /dev/null
+++ b/examples/modify_form.py
@@ -0,0 +1,8 @@
+
+def request(context, flow):
+ if "application/x-www-form-urlencoded" in flow.request.headers["content-type"]:
+ frm = flow.request.get_form_urlencoded()
+ frm["mitmproxy"] = ["rocks"]
+ flow.request.set_form_urlencoded(frm)
+
+