aboutsummaryrefslogtreecommitdiffstats
path: root/netlib/http/http2
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2016-05-31 14:34:09 +1200
committerAldo Cortesi <aldo@nullcube.com>2016-05-31 14:36:17 +1200
commit9ea68ebd284ce13d765519a20dd7cfe998c0ae1c (patch)
tree635b4ef4be9203b61f932efb166ccda4bd03a140 /netlib/http/http2
parentd98582664d8f234fe6a2c805f02d47686243379f (diff)
downloadmitmproxy-9ea68ebd284ce13d765519a20dd7cfe998c0ae1c.tar.gz
mitmproxy-9ea68ebd284ce13d765519a20dd7cfe998c0ae1c.tar.bz2
mitmproxy-9ea68ebd284ce13d765519a20dd7cfe998c0ae1c.zip
Improve handling of pseudo-headers
- The canonical source for :method, :scheme and :path are the .method, .scheme and .path attributes on the request object. - These pseudo-headers are stripped after reading the request, and re-inserted just before sending. - The :authority header remains, and should be handled analagously to the Host header in HTTP1 with respect to display and user interaction.
Diffstat (limited to 'netlib/http/http2')
-rw-r--r--netlib/http/http2/connections.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/netlib/http/http2/connections.py b/netlib/http/http2/connections.py
index b988d6ef..6b91f2ff 100644
--- a/netlib/http/http2/connections.py
+++ b/netlib/http/http2/connections.py
@@ -98,6 +98,11 @@ class HTTP2Protocol(object):
method = headers.get(':method', 'GET')
scheme = headers.get(':scheme', 'https')
path = headers.get(':path', '/')
+
+ headers.clear(":method")
+ headers.clear(":scheme")
+ headers.clear(":path")
+
host = None
port = None
@@ -202,12 +207,9 @@ class HTTP2Protocol(object):
if ':authority' not in headers:
headers.insert(0, b':authority', authority.encode('ascii'))
- if ':scheme' not in headers:
- headers.insert(0, b':scheme', request.scheme.encode('ascii'))
- if ':path' not in headers:
- headers.insert(0, b':path', request.path.encode('ascii'))
- if ':method' not in headers:
- headers.insert(0, b':method', request.method.encode('ascii'))
+ headers.insert(0, b':scheme', request.scheme.encode('ascii'))
+ headers.insert(0, b':path', request.path.encode('ascii'))
+ headers.insert(0, b':method', request.method.encode('ascii'))
if hasattr(request, 'stream_id'):
stream_id = request.stream_id