]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Fix WebSocketProtocol8 on python3
authorBen Darnell <ben@bendarnell.com>
Sun, 17 Jul 2011 22:13:04 +0000 (15:13 -0700)
committerBen Darnell <ben@bendarnell.com>
Sun, 17 Jul 2011 22:13:04 +0000 (15:13 -0700)
tornado/websocket.py

index 6b32b977451198d6b97a307c2a849db87c06fc3f..00ae0d805563d56ca8d30f539d741effe8f56f87 100644 (file)
@@ -365,9 +365,10 @@ class WebSocketProtocol8(WebSocketProtocol):
 
     def _challenge_response(self):
         sha1 = hashlib.sha1()
-        sha1.update(self.request.headers.get("Sec-Websocket-Key"))
-        sha1.update("258EAFA5-E914-47DA-95CA-C5AB0DC85B11") # Magic value
-        return base64.b64encode(sha1.digest())
+        sha1.update(tornado.escape.utf8(
+                self.request.headers.get("Sec-Websocket-Key")))
+        sha1.update(b("258EAFA5-E914-47DA-95CA-C5AB0DC85B11")) # Magic value
+        return tornado.escape.native_str(base64.b64encode(sha1.digest()))
 
     def _accept_connection(self):
         self.stream.write(tornado.escape.utf8(