Skip to content

common_http.interfaces

Runtime integration interfaces; implementations belong to their own packages.

Classes

HttpAuth

Bases: Protocol

An independently owned authenticator supplying one flow per operation.

HTTP prepares the initial request, including encoded body bytes, before starting a flow. Yield a Request to send; receive its HttpResponseHead via asend. Stop to deliver that response, or yield an authorized follow-up. Body-dependent signatures must retain the prepared binary body (or supply their own final binary body). HTTP never invents refresh/401 decisions.

requires_body selects responses that must be consumed before asend; those arrive as HttpResponse (a head subclass) with content bytes, decoded_as=bytes. This buffering obeys the client’s byte cap, also when using stream(). Other responses remain streamed until the flow accepts or replaces them.

A flow owns its authentication step budget and must terminate. Buffered operations also obey the configured execution-attempt timeout. Concurrent flows have independent local state; shared credential refresh coordination belongs to the authenticator. HTTP closes flows, never the authenticator. Token/refresh calls should use a separate unauthenticated HTTP client.

flow

def flow(request: Request) -> AsyncGenerator[Request, HttpResponseHead]

requires_body

def requires_body(response: HttpResponseHead) -> bool