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 )
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 )
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()