mirror of
https://github.com/django/daphne.git
synced 2024-11-21 23:46:33 +03:00
Add a custom override of buildProtocol.
This commit is contained in:
parent
d86d7dd3c4
commit
d3f26a6bf2
|
@ -283,11 +283,6 @@ class WebRequest(http.Request):
|
|||
})
|
||||
|
||||
|
||||
class HTTPProtocol(http.HTTPChannel):
|
||||
|
||||
requestFactory = WebRequest
|
||||
|
||||
|
||||
class HTTPFactory(http.HTTPFactory):
|
||||
"""
|
||||
Factory which takes care of tracking which protocol
|
||||
|
@ -296,8 +291,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
|
||||
|
@ -320,6 +313,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()
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user