diff options
author | Shadab Zafar <dufferzafar0@gmail.com> | 2016-03-07 09:19:29 +0530 |
---|---|---|
committer | Shadab Zafar <dufferzafar0@gmail.com> | 2016-03-11 17:57:57 +0530 |
commit | 9ef1522b5f2e855c5d2e343e7d49acd36ee4f6a0 (patch) | |
tree | afdfc67a5b7c14333d874e518318935dc80a7ea1 | |
parent | 96df077d5485979af256fe7b95708ace658fb8e2 (diff) | |
download | mitmproxy-9ef1522b5f2e855c5d2e343e7d49acd36ee4f6a0.tar.gz mitmproxy-9ef1522b5f2e855c5d2e343e7d49acd36ee4f6a0.tar.bz2 mitmproxy-9ef1522b5f2e855c5d2e343e7d49acd36ee4f6a0.zip |
Update modify_querystring example & add test for it
-rw-r--r-- | examples/modify_querystring.py | 5 | ||||
-rw-r--r-- | test/mitmproxy/test_examples.py | 8 |
2 files changed, 9 insertions, 4 deletions
diff --git a/examples/modify_querystring.py b/examples/modify_querystring.py index 7f31a48f..d682df69 100644 --- a/examples/modify_querystring.py +++ b/examples/modify_querystring.py @@ -1,6 +1,5 @@ - def request(context, flow): - q = flow.request.get_query() + q = flow.request.query if q: q["mitmproxy"] = ["rocks"] - flow.request.set_query(q) + flow.request.query = q diff --git a/test/mitmproxy/test_examples.py b/test/mitmproxy/test_examples.py index 8b6e0eab..88bd90bf 100644 --- a/test/mitmproxy/test_examples.py +++ b/test/mitmproxy/test_examples.py @@ -9,7 +9,7 @@ from . import tservers, tutils from examples import ( add_header, modify_form, - + modify_querystring, ) @@ -51,3 +51,9 @@ def test_modify_form(): modify_form.request({}, flow) assert flow.request.urlencoded_form["mitmproxy"] == ["rocks"] + +def test_modify_querystring(): + flow = tutils.tflow(req=netutils.treq(path="/search?q=term")) + modify_querystring.request({}, flow) + assert flow.request.query["mitmproxy"] == ["rocks"] + |