MCPcopy Create free account
hub / github.com/python-websockets/websockets / test_serialize

Method test_serialize

tests/test_http11.py:103–130  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

101 )
102
103 def test_serialize(self):
104 # Example from the protocol overview in RFC 6455
105 request = Request(
106 "/chat",
107 Headers(
108 [
109 ("Host", "server.example.com"),
110 ("Upgrade", "websocket"),
111 ("Connection", "Upgrade"),
112 ("Sec-WebSocket-Key", "dGhlIHNhbXBsZSBub25jZQ=="),
113 ("Origin", "http://example.com"),
114 ("Sec-WebSocket-Protocol", "chat, superchat"),
115 ("Sec-WebSocket-Version", "13"),
116 ]
117 ),
118 )
119 self.assertEqual(
120 request.serialize(),
121 b"GET /chat HTTP/1.1\r\n"
122 b"Host: server.example.com\r\n"
123 b"Upgrade: websocket\r\n"
124 b"Connection: Upgrade\r\n"
125 b"Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n"
126 b"Origin: http://example.com\r\n"
127 b"Sec-WebSocket-Protocol: chat, superchat\r\n"
128 b"Sec-WebSocket-Version: 13\r\n"
129 b"\r\n",
130 )
131
132
133class ResponseTests(GeneratorTestCase):

Callers

nothing calls this directly

Calls 3

serializeMethod · 0.95
HeadersClass · 0.90
RequestClass · 0.85

Tested by

no test coverage detected