Support websockets 8.x as well as 7.x (#1687)

Sanic currently requires websockets 7.x, but it's straightforward to
also support the more recent 8.x.
This commit is contained in:
Simon 2019-10-02 07:03:10 +01:00 committed by 7
parent c54a8b10bb
commit 134c414fe5
2 changed files with 4 additions and 1 deletions

View File

@ -119,6 +119,9 @@ class WebSocketProtocol(HttpProtocol):
read_limit=self.websocket_read_limit, read_limit=self.websocket_read_limit,
write_limit=self.websocket_write_limit, write_limit=self.websocket_write_limit,
) )
# Following two lines are required for websockets 8.x
self.websocket.is_client = False
self.websocket.side = "server"
self.websocket.subprotocol = subprotocol self.websocket.subprotocol = subprotocol
self.websocket.connection_made(request.transport) self.websocket.connection_made(request.transport)
self.websocket.connection_open() self.websocket.connection_open()

View File

@ -80,7 +80,7 @@ requirements = [
uvloop, uvloop,
ujson, ujson,
"aiofiles>=0.3.0", "aiofiles>=0.3.0",
"websockets>=7.0,<8.0", "websockets>=7.0,<9.0",
"multidict>=4.0,<5.0", "multidict>=4.0,<5.0",
"requests-async==0.5.0", "requests-async==0.5.0",
] ]