mirror of
https://github.com/django/daphne.git
synced 2024-11-25 01:03:45 +03:00
Merge pull request #29 from fcurella/ws_protocols
parse multiple subprotocols and return the first match
This commit is contained in:
commit
28c2a535d1
|
@ -68,8 +68,13 @@ class WebSocketProtocol(WebSocketServerProtocol):
|
||||||
|
|
||||||
ws_protocol = None
|
ws_protocol = None
|
||||||
for header, value in self.clean_headers:
|
for header, value in self.clean_headers:
|
||||||
if header == 'sec-websocket-protocol':
|
if header == b'sec-websocket-protocol':
|
||||||
ws_protocol = value
|
protocols = [x.strip() for x in self.unquote(value).split(",")]
|
||||||
|
for protocol in protocols:
|
||||||
|
if protocol in self.factory.protocols:
|
||||||
|
ws_protocol = protocol
|
||||||
|
break
|
||||||
|
|
||||||
if ws_protocol and ws_protocol in self.factory.protocols:
|
if ws_protocol and ws_protocol in self.factory.protocols:
|
||||||
return ws_protocol
|
return ws_protocol
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user