Merge pull request #1304 from ignatenkobrain/fedora

Switch to websockets 6.0
This commit is contained in:
Stephen Sadowski 2018-10-04 18:45:22 -05:00 committed by GitHub
commit 4466e8cce1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 14 deletions

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -60,7 +60,7 @@ requirements = [
uvloop,
ujson,
'aiofiles>=0.3.0',
'websockets>=5.0,<6.0',
'websockets>=6.0,<7.0',
'multidict>=4.0,<5.0',
]
if strtobool(os.environ.get("SANIC_NO_UJSON", "no")):