aboutsummaryrefslogtreecommitdiffstats
path: root/netlib/http/http2/protocol.py
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2015-08-11 10:57:32 +0200
committerMaximilian Hils <git@maximilianhils.com>2015-08-11 10:57:32 +0200
commitf3a611339148a5a3de141ff1234ec9018ab20896 (patch)
tree5c53dc5d5eb8a06d1caaed84b04fd137cdbee6a1 /netlib/http/http2/protocol.py
parentc2832ef72bd4eed485a1c8d4bcb732da69896444 (diff)
parent6a30ad2ad236fa20d086e271ff962ebc907da027 (diff)
downloadmitmproxy-f3a611339148a5a3de141ff1234ec9018ab20896.tar.gz
mitmproxy-f3a611339148a5a3de141ff1234ec9018ab20896.tar.bz2
mitmproxy-f3a611339148a5a3de141ff1234ec9018ab20896.zip
Merge pull request #85 from Kriechi/http2-wip
add move tests and code from mitmproxy
Diffstat (limited to 'netlib/http/http2/protocol.py')
-rw-r--r--netlib/http/http2/protocol.py27
1 files changed, 18 insertions, 9 deletions
diff --git a/netlib/http/http2/protocol.py b/netlib/http/http2/protocol.py
index a1ca4a18..c2ad5edd 100644
--- a/netlib/http/http2/protocol.py
+++ b/netlib/http/http2/protocol.py
@@ -9,6 +9,7 @@ from . import frame
class TCPHandler(object):
+
def __init__(self, rfile, wfile=None):
self.rfile = rfile
self.wfile = wfile
@@ -39,7 +40,6 @@ class HTTP2Protocol(semantics.ProtocolMixin):
ALPN_PROTO_H2 = 'h2'
-
def __init__(
self,
tcp_handler=None,
@@ -60,7 +60,12 @@ class HTTP2Protocol(semantics.ProtocolMixin):
self.current_stream_id = None
self.connection_preface_performed = False
- def read_request(self, include_body=True, body_size_limit=None, allow_empty=False):
+ def read_request(
+ self,
+ include_body=True,
+ body_size_limit=None,
+ allow_empty=False,
+ ):
self.perform_connection_preface()
timestamp_start = time.time()
@@ -92,7 +97,12 @@ class HTTP2Protocol(semantics.ProtocolMixin):
return request
- def read_response(self, request_method='', body_size_limit=None, include_body=True):
+ def read_response(
+ self,
+ request_method='',
+ body_size_limit=None,
+ include_body=True,
+ ):
self.perform_connection_preface()
timestamp_start = time.time()
@@ -123,7 +133,6 @@ class HTTP2Protocol(semantics.ProtocolMixin):
return response
-
def assemble_request(self, request):
assert isinstance(request, semantics.Request)
@@ -133,13 +142,13 @@ class HTTP2Protocol(semantics.ProtocolMixin):
headers = request.headers.copy()
- if not ':authority' in headers.keys():
+ if ':authority' not in headers.keys():
headers.add(':authority', bytes(authority), prepend=True)
- if not ':scheme' in headers.keys():
+ if ':scheme' not in headers.keys():
headers.add(':scheme', bytes(request.scheme), prepend=True)
- if not ':path' in headers.keys():
+ if ':path' not in headers.keys():
headers.add(':path', bytes(request.path), prepend=True)
- if not ':method' in headers.keys():
+ if ':method' not in headers.keys():
headers.add(':method', bytes(request.method), prepend=True)
headers = headers.items()
@@ -158,7 +167,7 @@ class HTTP2Protocol(semantics.ProtocolMixin):
headers = response.headers.copy()
- if not ':status' in headers.keys():
+ if ':status' not in headers.keys():
headers.add(':status', bytes(str(response.status_code)), prepend=True)
headers = headers.items()