From: Ben Darnell Date: Sun, 17 Jul 2011 22:13:04 +0000 (-0700) Subject: Fix WebSocketProtocol8 on python3 X-Git-Tag: v2.1.0~78^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ef42bd8a5a64ebbb7bcf1cd6ddf4e24c64074512;p=thirdparty%2Ftornado.git Fix WebSocketProtocol8 on python3 --- diff --git a/tornado/websocket.py b/tornado/websocket.py index 6b32b9774..00ae0d805 100644 --- a/tornado/websocket.py +++ b/tornado/websocket.py @@ -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(