Upgrade websockets dependency. (#2154)
* Upgrade websockets dependency. Fix #2142. * Bumpt sanic-testing version Co-authored-by: Adam Hopkins <adam@amhopkins.com> Co-authored-by: Adam Hopkins <admhpkns@gmail.com>
This commit is contained in:
@@ -14,9 +14,13 @@ from websockets import ( # type: ignore
|
||||
ConnectionClosed,
|
||||
InvalidHandshake,
|
||||
WebSocketCommonProtocol,
|
||||
handshake,
|
||||
)
|
||||
|
||||
# Despite the "legacy" namespace, the primary maintainer of websockets
|
||||
# committed to maintaining backwards-compatibility until 2026 and will
|
||||
# consider extending it if sanic continues depending on this module.
|
||||
from websockets.legacy import handshake
|
||||
|
||||
from sanic.exceptions import InvalidUsage
|
||||
from sanic.server import HttpProtocol
|
||||
|
||||
@@ -126,7 +130,9 @@ class WebSocketProtocol(HttpProtocol):
|
||||
ping_interval=self.websocket_ping_interval,
|
||||
ping_timeout=self.websocket_ping_timeout,
|
||||
)
|
||||
# Following two lines are required for websockets 8.x
|
||||
# we use WebSocketCommonProtocol because we don't want the handshake
|
||||
# logic from WebSocketServerProtocol; however, we must tell it that
|
||||
# we're running on the server side
|
||||
self.websocket.is_client = False
|
||||
self.websocket.side = "server"
|
||||
self.websocket.subprotocol = subprotocol
|
||||
|
||||
Reference in New Issue
Block a user