response¶
Summary¶
|
A dataclass containing cached response information, used for serialization. |
|
Set some default CachedResponse values on a ClientResponse object, so they can be expected to always be present |
Module Contents¶
- class CachedResponse(method, reason, status, url, version, body=b'', links=NOTHING, cookies=None, created_at=NOTHING, encoding=None, expires=None, raw_headers=NOTHING, real_url=None, history=NOTHING, last_used=NOTHING)¶
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.- Parameters
method (str) –
reason (str) –
status (int) –
url (yarl.URL) –
version (str) –
body (Any) –
cookies (http.cookies.SimpleCookie) –
created_at (datetime.datetime) –
encoding (str) –
expires (Optional[datetime.datetime]) –
real_url (Union[str, yarl.URL]) –
history (Iterable) –
last_used (datetime.datetime) –
- Return type
- _body¶
- _links¶
- property _released¶
- property content_disposition: Optional[aiohttp.client_reqrep.ContentDisposition]¶
Get Content-Disposition headers, if any
- Return type
- cookies¶
- created_at¶
- encoding¶
- expires¶
- property from_cache¶
- async classmethod from_client_response(client_response, expires=None)¶
Convert a ClientResponse into a CachedReponse
- Parameters
client_response (
aiohttp.ClientResponse
) –expires (Optional[datetime.datetime]) –
- get_encoding()¶
- property headers: multidict._multidict.CIMultiDictProxy¶
Get headers as an immutable, case-insensitive multidict from raw headers
- Return type
CIMultiDictProxy
- history¶
- async json(encoding=None, **kwargs)¶
Read and decode JSON response
- last_used¶
- property links: multidict._multidict.MultiDictProxy¶
Convert stored links into the format returned by
ClientResponse.links
- Return type
MultiDictProxy
- method¶
- raise_for_status()¶
- raw_headers¶
- real_url¶
- reason¶
- release()¶
No-op function for compatibility with ClientResponse
- property request_info: aiohttp.client_reqrep.RequestInfo¶
- Return type
- status¶
- async text(encoding=None, errors='strict')¶
Read response payload and decode
- url¶
- version¶
- set_response_defaults(response)¶
Set some default CachedResponse values on a ClientResponse object, so they can be expected to always be present
- Return type
- Parameters
response (Union[
aiohttp.ClientResponse
, aiohttp_client_cache.response.CachedResponse]) –