diff options
author | Maximilian Hils <git@maximilianhils.com> | 2016-05-17 22:03:32 -0700 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2016-05-17 22:03:32 -0700 |
commit | 9a280119d297bf24cb9fd21df36c1a5764158ee1 (patch) | |
tree | dc17956dd9baa2be698a0099c5fda4a64b6b15a0 /test | |
parent | d27fd5565727165ffb9ab4796059b14c1e30d27b (diff) | |
parent | 43ab9f7bd07e28c5d0d99b82f25c470db161eecd (diff) | |
download | mitmproxy-9a280119d297bf24cb9fd21df36c1a5764158ee1.tar.gz mitmproxy-9a280119d297bf24cb9fd21df36c1a5764158ee1.tar.bz2 mitmproxy-9a280119d297bf24cb9fd21df36c1a5764158ee1.zip |
Merge pull request #1126 from Kriechi/safeguard
Safeguard
Diffstat (limited to 'test')
-rw-r--r-- | test/mitmproxy/test_protocol_http2.py | 48 |
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 |