aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorThomas Kriechbaumer <thomas@kriechbaumer.name>2016-05-10 10:57:44 -0500
committerThomas Kriechbaumer <thomas@kriechbaumer.name>2016-05-17 21:25:10 -0700
commite61014d20301b1b2ca403cd5a1d9e0ee5b2d8de9 (patch)
tree6330277eecf07375b81370ced15f0acb7bcd91f4 /test
parentd27fd5565727165ffb9ab4796059b14c1e30d27b (diff)
downloadmitmproxy-e61014d20301b1b2ca403cd5a1d9e0ee5b2d8de9.tar.gz
mitmproxy-e61014d20301b1b2ca403cd5a1d9e0ee5b2d8de9.tar.bz2
mitmproxy-e61014d20301b1b2ca403cd5a1d9e0ee5b2d8de9.zip
http2: add connection-lost test
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/test_protocol_http2.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/test/mitmproxy/test_protocol_http2.py b/test/mitmproxy/test_protocol_http2.py
index dcb6ff3c..c3950975 100644
--- a/test/mitmproxy/test_protocol_http2.py
+++ b/test/mitmproxy/test_protocol_http2.py
@@ -434,3 +434,51 @@ class TestPushPromise(_Http2TestBase, _Http2ServerBase):
assert len(bodies) >= 1
assert b'regular_stream' in bodies
# the other two bodies might not be transmitted before the reset
+
+@requires_alpn
+class TestConnectionLost(_Http2TestBase, _Http2ServerBase):
+
+ @classmethod
+ def setup_class(self):
+ _Http2TestBase.setup_class()
+ _Http2ServerBase.setup_class()
+
+ @classmethod
+ def teardown_class(self):
+ _Http2TestBase.teardown_class()
+ _Http2ServerBase.teardown_class()
+
+ @classmethod
+ def handle_server_event(self, event, h2_conn, rfile, wfile):
+ if isinstance(event, h2.events.RequestReceived):
+ h2_conn.send_headers(1, [(':status', '200')])
+ wfile.write(h2_conn.data_to_send())
+ wfile.flush()
+ return False
+
+ def test_connection_lost(self):
+ client, h2_conn = self._setup_connection()
+
+ self._send_request(client.wfile, h2_conn, stream_id=1, headers=[
+ (':authority', "127.0.0.1:%s" % self.server.server.address.port),
+ (':method', 'GET'),
+ (':scheme', 'https'),
+ (':path', '/'),
+ ('foo', 'bar')
+ ])
+
+ done = False
+ ended_streams = 0
+ pushed_streams = 0
+ responses = 0
+ while not done:
+ try:
+ raw = b''.join(http2_read_raw_frame(client.rfile))
+ events = h2_conn.receive_data(raw)
+ except:
+ break
+ client.wfile.write(h2_conn.data_to_send())
+ client.wfile.flush()
+
+ if len(self.master.state.flows) == 1:
+ assert self.master.state.flows[0].response is None