aboutsummaryrefslogtreecommitdiffstats
path: root/netlib/http/http2
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2016-05-18 18:46:42 -0700
committerMaximilian Hils <git@maximilianhils.com>2016-05-18 18:46:42 -0700
commit44ac64aa7235362acbb96e0f12aa27534580e575 (patch)
treec03b8c3519c273a4f42b60cb2bce8cc0dd524925 /netlib/http/http2
parent4c3fb8f5097fad2c5de96104dae3f8026b0b4666 (diff)
downloadmitmproxy-44ac64aa7235362acbb96e0f12aa27534580e575.tar.gz
mitmproxy-44ac64aa7235362acbb96e0f12aa27534580e575.tar.bz2
mitmproxy-44ac64aa7235362acbb96e0f12aa27534580e575.zip
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.
Diffstat (limited to 'netlib/http/http2')
-rw-r--r--netlib/http/http2/connections.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/netlib/http/http2/connections.py b/netlib/http/http2/connections.py
index f900b67c..6643b6b9 100644
--- a/netlib/http/http2/connections.py
+++ b/netlib/http/http2/connections.py
@@ -201,13 +201,13 @@ class HTTP2Protocol(object):
headers = request.headers.copy()
if ':authority' not in headers:
- headers.fields.insert(0, (b':authority', authority.encode('ascii')))
+ headers.insert(0, b':authority', authority.encode('ascii'))
if ':scheme' not in headers:
- headers.fields.insert(0, (b':scheme', request.scheme.encode('ascii')))
+ headers.insert(0, b':scheme', request.scheme.encode('ascii'))
if ':path' not in headers:
- headers.fields.insert(0, (b':path', request.path.encode('ascii')))
+ headers.insert(0, b':path', request.path.encode('ascii'))
if ':method' not in headers:
- headers.fields.insert(0, (b':method', request.method.encode('ascii')))
+ headers.insert(0, b':method', request.method.encode('ascii'))
if hasattr(request, 'stream_id'):
stream_id = request.stream_id
@@ -224,7 +224,7 @@ class HTTP2Protocol(object):
headers = response.headers.copy()
if ':status' not in headers:
- headers.fields.insert(0, (b':status', str(response.status_code).encode('ascii')))
+ headers.insert(0, b':status', str(response.status_code).encode('ascii'))
if hasattr(response, 'stream_id'):
stream_id = response.stream_id
@@ -420,7 +420,7 @@ class HTTP2Protocol(object):
self._handle_unexpected_frame(frm)
headers = Headers(
- [[k.encode('ascii'), v.encode('ascii')] for k, v in self.decoder.decode(header_blocks)]
+ (k.encode('ascii'), v.encode('ascii')) for k, v in self.decoder.decode(header_blocks)
)
return stream_id, headers, body