correspond.channels._http
A small HTTP client over urllib, shared by the HTTP adapters, with failures classified.
Adapters take it as http=. The call shape is
http(method, url, *, headers=None, body=None, timeout=DEFAULT_TIMEOUT_S) -> Response:
an HTTP error status comes back as a Response like any other, and only “could not reach
the server” raises, as a ChannelError of kind network that names the host and never
the URL (a URL path can carry a token). Tests pass a scripted function of the same shape.
>>> classify(429, "slow down", {"retry-after": "3"}).retry_after
3.0
>>> classify(404, "gone").kind
'not_found'
- class correspond.channels._http.Response(status: int, headers: Mapping[str, str]=<factory>, body: bytes = b'')[source]
An HTTP response: status, lower-cased headers, raw body.
- correspond.channels._http.classify(status: int, message: str, headers: Mapping[str, str] | None = None) ChannelError[source]
The
ChannelErroran HTTP error status means.