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

Method serialize

src/websockets/http11.py:289–299  ·  view source on GitHub ↗

Serialize a WebSocket handshake response.

(self)

Source from the content-addressed store, hash-verified

287 return cls(status_code, reason, headers, body)
288
289 def serialize(self) -> bytes:
290 """
291 Serialize a WebSocket handshake response.
292
293 """
294 # Since the status line and headers only contain ASCII characters,
295 # we can keep this simple.
296 response = f"HTTP/1.1 {self.status_code} {self.reason_phrase}\r\n".encode()
297 response += self.headers.serialize()
298 response += self.body
299 return response
300
301
302def parse_line(

Callers 3

test_serializeMethod · 0.95

Calls 2

encodeMethod · 0.45
serializeMethod · 0.45

Tested by 3

test_serializeMethod · 0.76