diff options
Diffstat (limited to 'netlib')
-rw-r--r-- | netlib/http/http2/connections.py | 14 | ||||
-rw-r--r-- | netlib/multidict.py | 8 |
2 files changed, 16 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 diff --git a/netlib/multidict.py b/netlib/multidict.py index 98fde7e3..f8876cbd 100644 --- a/netlib/multidict.py +++ b/netlib/multidict.py @@ -171,6 +171,14 @@ class _MultiDict(MutableMapping, Serializable): else: return super(_MultiDict, self).items() + def clear(self, key): + """ + Removes all items with the specified key, and does not raise an + exception if the key does not exist. + """ + if key in self: + del self[key] + def to_dict(self): """ Get the MultiDict as a plain Python dict. |