aiohttp_client_cache.response module

class aiohttp_client_cache.response.CachedResponse(method, reason, status, url, version, body=None, content_disposition=None, cookies=None, created_at=NOTHING, encoding=None, expires=None, headers=NOTHING, history=NOTHING, request_info=None)[source]

Bases: object

A dataclass containing cached response information, used for serialization. It will mostly behave the same as a aiohttp.ClientResponse that has been read, with some additional cache-related info.

_body: Any
content_disposition: aiohttp.client_reqrep.ContentDisposition
cookies: http.cookies.SimpleCookie
created_at: datetime.datetime
encoding: str
expires: datetime.datetime
async classmethod from_client_response(client_response, expire_after=None)[source]

Convert a ClientResponse into a CachedReponse

Parameters
  • client_response (aiohttp.client_reqrep.ClientResponse) –

  • expire_after (datetime.timedelta) –

get_encoding()[source]
headers: Mapping
history: Iterable
property is_expired

Determine if this cached response is expired

Return type

bool

async json(encoding=None, **kwargs)[source]

Read and decode JSON response

Return type

Optional[Dict[str, Any]]

Parameters

encoding (Optional[str]) –

method: str
property ok

Returns True if status is less than 400, False if not

Return type

bool

raise_for_status()[source]
Return type

None

read()[source]

No-op function for compatibility with ClientResponse

reason: str
release()[source]

No-op function for compatibility with ClientResponse

request_info: aiohttp_client_cache.response.RequestInfo
status: int
async text(encoding=None, errors='strict')[source]

Read response payload and decode

Return type

str

Parameters
  • encoding (Optional[str]) –

  • errors (str) –

url: Union[str, yarl.URL]
version: str
class aiohttp_client_cache.response.RequestInfo(url, method, headers, real_url)[source]

Bases: object

A picklable version of aiohttp.client_reqrep.RequestInfo

classmethod from_object(request_info)[source]
headers: dict
method: str
real_url: str
url: str