Skip to content

Commit a47e320

Browse files
committed
HTTP Upgrade and Connection must contain the WebSockets token but may also have other tokens
1 parent 584b78a commit a47e320

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

ws4py/server/cherrypyserver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def upgrade(self, protocols=None, extensions=None, version=8, handler_cls=WebSoc
127127
actual_value = request.headers.get(key)
128128
if not actual_value:
129129
raise HandshakeError('Header %s is not defined' % key)
130-
if expected_value and actual_value != expected_value:
130+
if expected_value and expected_value not in actual_value:
131131
raise HandshakeError('Illegal value for header %s: %s' %
132132
(key, actual_value))
133133

ws4py/server/wsgi/middleware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def __init__(self, handle, fallback_app=None, protocols=None, extensions=None,
204204
def __call__(self, environ, start_response):
205205
# Initial handshake validation
206206
try:
207-
if environ.get('upgrade.protocol') != 'websocket':
207+
if 'websocket' not in environ.get('upgrade.protocol'):
208208
raise HandshakeError("Upgrade protocol is not websocket")
209209

210210
if environ.get('REQUEST_METHOD') != 'GET':

0 commit comments

Comments
 (0)