diff --git a/daphne/http_protocol.py b/daphne/http_protocol.py index a30cbed..74d4239 100755 --- a/daphne/http_protocol.py +++ b/daphne/http_protocol.py @@ -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()