def on_headers(self, response, exc=None):
        '''Websocket upgrade as ``on_headers`` event.'''

        if response.status_code == 101:
            connection = response.connection
            request = response.request
            handler = request.websocket_handler
            if not handler:
                handler = WS()
            parser = request.client.frame_parser(kind=1)
            consumer = partial(WebSocketClient.create,
                               response, handler, parser)
            connection.upgrade(consumer)
            response.event('post_request').fire()
            websocket = connection.current_consumer()
            response.request_again = lambda r: websocket
def on_headers ( self , response , exc = None ) : if response . status_code == 101 : connection = response . connection request = response . request handler = request . websocket_handler if not handler : handler = WS ( ) parser = request . client . frame_parser ( kind = 1 ) consumer = partial ( WebSocketClient . create , response , handler , parser ) connection . upgrade ( consumer ) response . event ( 'post_request' ) . fire ( ) websocket = connection . current_consumer ( ) response . request_again = lambda r : websocket
Websocket upgrade as ``on_headers`` event.