diff options
author | Maximilian Hils <git@maximilianhils.com> | 2016-08-13 08:17:50 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-13 08:17:50 -0700 |
commit | 9da55e20477f10155fb79ba66fdc21cca760e40d (patch) | |
tree | 9b93acc6f9b1a12de8221207605342afd93dd2ab | |
parent | a0391db1ae4b30350572f6b72ce150cac84e9ed9 (diff) | |
parent | 0c3f2a3806f33208aeca79711e8b70e07107e7c1 (diff) | |
download | mitmproxy-9da55e20477f10155fb79ba66fdc21cca760e40d.tar.gz mitmproxy-9da55e20477f10155fb79ba66fdc21cca760e40d.tar.bz2 mitmproxy-9da55e20477f10155fb79ba66fdc21cca760e40d.zip |
Merge pull request #1479 from Kriechi/fix-1430
fix #1430
-rw-r--r-- | mitmproxy/exceptions.py | 4 | ||||
-rw-r--r-- | mitmproxy/protocol/http2.py | 24 |
2 files changed, 15 insertions, 13 deletions
diff --git a/mitmproxy/exceptions.py b/mitmproxy/exceptions.py index 6ca11b25..94876514 100644 --- a/mitmproxy/exceptions.py +++ b/mitmproxy/exceptions.py @@ -103,6 +103,10 @@ class ControlException(ProxyException): pass +class SetServerNotAllowedException(ProxyException): + pass + + class OptionsError(Exception): pass diff --git a/mitmproxy/protocol/http2.py b/mitmproxy/protocol/http2.py index 8308f44d..eb5586cb 100644 --- a/mitmproxy/protocol/http2.py +++ b/mitmproxy/protocol/http2.py @@ -109,15 +109,6 @@ class Http2Layer(base.Layer): self.server_conn.send(self.server_conn.h2.data_to_send()) self.active_conns.append(self.server_conn.connection) - def connect(self): # pragma: no cover - raise exceptions.Http2ProtocolException("HTTP2 layer should already have a connection.") - - def set_server(self): # pragma: no cover - raise exceptions.Http2ProtocolException("Cannot change server for HTTP2 connections.") - - def disconnect(self): # pragma: no cover - raise exceptions.Http2ProtocolException("Cannot dis- or reconnect in HTTP2 connections.") - def next_layer(self): # pragma: no cover # WebSockets over HTTP/2? # CONNECT for proxying? @@ -382,15 +373,20 @@ class Http2SingleStreamLayer(http._HttpTransmissionLayer, basethread.BaseThread) self.priority_weight = None self.handled_priority_event = None + def connect(self): # pragma: no cover + raise exceptions.Http2ProtocolException("HTTP2 layer should already have a connection.") + + def disconnect(self): # pragma: no cover + raise exceptions.Http2ProtocolException("Cannot dis- or reconnect in HTTP2 connections.") + + def set_server(self, address): # pragma: no cover + raise exceptions.SetServerNotAllowedException(repr(address)) + def check_close_connection(self, flow): # This layer only handles a single stream. # RFC 7540 8.1: An HTTP request/response exchange fully consumes a single stream. return True - def set_server(self, *args, **kwargs): # pragma: no cover - # do not mess with the server connection - all streams share it. - pass - @property def data_queue(self): if self.response_arrived.is_set(): @@ -584,6 +580,8 @@ class Http2SingleStreamLayer(http._HttpTransmissionLayer, basethread.BaseThread) except exceptions.ProtocolException as e: # pragma: no cover self.log(repr(e), "info") self.log(traceback.format_exc(), "debug") + except exceptions.SetServerNotAllowedException as e: # pragma: no cover + self.log("Changing the Host server for HTTP/2 connections not allowed: {}".format(e), "info") except exceptions.Kill: self.log("Connection killed", "info") |