class documentation

class Response: (source)

View In Hierarchy

Undocumented

Method __getstate__ Undocumented
Method __init__ Undocumented
Method __repr__ Undocumented
Method __setstate__ Undocumented
Async Method aclose Close the response and release the connection. Automatically called if the response body is read to completion.
Async Method aiter_bytes A byte-iterator over the decoded response content. This allows us to handle gzip, deflate, and brotli encoded responses.
Async Method aiter_lines Undocumented
Async Method aiter_raw A byte-iterator over the raw response content.
Async Method aiter_text A str-iterator over the decoded response content that handles both gzip, deflate, etc but also detects the content's string encoding.
Async Method aread Read and return the response content.
Method close Close the response and release the connection. Automatically called if the response body is read to completion.
Method elapsed.setter Undocumented
Method encoding.setter Undocumented
Method iter_bytes A byte-iterator over the decoded response content. This allows us to handle gzip, deflate, and brotli encoded responses.
Method iter_lines Undocumented
Method iter_raw A byte-iterator over the raw response content.
Method iter_text A str-iterator over the decoded response content that handles both gzip, deflate, etc but also detects the content's string encoding.
Method json Undocumented
Method raise_for_status Raise the `HTTPStatusError` if one occurred.
Method read Read and return the response content.
Method request.setter Undocumented
Instance Variable default_encoding Undocumented
Instance Variable extensions Undocumented
Instance Variable headers Undocumented
Instance Variable history Undocumented
Instance Variable is_closed Undocumented
Instance Variable is_stream_consumed Undocumented
Instance Variable next_request Undocumented
Instance Variable status_code Undocumented
Instance Variable stream Undocumented
Property charset_encoding Return the encoding, as specified by the Content-Type header.
Property content Undocumented
Property cookies Undocumented
Property elapsed Returns the time taken for the complete request/response cycle to complete.
Property encoding Return an encoding to use for decoding the byte content into text. The priority for determining this is given by...
Property has_redirect_location Returns True for 3xx responses with a properly formed URL redirection, `False` otherwise.
Property http_version Undocumented
Property is_client_error A property which is `True` for 4xx status codes, `False` otherwise.
Property is_error A property which is `True` for 4xx and 5xx status codes, `False` otherwise.
Property is_informational A property which is `True` for 1xx status codes, `False` otherwise.
Property is_redirect A property which is `True` for 3xx status codes, `False` otherwise.
Property is_server_error A property which is `True` for 5xx status codes, `False` otherwise.
Property is_success A property which is `True` for 2xx status codes, `False` otherwise.
Property links Returns the parsed header links of the response, if any
Property num_bytes_downloaded Undocumented
Property reason_phrase Undocumented
Property request Returns the request instance associated to the current response.
Property text Undocumented
Property url Returns the URL for which the request was made.
Method _get_content_decoder Returns a decoder instance which can be used to decode the raw byte content, depending on the Content-Encoding used in the response.
Method _prepare Undocumented
Instance Variable _content Undocumented
Instance Variable _decoder Undocumented
Instance Variable _elapsed Undocumented
Instance Variable _encoding Undocumented
Instance Variable _num_bytes_downloaded Undocumented
Instance Variable _request Undocumented
def __getstate__(self): (source)

Undocumented

Returns
typing.Dict[str, typing.Any]Undocumented
def __init__(self, status_code, *, headers=None, content=None, text=None, html=None, json=None, stream=None, request=None, extensions=None, history=None, default_encoding='utf-8'): (source)

Undocumented

Parameters
status_code:intUndocumented
headers:typing.Optional[HeaderTypes]Undocumented
content:typing.Optional[ResponseContent]Undocumented
text:typing.Optional[str]Undocumented
html:typing.Optional[str]Undocumented
json:typing.AnyUndocumented
stream:typing.Union[SyncByteStream, AsyncByteStream, None]Undocumented
request:typing.Optional[Request]Undocumented
extensions:typing.Optional[ResponseExtensions]Undocumented
history:typing.Optional[typing.List[Response]]Undocumented
default_encoding:typing.Union[str, typing.Callable[[bytes], str]]Undocumented
def __repr__(self): (source)

Undocumented

Returns
strUndocumented
def __setstate__(self, state): (source)

Undocumented

Parameters
state:typing.Dict[str, typing.Any]Undocumented
async def aclose(self): (source)

Close the response and release the connection. Automatically called if the response body is read to completion.

async def aiter_bytes(self, chunk_size=None): (source)

A byte-iterator over the decoded response content. This allows us to handle gzip, deflate, and brotli encoded responses.

Parameters
chunk_size:typing.Optional[int]Undocumented
Returns
typing.AsyncIterator[bytes]Undocumented
async def aiter_lines(self): (source)

Undocumented

Returns
typing.AsyncIterator[str]Undocumented
async def aiter_raw(self, chunk_size=None): (source)

A byte-iterator over the raw response content.

Parameters
chunk_size:typing.Optional[int]Undocumented
Returns
typing.AsyncIterator[bytes]Undocumented
async def aiter_text(self, chunk_size=None): (source)

A str-iterator over the decoded response content that handles both gzip, deflate, etc but also detects the content's string encoding.

Parameters
chunk_size:typing.Optional[int]Undocumented
Returns
typing.AsyncIterator[str]Undocumented
async def aread(self): (source)

Read and return the response content.

Returns
bytesUndocumented
def close(self): (source)

Close the response and release the connection. Automatically called if the response body is read to completion.

@elapsed.setter
def elapsed(self, elapsed): (source)

Undocumented

Parameters
elapsed:datetime.timedeltaUndocumented
@encoding.setter
def encoding(self, value): (source)

Undocumented

Parameters
value:strUndocumented
def iter_bytes(self, chunk_size=None): (source)

A byte-iterator over the decoded response content. This allows us to handle gzip, deflate, and brotli encoded responses.

Parameters
chunk_size:typing.Optional[int]Undocumented
Returns
typing.Iterator[bytes]Undocumented
def iter_lines(self): (source)

Undocumented

Returns
typing.Iterator[str]Undocumented
def iter_raw(self, chunk_size=None): (source)

A byte-iterator over the raw response content.

Parameters
chunk_size:typing.Optional[int]Undocumented
Returns
typing.Iterator[bytes]Undocumented
def iter_text(self, chunk_size=None): (source)

A str-iterator over the decoded response content that handles both gzip, deflate, etc but also detects the content's string encoding.

Parameters
chunk_size:typing.Optional[int]Undocumented
Returns
typing.Iterator[str]Undocumented
def json(self, **kwargs): (source)

Undocumented

Parameters
**kwargs:typing.AnyUndocumented
Returns
typing.AnyUndocumented
def raise_for_status(self): (source)

Raise the `HTTPStatusError` if one occurred.

def read(self): (source)

Read and return the response content.

Returns
bytesUndocumented
@request.setter
def request(self, value): (source)

Undocumented

Parameters
value:RequestUndocumented
default_encoding = (source)

Undocumented

extensions: dict = (source)

Undocumented

Undocumented

Undocumented

is_closed: bool = (source)

Undocumented

is_stream_consumed: bool = (source)

Undocumented

Undocumented

status_code = (source)

Undocumented

Undocumented

Return the encoding, as specified by the Content-Type header.

Undocumented

Undocumented

Returns the time taken for the complete request/response cycle to complete.

Return an encoding to use for decoding the byte content into text. The priority for determining this is given by... * `.encoding = <>` has been set explicitly. * The encoding as specified by the charset parameter in the Content-Type header. * The encoding as determined by `default_encoding`, which may either be a string like "utf-8" indicating the encoding to use, or may be a callable which enables charset autodetection.

@property
has_redirect_location: bool = (source)

Returns True for 3xx responses with a properly formed URL redirection, `False` otherwise.

@property
http_version: str = (source)

Undocumented

@property
is_client_error: bool = (source)

A property which is `True` for 4xx status codes, `False` otherwise.

A property which is `True` for 4xx and 5xx status codes, `False` otherwise.

@property
is_informational: bool = (source)

A property which is `True` for 1xx status codes, `False` otherwise.

A property which is `True` for 3xx status codes, `False` otherwise. Note that not all responses with a 3xx status code indicate a URL redirect. Use `response.has_redirect_location` to determine responses with a properly formed URL redirection.

@property
is_server_error: bool = (source)

A property which is `True` for 5xx status codes, `False` otherwise.

A property which is `True` for 2xx status codes, `False` otherwise.

Returns the parsed header links of the response, if any

@property
num_bytes_downloaded: int = (source)

Undocumented

@property
reason_phrase: str = (source)

Undocumented

Returns the request instance associated to the current response.

Undocumented

Returns the URL for which the request was made.

def _get_content_decoder(self): (source)

Returns a decoder instance which can be used to decode the raw byte content, depending on the Content-Encoding used in the response.

Returns
ContentDecoderUndocumented
def _prepare(self, default_headers): (source)

Undocumented

Parameters
default_headers:typing.Dict[str, str]Undocumented
_content = (source)

Undocumented

_decoder = (source)

Undocumented

_elapsed = (source)

Undocumented

_encoding = (source)

Undocumented

_num_bytes_downloaded: int = (source)

Undocumented

_request = (source)

Undocumented