]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Sigh... More websocket protocol changes.
authorBen Darnell <ben@bendarnell.com>
Sun, 23 Oct 2011 20:39:19 +0000 (13:39 -0700)
committerBen Darnell <ben@bendarnell.com>
Sun, 23 Oct 2011 20:39:19 +0000 (13:39 -0700)
Closes #385.

tornado/websocket.py

index 3a17f93e1058efc1de6a0cf02f80a2d9c3ec50cf..ecc80ac436d863faa3db7336c1d70abae0547a2e 100644 (file)
@@ -5,10 +5,11 @@ communication between the browser and server.
 
 .. warning::
 
-   The WebSocket protocol is still in development.  This module currently
-   implements the "hixie-76" and "hybi-10" versions of the protocol.  
-   See this `browser compatibility table 
-   <http://en.wikipedia.org/wiki/WebSockets#Browser_support>`_ on Wikipedia.
+   The WebSocket protocol is still in development.  This module
+   currently implements the "hixie-76", "hybi-10", and "hybi-17"
+   versions of the protocol.  See this `browser compatibility table
+   <http://en.wikipedia.org/wiki/WebSockets#Browser_support>`_ on
+   Wikipedia.
 """
 # Author: Jacob Kristhammar, 2010
 
@@ -31,10 +32,12 @@ class WebSocketHandler(tornado.web.RequestHandler):
 
     See http://dev.w3.org/html5/websockets/ for details on the
     JavaScript interface. This implement the protocol as specified at
+    http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-17
+    The older protocol versions specified at
     http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-10
-    The older protocol version specified at
+    and 
     http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-76.
-    is also supported.
+    are also supported.
 
     Here is an example Web Socket handler that echos back all received messages
     back to the client::
@@ -79,8 +82,10 @@ class WebSocketHandler(tornado.web.RequestHandler):
         self.open_args = args
         self.open_kwargs = kwargs
 
-        if (self.request.headers.get("Sec-WebSocket-Version") == "8" or
-            self.request.headers.get("Sec-WebSocket-Version") == "7"):
+        # The difference between version 8 and 13 is that in 8 the
+        # client sends a "Sec-Websocket-Origin" header and in 13 it's
+        # simply "Origin".
+        if self.request.headers.get("Sec-WebSocket-Version") in ("7", "8", "13"):
             self.ws_connection = WebSocketProtocol8(self)
             self.ws_connection.accept_connection()