Exemplo n.º 1
0
    def __init__(self, client_conn, server_conn, handshake_flow, live=None):
        super().__init__("websocket", client_conn, server_conn, live)
        self.messages = []  # type: List[WebSocketMessage]
        self.close_sender = 'client'
        self.close_code = '(status code missing)'
        self.close_message = '(message missing)'
        self.close_reason = 'unknown status code'
        self.stream = False

        if handshake_flow:
            self.client_key = websockets.get_client_key(handshake_flow.request.headers)
            self.client_protocol = websockets.get_protocol(handshake_flow.request.headers)
            self.client_extensions = websockets.get_extensions(handshake_flow.request.headers)
            self.server_accept = websockets.get_server_accept(handshake_flow.response.headers)
            self.server_protocol = websockets.get_protocol(handshake_flow.response.headers)
            self.server_extensions = websockets.get_extensions(handshake_flow.response.headers)
        else:
            self.client_key = ''
            self.client_protocol = ''
            self.client_extensions = ''
            self.server_accept = ''
            self.server_protocol = ''
            self.server_extensions = ''

        self.handshake_flow = handshake_flow
Exemplo n.º 2
0
    def __init__(self, client_conn, server_conn, handshake_flow, live=None):
        super().__init__("websocket", client_conn, server_conn, live)

        self.messages: List[WebSocketMessage] = []
        """A list containing all WebSocketMessage's."""
        self.close_sender = 'client'
        """'client' if the client initiated connection closing."""
        self.close_code = CloseReason.NORMAL_CLOSURE
        """WebSocket close code."""
        self.close_message = '(message missing)'
        """WebSocket close message."""
        self.close_reason = 'unknown status code'
        """WebSocket close reason."""
        self.stream = False
        """True of this connection is streaming directly to the other endpoint."""
        self.handshake_flow = handshake_flow
        """The HTTP flow containing the initial WebSocket handshake."""

        if handshake_flow:
            self.client_key = websockets.get_client_key(handshake_flow.request.headers)
            self.client_protocol = websockets.get_protocol(handshake_flow.request.headers)
            self.client_extensions = websockets.get_extensions(handshake_flow.request.headers)
            self.server_accept = websockets.get_server_accept(handshake_flow.response.headers)
            self.server_protocol = websockets.get_protocol(handshake_flow.response.headers)
            self.server_extensions = websockets.get_extensions(handshake_flow.response.headers)
        else:
            self.client_key = ''
            self.client_protocol = ''
            self.client_extensions = ''
            self.server_accept = ''
            self.server_protocol = ''
            self.server_extensions = ''
Exemplo n.º 3
0
    def __init__(self, client_conn, server_conn, handshake_flow, live=None):
        super().__init__("websocket", client_conn, server_conn, live)
        self.messages = []  # type: List[WebSocketMessage]
        self.close_sender = 'client'
        self.close_code = '(status code missing)'
        self.close_message = '(message missing)'
        self.close_reason = 'unknown status code'

        if handshake_flow:
            self.client_key = websockets.get_client_key(
                handshake_flow.request.headers)
            self.client_protocol = websockets.get_protocol(
                handshake_flow.request.headers)
            self.client_extensions = websockets.get_extensions(
                handshake_flow.request.headers)
            self.server_accept = websockets.get_server_accept(
                handshake_flow.response.headers)
            self.server_protocol = websockets.get_protocol(
                handshake_flow.response.headers)
            self.server_extensions = websockets.get_extensions(
                handshake_flow.response.headers)
        else:
            self.client_key = ''
            self.client_protocol = ''
            self.client_extensions = ''
            self.server_accept = ''
            self.server_protocol = ''
            self.server_extensions = ''

        self.handshake_flow = handshake_flow
Exemplo n.º 4
0
    def __init__(self, ctx, flow):
        super().__init__(ctx)
        self._flow = flow

        self.client_key = websockets.get_client_key(self._flow.request.headers)
        self.client_protocol = websockets.get_protocol(self._flow.request.headers)
        self.client_extensions = websockets.get_extensions(self._flow.request.headers)

        self.server_accept = websockets.get_server_accept(self._flow.response.headers)
        self.server_protocol = websockets.get_protocol(self._flow.response.headers)
        self.server_extensions = websockets.get_extensions(self._flow.response.headers)
Exemplo n.º 5
0
    def __init__(self, ctx, flow):
        super().__init__(ctx)
        self._flow = flow

        self.client_key = websockets.get_client_key(self._flow.request.headers)
        self.client_protocol = websockets.get_protocol(
            self._flow.request.headers)
        self.client_extensions = websockets.get_extensions(
            self._flow.request.headers)

        self.server_accept = websockets.get_server_accept(
            self._flow.response.headers)
        self.server_protocol = websockets.get_protocol(
            self._flow.response.headers)
        self.server_extensions = websockets.get_extensions(
            self._flow.response.headers)
Exemplo n.º 6
0
    def __init__(self, client_conn, server_conn, handshake_flow, live=None):
        super().__init__("websocket", client_conn, server_conn, live)

        self.messages: List[WebSocketMessage] = []
        """A list containing all WebSocketMessage's."""
        self.close_sender = 'client'
        """'client' if the client initiated connection closing."""
        self.close_code = CloseReason.NORMAL_CLOSURE
        """WebSocket close code."""
        self.close_message = '(message missing)'
        """WebSocket close message."""
        self.close_reason = 'unknown status code'
        """WebSocket close reason."""
        self.stream = False
        """True of this connection is streaming directly to the other endpoint."""
        self.handshake_flow = handshake_flow
        """The HTTP flow containing the initial WebSocket handshake."""
        self.ended = False
        """True when the WebSocket connection has been closed."""

        self._inject_messages_client = queue.Queue(maxsize=1)
        self._inject_messages_server = queue.Queue(maxsize=1)

        if handshake_flow:
            self.client_key = websockets.get_client_key(
                handshake_flow.request.headers)
            self.client_protocol = websockets.get_protocol(
                handshake_flow.request.headers)
            self.client_extensions = websockets.get_extensions(
                handshake_flow.request.headers)
            self.server_accept = websockets.get_server_accept(
                handshake_flow.response.headers)
            self.server_protocol = websockets.get_protocol(
                handshake_flow.response.headers)
            self.server_extensions = websockets.get_extensions(
                handshake_flow.response.headers)
        else:
            self.client_key = ''
            self.client_protocol = ''
            self.client_extensions = ''
            self.server_accept = ''
            self.server_protocol = ''
            self.server_extensions = ''
Exemplo n.º 7
0
 def test_get_extensions(self, input, expected):
     h = http.Headers(input)
     assert websockets.get_extensions(h) == expected
Exemplo n.º 8
0
 def test_get_extensions(self, input, expected):
     h = http.Headers(input)
     assert websockets.get_extensions(h) == expected
Exemplo n.º 9
0
 def server_extensions(self):
     return websockets.get_extensions(self.handshake_flow.response.headers)
Exemplo n.º 10
0
 def client_extensions(self):
     return websockets.get_extensions(self.handshake_flow.request.headers)
Exemplo n.º 11
0
 def server_extensions(self):
     return websockets.get_extensions(self.handshake_flow.response.headers)
Exemplo n.º 12
0
 def client_extensions(self):
     return websockets.get_extensions(self.handshake_flow.request.headers)