Parse the payload from a close frame. Returns: Close code and reason. Raises: ProtocolError: If data is ill-formed. UnicodeDecodeError: If the reason isn't valid UTF-8.
(data: bytes)
| 201 | |
| 202 | |
| 203 | def parse_close(data: bytes) -> tuple[int, str]: |
| 204 | """ |
| 205 | Parse the payload from a close frame. |
| 206 | |
| 207 | Returns: |
| 208 | Close code and reason. |
| 209 | |
| 210 | Raises: |
| 211 | ProtocolError: If data is ill-formed. |
| 212 | UnicodeDecodeError: If the reason isn't valid UTF-8. |
| 213 | |
| 214 | """ |
| 215 | close = Close.parse(data) |
| 216 | return close.code, close.reason |
| 217 | |
| 218 | |
| 219 | def serialize_close(code: int, reason: str) -> bytes: |
searching dependent graphs…