Serialize a WebSocket handshake response.
(self)
| 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 | |
| 302 | def parse_line( |