Skip to content

Commit

Permalink
Sigh... More websocket protocol changes.
Browse files Browse the repository at this point in the history
Closes #385.
  • Loading branch information
bdarnell committed Oct 23, 2011
1 parent 970b43b commit 84d7b45
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions tornado/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
.. 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

Expand All @@ -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::
Expand Down Expand Up @@ -79,8 +82,10 @@ def _execute(self, transforms, *args, **kwargs):
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()

Expand Down

0 comments on commit 84d7b45

Please sign in to comment.