class documentation

class Response:

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 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 apparent​_encoding Return the encoding, as determined by charset_normalizer.
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):

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):

Undocumented

Parameters
status​_code:intUndocumented
headers:HeaderTypesUndocumented
content:ResponseContentUndocumented
text:strUndocumented
html:strUndocumented
json:typing.AnyUndocumented
stream:typing.Union[SyncByteStream, AsyncByteStream]Undocumented
request:RequestUndocumented
extensions:dictUndocumented
history:typing.List[Response]Undocumented
def __repr__(self):

Undocumented

Returns
strUndocumented
def __setstate__(self, state):

Undocumented

Parameters
state:typing.Dict[str, typing.Any]Undocumented
async def aclose(self):
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):
A byte-iterator over the decoded response content. This allows us to handle gzip, deflate, and brotli encoded responses.
Parameters
chunk​_size:intUndocumented
Returns
typing.AsyncIterator[bytes]Undocumented
async def aiter_lines(self):

Undocumented

Returns
typing.AsyncIterator[str]Undocumented
async def aiter_raw(self, chunk_size=None):
A byte-iterator over the raw response content.
Parameters
chunk​_size:intUndocumented
Returns
typing.AsyncIterator[bytes]Undocumented
async def aiter_text(self, chunk_size=None):
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:intUndocumented
Returns
typing.AsyncIterator[str]Undocumented
async def aread(self):
Read and return the response content.
Returns
bytesUndocumented
def close(self):
Close the response and release the connection. Automatically called if the response body is read to completion.
@elapsed.setter
def elapsed(self, elapsed):

Undocumented

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

Undocumented

Parameters
value:strUndocumented
def iter_bytes(self, chunk_size=None):
A byte-iterator over the decoded response content. This allows us to handle gzip, deflate, and brotli encoded responses.
Parameters
chunk​_size:intUndocumented
Returns
typing.Iterator[bytes]Undocumented
def iter_lines(self):

Undocumented

Returns
typing.Iterator[str]Undocumented
def iter_raw(self, chunk_size=None):
A byte-iterator over the raw response content.
Parameters
chunk​_size:intUndocumented
Returns
typing.Iterator[bytes]Undocumented
def iter_text(self, chunk_size=None):
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:intUndocumented
Returns
typing.Iterator[str]Undocumented
def json(self, **kwargs):

Undocumented

Parameters
**kwargs:typing.AnyUndocumented
Returns
typing.AnyUndocumented
def raise_for_status(self):
Raise the HTTPStatusError if one occurred.
def read(self):
Read and return the response content.
Returns
bytesUndocumented
@request.setter
def request(self, value):

Undocumented

Parameters
value:RequestUndocumented
extensions: dict =

Undocumented

headers =

Undocumented

history =

Undocumented

is_closed: bool =

Undocumented

is_stream_consumed: bool =

Undocumented

next_request: typing.Optional[Request] =

Undocumented

status_code =

Undocumented

stream =

Undocumented

@property
apparent_encoding: typing.Optional[str] =
Return the encoding, as determined by charset_normalizer.
@property
charset_encoding: typing.Optional[str] =
Return the encoding, as specified by the Content-Type header.
@property
content: bytes =

Undocumented

@property
cookies: Cookies =

Undocumented

@property
elapsed: datetime.timedelta =
Returns the time taken for the complete request/response cycle to complete.
@property
encoding: typing.Optional[str] =

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 charset_normalizer.
  • UTF-8.
@property
has_redirect_location: bool =
Returns True for 3xx responses with a properly formed URL redirection, False otherwise.
@property
http_version: str =

Undocumented

@property
is_client_error: bool =
A property which is True for 4xx status codes, False otherwise.
@property
is_error: bool =
A property which is True for 4xx and 5xx status codes, False otherwise.
@property
is_informational: bool =
A property which is True for 1xx status codes, False otherwise.
@property
is_redirect: bool =

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 =
A property which is True for 5xx status codes, False otherwise.
@property
is_success: bool =
A property which is True for 2xx status codes, False otherwise.
@property
links: typing.Dict[typing.Optional[str], typing.Dict[str, str]] =
Returns the parsed header links of the response, if any
@property
num_bytes_downloaded: int =

Undocumented

@property
reason_phrase: str =

Undocumented

@property
request: Request =
Returns the request instance associated to the current response.
@property
text: str =

Undocumented

@property
url: URL =
Returns the URL for which the request was made.
def _get_content_decoder(self):
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):

Undocumented

Parameters
default​_headers:typing.Dict[str, str]Undocumented
_content =

Undocumented

_decoder =

Undocumented

_elapsed =

Undocumented

_encoding =

Undocumented

_num_bytes_downloaded: int =

Undocumented

_request =

Undocumented