diff options
author | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2017-05-26 17:59:19 +0200 |
---|---|---|
committer | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2017-05-26 17:59:19 +0200 |
commit | e5414ae2d3c124b192fd057ed44441ca5298a87f (patch) | |
tree | 54d21c491b7f1b93d68249f677e679d6647e06f0 | |
parent | 4fb9cc1a69f7000e274a2f26d91d2b198bc7c8b1 (diff) | |
download | mitmproxy-e5414ae2d3c124b192fd057ed44441ca5298a87f.tar.gz mitmproxy-e5414ae2d3c124b192fd057ed44441ca5298a87f.tar.bz2 mitmproxy-e5414ae2d3c124b192fd057ed44441ca5298a87f.zip |
http2: prevent KeyError
-rw-r--r-- | mitmproxy/proxy/protocol/http2.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/mitmproxy/proxy/protocol/http2.py b/mitmproxy/proxy/protocol/http2.py index 2191b54b..ace7ecde 100644 --- a/mitmproxy/proxy/protocol/http2.py +++ b/mitmproxy/proxy/protocol/http2.py @@ -206,14 +206,15 @@ class Http2Layer(base.Layer): return True def _handle_stream_reset(self, eid, event, is_server, other_conn): - self.streams[eid].kill() - if eid in self.streams and event.error_code == h2.errors.ErrorCodes.CANCEL: - if is_server: - other_stream_id = self.streams[eid].client_stream_id - else: - other_stream_id = self.streams[eid].server_stream_id - if other_stream_id is not None: - self.connections[other_conn].safe_reset_stream(other_stream_id, event.error_code) + if eid in self.streams: + self.streams[eid].kill() + if event.error_code == h2.errors.ErrorCodes.CANCEL: + if is_server: + other_stream_id = self.streams[eid].client_stream_id + else: + other_stream_id = self.streams[eid].server_stream_id + if other_stream_id is not None: + self.connections[other_conn].safe_reset_stream(other_stream_id, event.error_code) return True def _handle_remote_settings_changed(self, event, other_conn): |