WebSocket handshake response. Attributes: status_code: Response code. reason_phrase: Response reason. headers: Response headers. body: Response body.
| 180 | |
| 181 | @dataclasses.dataclass |
| 182 | class Response: |
| 183 | """ |
| 184 | WebSocket handshake response. |
| 185 | |
| 186 | Attributes: |
| 187 | status_code: Response code. |
| 188 | reason_phrase: Response reason. |
| 189 | headers: Response headers. |
| 190 | body: Response body. |
| 191 | |
| 192 | """ |
| 193 | |
| 194 | status_code: int |
| 195 | reason_phrase: str |
| 196 | headers: Headers |
| 197 | body: bytes | bytearray = b"" |
| 198 | |
| 199 | _exception: Exception | None = None |
| 200 | |
| 201 | @property |
| 202 | def exception(self) -> Exception | None: # pragma: no cover |
| 203 | warnings.warn( # deprecated in 10.3 - 2022-04-17 |
| 204 | "Response.exception is deprecated; " |
| 205 | "use ClientProtocol.handshake_exc instead", |
| 206 | DeprecationWarning, |
| 207 | ) |
| 208 | return self._exception |
| 209 | |
| 210 | @classmethod |
| 211 | def parse( |
| 212 | cls, |
| 213 | read_line: Callable[[int], Generator[None, None, bytes | bytearray]], |
| 214 | read_exact: Callable[[int], Generator[None, None, bytes | bytearray]], |
| 215 | read_to_eof: Callable[[int], Generator[None, None, bytes | bytearray]], |
| 216 | proxy: bool = False, |
| 217 | ) -> Generator[None, None, Response]: |
| 218 | """ |
| 219 | Parse a WebSocket handshake response. |
| 220 | |
| 221 | This is a generator-based coroutine. |
| 222 | |
| 223 | The reason phrase and headers are expected to contain only ASCII |
| 224 | characters. Other characters are represented with surrogate escapes. |
| 225 | |
| 226 | Args: |
| 227 | read_line: Generator-based coroutine that reads a LF-terminated |
| 228 | line or raises an exception if there isn't enough data. |
| 229 | read_exact: Generator-based coroutine that reads the requested |
| 230 | bytes or raises an exception if there isn't enough data. |
| 231 | read_to_eof: Generator-based coroutine that reads until the end |
| 232 | of the stream. |
| 233 | |
| 234 | Raises: |
| 235 | EOFError: If the connection is closed without a full HTTP response. |
| 236 | SecurityError: If the response exceeds a security limit. |
| 237 | LookupError: If the response isn't well formatted. |
| 238 | ValueError: If the response isn't well formatted. |
| 239 |
no outgoing calls
searching dependent graphs…