Add a custom override of buildProtocol.

This commit is contained in:
Cory Benfield 2016-11-18 10:15:16 +00:00
parent fd83678276
commit 0adf05246c
No known key found for this signature in database
GPG Key ID: 70FE17F8A643E15B

View File

@ -275,11 +275,6 @@ class WebRequest(http.Request):
})
class HTTPProtocol(http.HTTPChannel):
requestFactory = WebRequest
class HTTPFactory(http.HTTPFactory):
"""
Factory which takes care of tracking which protocol
@ -288,8 +283,6 @@ class HTTPFactory(http.HTTPFactory):
routed appropriately.
"""
protocol = HTTPProtocol
def __init__(self, channel_layer, action_logger=None, timeout=120, websocket_timeout=86400, ping_interval=20, ping_timeout=30, ws_protocols=None, root_path="", websocket_connect_timeout=30, proxy_forwarded_address_header=None, proxy_forwarded_port_header=None):
http.HTTPFactory.__init__(self)
self.channel_layer = channel_layer
@ -309,6 +302,15 @@ class HTTPFactory(http.HTTPFactory):
self.ws_factory.reply_protocols = self.reply_protocols
self.root_path = root_path
def buildProtocol(self, addr):
"""
Builds protocol instances. This override is used to ensure we use our
own Request object instead of the default.
"""
protocol = http.HTTPFactory.buildProtocol(self, addr)
protocol.requestFactory = WebRequest
return protocol
def reply_channels(self):
return self.reply_protocols.keys()