mirror of
https://github.com/zhigang1992/mitmproxy.git
synced 2026-04-28 20:24:59 +08:00
add MultiDict
This commit introduces MultiDict, a multi-dictionary similar to ODict, but with improved semantics (as in the Headers class). MultiDict fixes a few issues that were present in the Request/Response API. In particular, `request.cookies["foo"] = "bar"` has previously been a no-op, as the cookies property returned a mutable _copy_ of the cookies.
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
def request(context, flow):
|
||||
form = flow.request.urlencoded_form
|
||||
if form is not None:
|
||||
form["mitmproxy"] = ["rocks"]
|
||||
flow.request.urlencoded_form = form
|
||||
if flow.request.urlencoded_form is not None:
|
||||
flow.request.urlencoded_form["mitmproxy"] = "rocks"
|
||||
else:
|
||||
# This sets the proper content type and overrides the body.
|
||||
flow.request.urlencoded_form = [
|
||||
("foo", "bar")
|
||||
]
|
||||
|
||||
@@ -1,5 +1,2 @@
|
||||
def request(context, flow):
|
||||
q = flow.request.query
|
||||
if q:
|
||||
q["mitmproxy"] = ["rocks"]
|
||||
flow.request.query = q
|
||||
flow.request.query["mitmproxy"] = "rocks"
|
||||
|
||||
Reference in New Issue
Block a user