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

Method test_serialize

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

Source from the content-addressed store, hash-verified

351 )
352
353 def test_serialize(self):
354 # Example from the protocol overview in RFC 6455
355 response = Response(
356 101,
357 "Switching Protocols",
358 Headers(
359 [
360 ("Upgrade", "websocket"),
361 ("Connection", "Upgrade"),
362 ("Sec-WebSocket-Accept", "s3pPLMBiTxaQ9kYGzzhZRbK+xOo="),
363 ("Sec-WebSocket-Protocol", "chat"),
364 ]
365 ),
366 )
367 self.assertEqual(
368 response.serialize(),
369 b"HTTP/1.1 101 Switching Protocols\r\n"
370 b"Upgrade: websocket\r\n"
371 b"Connection: Upgrade\r\n"
372 b"Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=\r\n"
373 b"Sec-WebSocket-Protocol: chat\r\n"
374 b"\r\n",
375 )
376
377 def test_serialize_with_body(self):
378 response = Response(

Callers

nothing calls this directly

Calls 3

serializeMethod · 0.95
HeadersClass · 0.90
ResponseClass · 0.85

Tested by

no test coverage detected