aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/modify_querystring.py5
-rw-r--r--test/mitmproxy/test_examples.py8
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"]
+