aboutsummaryrefslogtreecommitdiffstats
path: root/netlib/utils.py
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2015-09-05 18:15:47 +0200
committerMaximilian Hils <git@maximilianhils.com>2015-09-05 18:15:47 +0200
commit66ee1f465f6c492d5a4ff5659e6f0346fb243d67 (patch)
tree81599af6bf38402059dcf6f387dfcf9b599c375e /netlib/utils.py
parent3718e59308745e4582f4e8061b4ff6113d9dfc74 (diff)
downloadmitmproxy-66ee1f465f6c492d5a4ff5659e6f0346fb243d67.tar.gz
mitmproxy-66ee1f465f6c492d5a4ff5659e6f0346fb243d67.tar.bz2
mitmproxy-66ee1f465f6c492d5a4ff5659e6f0346fb243d67.zip
headers: adjust everything
Diffstat (limited to 'netlib/utils.py')
-rw-r--r--netlib/utils.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/netlib/utils.py b/netlib/utils.py
index d6190673..aae187da 100644
--- a/netlib/utils.py
+++ b/netlib/utils.py
@@ -204,11 +204,10 @@ def get_header_tokens(headers, key):
follow a pattern where each header line can containe comma-separated
tokens, and headers can be set multiple times.
"""
- toks = []
- for i in headers[key]:
- for j in i.split(","):
- toks.append(j.strip())
- return toks
+ if key not in headers:
+ return []
+ tokens = headers[key].split(",")
+ return [token.strip() for token in tokens]
def hostport(scheme, host, port):
@@ -270,11 +269,11 @@ def parse_content_type(c):
return ts[0].lower(), ts[1].lower(), d
-def multipartdecode(hdrs, content):
+def multipartdecode(headers, content):
"""
Takes a multipart boundary encoded string and returns list of (key, value) tuples.
"""
- v = hdrs.get_first("content-type")
+ v = headers.get("content-type")
if v:
v = parse_content_type(v)
if not v: