Merge pull request #1304 from ignatenkobrain/fedora
Switch to websockets 6.0
This commit is contained in:
commit
4466e8cce1
|
@ -15,7 +15,7 @@ dependencies:
|
|||
- httptools>=0.0.10
|
||||
- ujson>=1.35
|
||||
- aiofiles>=0.3.0
|
||||
- websockets>=3.2
|
||||
- websockets>=6.0
|
||||
- sphinxcontrib-asyncio>=0.2.0
|
||||
- multidict>=4.0<5.0
|
||||
- https://github.com/channelcat/docutils-fork/zipball/master
|
||||
|
|
|
@ -2,5 +2,5 @@ aiofiles
|
|||
httptools>=0.0.10
|
||||
ujson; sys_platform != "win32" and implementation_name == "cpython"
|
||||
uvloop; sys_platform != "win32" and implementation_name == "cpython"
|
||||
websockets>=5.0,<6.0
|
||||
websockets>=6.0,<7.0
|
||||
multidict>=4.0,<5.0
|
||||
|
|
|
@ -57,17 +57,11 @@ class WebSocketProtocol(HttpProtocol):
|
|||
|
||||
async def websocket_handshake(self, request, subprotocols=None):
|
||||
# let the websockets package do the handshake with the client
|
||||
headers = []
|
||||
|
||||
def get_header(k):
|
||||
return request.headers.get(k, '')
|
||||
|
||||
def set_header(k, v):
|
||||
headers.append((k, v))
|
||||
headers = {}
|
||||
|
||||
try:
|
||||
key = handshake.check_request(get_header)
|
||||
handshake.build_response(set_header, key)
|
||||
key = handshake.check_request(request.headers)
|
||||
handshake.build_response(headers, key)
|
||||
except InvalidHandshake:
|
||||
raise InvalidUsage('Invalid websocket request')
|
||||
|
||||
|
@ -79,12 +73,12 @@ class WebSocketProtocol(HttpProtocol):
|
|||
for p in client_subprotocols:
|
||||
if p in subprotocols:
|
||||
subprotocol = p
|
||||
set_header('Sec-Websocket-Protocol', subprotocol)
|
||||
headers['Sec-Websocket-Protocol'] = subprotocol
|
||||
break
|
||||
|
||||
# write the 101 response back to the client
|
||||
rv = b'HTTP/1.1 101 Switching Protocols\r\n'
|
||||
for k, v in headers:
|
||||
for k, v in headers.items():
|
||||
rv += k.encode('utf-8') + b': ' + v.encode('utf-8') + b'\r\n'
|
||||
rv += b'\r\n'
|
||||
request.transport.write(rv)
|
||||
|
|
Loading…
Reference in New Issue
Block a user