diff options
author | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2016-05-21 20:18:49 +0200 |
---|---|---|
committer | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2016-05-21 20:24:21 +0200 |
commit | 85a3a92a8adbb07663b6e4bb8ecc017de1b7b286 (patch) | |
tree | 2451e23c4abac888ef324f7e7e60c9b61d7348ab | |
parent | 6965c93be6221f5905dcb1b290fea73c9fe652de (diff) | |
download | mitmproxy-85a3a92a8adbb07663b6e4bb8ecc017de1b7b286.tar.gz mitmproxy-85a3a92a8adbb07663b6e4bb8ecc017de1b7b286.tar.bz2 mitmproxy-85a3a92a8adbb07663b6e4bb8ecc017de1b7b286.zip |
kill streams if connection gets terminated
-rw-r--r-- | mitmproxy/protocol/http2.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/mitmproxy/protocol/http2.py b/mitmproxy/protocol/http2.py index 3c4b59e9..98728c8a 100644 --- a/mitmproxy/protocol/http2.py +++ b/mitmproxy/protocol/http2.py @@ -209,6 +209,11 @@ class Http2Layer(Layer): if zombie and zombie <= death_time: self.streams.pop(stream_id, None) + def _kill_all_streams(self): + for stream in self.streams.values(): + if not stream.zombie: + stream.zombie = time.time() + def __call__(self): if self.server_conn: self._initiate_server_conn() @@ -230,9 +235,7 @@ class Http2Layer(Layer): raw_frame = b''.join(http2_read_raw_frame(source_conn.rfile)) except: # read frame failed: connection closed - # kill all streams - for stream in self.streams.values(): - stream.zombie = time.time() + self._kill_all_streams() return incoming_events = source_conn.h2.receive_data(raw_frame) @@ -240,6 +243,8 @@ class Http2Layer(Layer): for event in incoming_events: if not self._handle_event(event, source_conn, other_conn, is_server): + # connection terminated: GoAway + self._kill_all_streams() return self._cleanup_streams() |