Anonymous avatar Anonymous committed aab8e55

Added a way to prevent the call to 'wsgi'


mywebsockethandler.prevent_wsgi_call = True

This is what is done in the latest gevent-socketio library.

Comments (0)

Files changed (1)


 class WebSocketHandler(WSGIHandler):
-    """ Automatically upgrades the connection to websockets. """
+    """Automatically upgrades the connection to websockets.
+    To prevent the WebSocketHandler to call the underlying WSGI application,
+    but only setup the WebSocket negotiations, do:
+      mywebsockethandler.prevent_wsgi_call = True
+    before calling handle_one_response().  This is useful if you want to do
+    more things before calling the app, and want to off-load the WebSocket
+    negotiations to this library.  Socket.IO needs this for example, to
+    send the 'ack' before yielding the control to your WSGI app.
+    """
     GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
     SUPPORTED_VERSIONS = ('13', '8', '7')
             if not result:
-            self.application(environ, self._fake_start_response)
+            if not hasattr(self, 'prevent_wsgi_call'):
+                self.application(environ, self._fake_start_response)
             return []
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
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.