Jeffrey Gelens avatar Jeffrey Gelens committed cba817e

Version handshaking

Comments (0)

Files changed (1)

geventwebsocket/handler.py

 from geventwebsocket import WebSocketVersion7, WebSocketLegacy
 
 
-PROTOCOL_VERSIONS = (
-    "hixie-75",
-    "0",
-    "6",
-)
 
 class HandShakeError(ValueError):
     """ Hand shake challenge can't be parsed """
     """ Automatically upgrades the connection to websockets. """
 
     GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
+    SUPPORTED_VERSIONS = (7,)
 
     def __init__(self, *args, **kwargs):
         self.websocket_connection = False
                 self._handshake_hybi00()
             else:
                 self._handshake_hixie75()
+
+            return True
         else:
             print "NEW ", version
             self.websocket = WebSocketVersion7(self.socket, self.rfile, self.environ)
 
-            if version and int(version) in PROTOCOL_VERSIONS:
+            if int(version) in self.SUPPORTED_VERSIONS:
+                return True
+            else:
                 pass
+                # TODO: not support by websockets yet
+                #headers = [
+                #    ("Sec-WebSocket-Version", self.SUPPORTED_VERSION),
+                #]
+                #self.start_response("400 Bad Request", headers)
+                #self._close_connection()
 
 
     def _handshake_hixie75(self):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.