diff options
-rw-r--r-- | mitmproxy/exceptions.py | 3 | ||||
-rw-r--r-- | mitmproxy/protocol/http2.py | 7 |
2 files changed, 8 insertions, 2 deletions
diff --git a/mitmproxy/exceptions.py b/mitmproxy/exceptions.py index 94876514..9ecfa8e5 100644 --- a/mitmproxy/exceptions.py +++ b/mitmproxy/exceptions.py @@ -61,6 +61,9 @@ class HttpProtocolException(ProtocolException): class Http2ProtocolException(ProtocolException): pass +class Http2ZombieException(ProtocolException): + pass + class ServerException(ProxyException): pass diff --git a/mitmproxy/protocol/http2.py b/mitmproxy/protocol/http2.py index ee105781..7ae7f09d 100644 --- a/mitmproxy/protocol/http2.py +++ b/mitmproxy/protocol/http2.py @@ -422,10 +422,11 @@ class Http2SingleStreamLayer(http._HttpTransmissionLayer, basethread.BaseThread) self.request_queued_data_length = v def raise_zombie(self, pre_command=None): - if self.zombie is not None: + connection_closed = self.h2_connection.state_machine.state == h2.connection.ConnectionState.CLOSED + if self.zombie is not None or connection_closed: if pre_command is not None: pre_command() - raise exceptions.Http2ProtocolException("Zombie Stream") + raise exceptions.Http2ZombieException("Connection already dead") @detect_zombie_stream def read_request(self): @@ -582,6 +583,8 @@ class Http2SingleStreamLayer(http._HttpTransmissionLayer, basethread.BaseThread) try: layer() + except exceptions.Http2ZombieException as e: # pragma: no cover + pass except exceptions.ProtocolException as e: # pragma: no cover self.log(repr(e), "info") self.log(traceback.format_exc(), "debug") |