aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Kriechbaumer <thomas@kriechbaumer.name>2016-08-23 19:12:03 +0200
committerThomas Kriechbaumer <thomas@kriechbaumer.name>2016-09-03 10:00:31 +0200
commit9b5acc19e2171cb70f7c87c62a283b9398156883 (patch)
treeae4a24c8041067bba66f1ba88906fd0566b78cb8
parent0badb3ec91d27ff529b8ea446848431e89fe8ad7 (diff)
downloadmitmproxy-9b5acc19e2171cb70f7c87c62a283b9398156883.tar.gz
mitmproxy-9b5acc19e2171cb70f7c87c62a283b9398156883.tar.bz2
mitmproxy-9b5acc19e2171cb70f7c87c62a283b9398156883.zip
http2: improve zombie exception handling
-rw-r--r--mitmproxy/exceptions.py3
-rw-r--r--mitmproxy/protocol/http2.py7
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")