This commit is contained in:
liris
2015-03-24 12:04:54 +09:00
parent cac1cf234e
commit 77faf8c6f8
3 changed files with 8 additions and 2 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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)