Add possibility to reject a WebSocket request before the connection is established
I am using special crafted URL for the handover to a WebSocket connection. Now I want to check the given URL before the WebSocket connection is established. Right now there seams to be no way to reject a WebSocket connection before the connection is actually established.
I would propose that the library user needs to explicitly "open" or "accept" the connection.
def application(environ, start_response): ws = environ['wsgi.websocket'] if check_path(environ['PATH_INFO']): ws.open() websocket_main(ws) ws.close() else: start_response('404 Not Found', ) return