Merge pull request #1479 from Kriechi/fix-1430

fix #1430
This commit is contained in:
Maximilian Hils 2016-08-13 08:17:50 -07:00 committed by GitHub
commit 9da55e2047
2 changed files with 15 additions and 13 deletions

View File

@ -103,6 +103,10 @@ class ControlException(ProxyException):
pass pass
class SetServerNotAllowedException(ProxyException):
pass
class OptionsError(Exception): class OptionsError(Exception):
pass pass

View File

@ -109,15 +109,6 @@ class Http2Layer(base.Layer):
self.server_conn.send(self.server_conn.h2.data_to_send()) self.server_conn.send(self.server_conn.h2.data_to_send())
self.active_conns.append(self.server_conn.connection) 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 def next_layer(self): # pragma: no cover
# WebSockets over HTTP/2? # WebSockets over HTTP/2?
# CONNECT for proxying? # CONNECT for proxying?
@ -382,15 +373,20 @@ class Http2SingleStreamLayer(http._HttpTransmissionLayer, basethread.BaseThread)
self.priority_weight = None self.priority_weight = None
self.handled_priority_event = 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): def check_close_connection(self, flow):
# This layer only handles a single stream. # This layer only handles a single stream.
# RFC 7540 8.1: An HTTP request/response exchange fully consumes a single stream. # RFC 7540 8.1: An HTTP request/response exchange fully consumes a single stream.
return True return True
def set_server(self, *args, **kwargs): # pragma: no cover
# do not mess with the server connection - all streams share it.
pass
@property @property
def data_queue(self): def data_queue(self):
if self.response_arrived.is_set(): if self.response_arrived.is_set():
@ -584,6 +580,8 @@ class Http2SingleStreamLayer(http._HttpTransmissionLayer, basethread.BaseThread)
except exceptions.ProtocolException as e: # pragma: no cover except exceptions.ProtocolException as e: # pragma: no cover
self.log(repr(e), "info") self.log(repr(e), "info")
self.log(traceback.format_exc(), "debug") 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: except exceptions.Kill:
self.log("Connection killed", "info") self.log("Connection killed", "info")