fixed #158
This commit is contained in:
@@ -4,6 +4,7 @@ ChangeLog
|
||||
- 0.27.0
|
||||
|
||||
- remove unittest2 requirements for python 2.6 (#156)
|
||||
- fixed subprotocol case during header validation (#158)
|
||||
- refactoring.
|
||||
|
||||
- 0.26.0
|
||||
|
@@ -117,8 +117,8 @@ def _validate(headers, key, subprotocols):
|
||||
return False, None
|
||||
|
||||
if subprotocols:
|
||||
subproto = headers.get("sec-websocket-protocol", None)
|
||||
if not subproto or subproto not in subprotocols:
|
||||
subproto = headers.get("sec-websocket-protocol", None).lower()
|
||||
if not subproto or subproto not in [s.lower() for s in subprotocols]:
|
||||
error("Invalid subprotocol: " + str(subprotocols))
|
||||
return False, None
|
||||
|
||||
|
@@ -213,6 +213,11 @@ class WebSocketTest(unittest.TestCase):
|
||||
self.assertEqual(_validate_header(header, key, ["sub1", "sub2"]), (True, "sub1"))
|
||||
self.assertEqual(_validate_header(header, key, ["sub2", "sub3"]), (False, None))
|
||||
|
||||
header = required_header.copy()
|
||||
header["sec-websocket-protocol"] = "sUb1"
|
||||
self.assertEqual(_validate_header(header, key, ["Sub1", "suB2"]), (True, "sub1"))
|
||||
|
||||
|
||||
def testReadHeader(self):
|
||||
status, header = read_headers(HeaderSockMock("data/header01.txt"))
|
||||
self.assertEqual(status, 101)
|
||||
|
Reference in New Issue
Block a user