Skip to main content

HttpResponse

Protocol for HTTP response objects returned by HTTP clients.

Any object that has the required attributes and methods can be used as an HTTP response (e.g., impit.Response). This enables custom HTTP client implementations to return their own response types.

Index

Methods

aclose

  • async aclose(): None
  • Close the response and release the connection asynchronously.


    Returns None

aiter_bytes

  • aiter_bytes(): AsyncIterator[bytes]
  • Iterate over the response body in bytes chunks asynchronously.


    Returns AsyncIterator[bytes]

aread

  • async aread(): bytes
  • Read the entire response body asynchronously.


    Returns bytes

close

  • close(): None
  • Close the response and release the connection.


    Returns None

iter_bytes

  • iter_bytes(): Iterator[bytes]
  • Iterate over the response body in bytes chunks.


    Returns Iterator[bytes]

json

  • json(): Any
  • Parse response body as JSON.


    Returns Any

read

  • read(): bytes
  • Read the entire response body.


    Returns bytes

Properties

content

content: bytes

Raw response body as bytes.

headers

headers: Mapping[str, str]

Response headers as a mapping.

status_code

status_code: int

HTTP status code of the response.

text

text: str

Response body decoded as text.