diff options
author | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2016-05-26 13:43:24 +0200 |
---|---|---|
committer | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2016-06-04 11:20:10 +0200 |
commit | ac70eaed6635ee506c9d9e1920e225f54bb26279 (patch) | |
tree | 089a2cfbe171ae34a136c2191dd5c68fb41f685c | |
parent | 7f4ac6f27bf7ed9b4fbd5bde616d9b2d2f81145a (diff) | |
download | mitmproxy-ac70eaed6635ee506c9d9e1920e225f54bb26279.tar.gz mitmproxy-ac70eaed6635ee506c9d9e1920e225f54bb26279.tar.bz2 mitmproxy-ac70eaed6635ee506c9d9e1920e225f54bb26279.zip |
http2: improve GoAway handling
-rw-r--r-- | mitmproxy/protocol/http2.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/mitmproxy/protocol/http2.py b/mitmproxy/protocol/http2.py index 865fe645..49219ede 100644 --- a/mitmproxy/protocol/http2.py +++ b/mitmproxy/protocol/http2.py @@ -165,9 +165,21 @@ class Http2Layer(base.Layer): new_settings = dict([(id, cs.new_value) for (id, cs) in six.iteritems(event.changed_settings)]) other_conn.h2.safe_update_settings(new_settings) elif isinstance(event, events.ConnectionTerminated): - # Do not immediately terminate the other connection. - # Some streams might be still sending data to the client. - return False + if event.error_code == h2.errors.NO_ERROR: + # Do not immediately terminate the other connection. + # Some streams might be still sending data to the client. + return False + else: + # Something terrible has happened - kill everything! + self.client_conn.h2.close_connection( + error_code=event.error_code, + last_stream_id=event.last_stream_id, + additional_data=event.additional_data + ) + self.client_conn.send(self.client_conn.h2.data_to_send()) + self._kill_all_streams() + return False + elif isinstance(event, events.PushedStreamReceived): # pushed stream ids should be unique and not dependent on race conditions # only the parent stream id must be looked up first |