aboutsummaryrefslogtreecommitdiffstats
path: root/mitmproxy/flow.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2016-05-21 10:15:37 +1200
committerAldo Cortesi <aldo@nullcube.com>2016-05-21 10:15:37 +1200
commit96d8ec1ee33b076a472afc3053fdd8256559fcc3 (patch)
tree933549b94c497b70eb6165f90bef191eebca4cc7 /mitmproxy/flow.py
parent84144ca0c635f4a42c8ba8a13e779fe127a81d45 (diff)
parentb538138ead1dc8550f2d4e4a3f30ff70abb95f53 (diff)
downloadmitmproxy-96d8ec1ee33b076a472afc3053fdd8256559fcc3.tar.gz
mitmproxy-96d8ec1ee33b076a472afc3053fdd8256559fcc3.tar.bz2
mitmproxy-96d8ec1ee33b076a472afc3053fdd8256559fcc3.zip
Merge branch 'multidict' of https://github.com/mhils/mitmproxy into mhils-multidict
Diffstat (limited to 'mitmproxy/flow.py')
-rw-r--r--mitmproxy/flow.py34
1 files changed, 16 insertions, 18 deletions
diff --git a/mitmproxy/flow.py b/mitmproxy/flow.py
index ccedd1d4..a9018e16 100644
--- a/mitmproxy/flow.py
+++ b/mitmproxy/flow.py
@@ -158,9 +158,9 @@ class SetHeaders:
for _, header, value, cpatt in self.lst:
if cpatt(f):
if f.response:
- f.response.headers.fields.append((header, value))
+ f.response.headers.add(header, value)
else:
- f.request.headers.fields.append((header, value))
+ f.request.headers.add(header, value)
class StreamLargeBodies(object):
@@ -265,7 +265,7 @@ class ServerPlaybackState:
form_contents = r.urlencoded_form or r.multipart_form
if self.ignore_payload_params and form_contents:
key.extend(
- p for p in form_contents
+ p for p in form_contents.items(multi=True)
if p[0] not in self.ignore_payload_params
)
else:
@@ -321,10 +321,10 @@ class StickyCookieState:
"""
domain = f.request.host
path = "/"
- if attrs["domain"]:
- domain = attrs["domain"][-1]
- if attrs["path"]:
- path = attrs["path"][-1]
+ if "domain" in attrs:
+ domain = attrs["domain"]
+ if "path" in attrs:
+ path = attrs["path"]
return (domain, f.request.port, path)
def domain_match(self, a, b):
@@ -335,28 +335,26 @@ class StickyCookieState:
return False
def handle_response(self, f):
- for i in f.response.headers.get_all("set-cookie"):
+ for name, (value, attrs) in f.response.cookies.items(multi=True):
# FIXME: We now know that Cookie.py screws up some cookies with
# valid RFC 822/1123 datetime specifications for expiry. Sigh.
- name, value, attrs = cookies.parse_set_cookie_header(str(i))
a = self.ckey(attrs, f)
if self.domain_match(f.request.host, a[0]):
- b = attrs.lst
- b.insert(0, [name, value])
- self.jar[a][name] = odict.ODictCaseless(b)
+ b = attrs.with_insert(0, name, value)
+ self.jar[a][name] = b
def handle_request(self, f):
l = []
if f.match(self.flt):
- for i in self.jar.keys():
+ for domain, port, path in self.jar.keys():
match = [
- self.domain_match(f.request.host, i[0]),
- f.request.port == i[1],
- f.request.path.startswith(i[2])
+ self.domain_match(f.request.host, domain),
+ f.request.port == port,
+ f.request.path.startswith(path)
]
if all(match):
- c = self.jar[i]
- l.extend([cookies.format_cookie_header(c[name]) for name in c.keys()])
+ c = self.jar[(domain, port, path)]
+ l.extend([cookies.format_cookie_header(c[name].items(multi=True)) for name in c.keys()])
if l:
f.request.stickycookie = True
f.request.headers["cookie"] = "; ".join(l)