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:
Maximilian Hils
2016-05-18 18:46:42 -07:00
parent 4c3fb8f509
commit 44ac64aa72
23 changed files with 369 additions and 264 deletions

View File

@@ -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")
]

View File

@@ -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"