Exemplo n.º 1
0
    def test_goaway_serializes_properly(self):
        f = GoAwayFrame(0)
        f.last_stream_id = 64
        f.error_code = 32
        f.additional_data = b'hello'

        s = f.serialize()
        assert s == (
            b'\x00\x0D\x07\x00\x00\x00\x00\x00' +  # Frame header
            b'\x00\x00\x00\x40'                 +  # Last Stream ID
            b'\x00\x00\x00\x20'                 +  # Error Code
            b'hello'                               # Additional data
        )
Exemplo n.º 2
0
    def test_goaway_serializes_properly(self):
        f = GoAwayFrame(0)
        f.last_stream_id = 64
        f.error_code = 32
        f.additional_data = b"hello"

        s = f.serialize()
        assert s == (
            b"\x00\x0D\x07\x00\x00\x00\x00\x00"
            + b"\x00\x00\x00\x40"  # Frame header
            + b"\x00\x00\x00\x20"  # Last Stream ID
            + b"hello"  # Error Code  # Additional data
        )
Exemplo n.º 3
0
        def socket_handler(listener):
            sock = listener.accept()[0]

            # We should get two packets: one connection header string, one
            # SettingsFrame. Rather than respond to the packets, send a GOAWAY
            # frame with error code 0 indicating clean shutdown.
            first = sock.recv(65535)
            second = sock.recv(65535)

            # Now, send the shut down.
            f = GoAwayFrame(0)
            f.error_code = 1
            sock.send(f.serialize())

            # Wait for the message from the main thread.
            sock.close()
            recv_event.wait()
Exemplo n.º 4
0
    def test_goaway_serializes_properly(self):
        f = GoAwayFrame(0)
        f.last_stream_id = 64
        f.error_code = 32
        f.additional_data = b'hello'

        s = f.serialize()
        assert s == (
            b'\x00\x0D\x07\x00\x00\x00\x00\x00' +  # Frame header
            b'\x00\x00\x00\x40' +  # Last Stream ID
            b'\x00\x00\x00\x20' +  # Error Code
            b'hello'  # Additional data
        )
Exemplo n.º 5
0
    def test_go_away_has_no_flags(self):
        f = GoAwayFrame(0)
        flags = f.parse_flags(0xFF)

        assert not flags
        assert isinstance(flags, set)
Exemplo n.º 6
0
    def test_go_away_has_no_flags(self):
        f = GoAwayFrame(0)
        flags = f.parse_flags(0xFF)

        assert not flags
        assert isinstance(flags, set)
Exemplo n.º 7
0
 def test_goaway_frame_never_has_a_stream(self):
     with pytest.raises(ValueError):
         GoAwayFrame(1)