Be backwards compatible with older websockify clients
They will specify a sub-protocol, and the specification requires us to choose one of the specified protocols.
This commit is contained in:
parent
c7bde00a4e
commit
df317822d6
|
@ -41,6 +41,14 @@ if sys.platform == 'win32':
|
||||||
from websockify.websocket import WebSocket, WebSocketWantReadError, WebSocketWantWriteError
|
from websockify.websocket import WebSocket, WebSocketWantReadError, WebSocketWantWriteError
|
||||||
from websockify.websocketserver import WebSocketRequestHandler
|
from websockify.websocketserver import WebSocketRequestHandler
|
||||||
|
|
||||||
|
class CompatibleWebSocket(WebSocket):
|
||||||
|
def select_subprotocol(self, protocols):
|
||||||
|
# Handle old websockify clients that still specifiy a sub-protocol
|
||||||
|
if 'binary' in protocols:
|
||||||
|
return 'binary'
|
||||||
|
else:
|
||||||
|
return ''
|
||||||
|
|
||||||
# HTTP handler with WebSocket upgrade support
|
# HTTP handler with WebSocket upgrade support
|
||||||
class WebSockifyRequestHandler(WebSocketRequestHandler, SimpleHTTPRequestHandler):
|
class WebSockifyRequestHandler(WebSocketRequestHandler, SimpleHTTPRequestHandler):
|
||||||
"""
|
"""
|
||||||
|
@ -61,6 +69,8 @@ class WebSockifyRequestHandler(WebSocketRequestHandler, SimpleHTTPRequestHandler
|
||||||
|
|
||||||
protocol_version = "HTTP/1.1"
|
protocol_version = "HTTP/1.1"
|
||||||
|
|
||||||
|
SocketClass = CompatibleWebSocket
|
||||||
|
|
||||||
# An exception while the WebSocket client was connected
|
# An exception while the WebSocket client was connected
|
||||||
class CClose(Exception):
|
class CClose(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in New Issue