OpenQuizz
Une application de gestion des contenus pédagogiques
Response Class Reference
Inheritance diagram for Response:
Collaboration diagram for Response:

Public Member Functions

def __init__ (self)
 
def __enter__ (self)
 
def __exit__ (self, *args)
 
def __getstate__ (self)
 
def __setstate__ (self, state)
 
def __repr__ (self)
 
def __bool__ (self)
 
def __nonzero__ (self)
 
def __iter__ (self)
 
def ok (self)
 
def is_redirect (self)
 
def is_permanent_redirect (self)
 
def next (self)
 
def apparent_encoding (self)
 
def iter_content (self, chunk_size=1, decode_unicode=False)
 
def iter_lines (self, chunk_size=ITER_CHUNK_SIZE, decode_unicode=False, delimiter=None)
 
def content (self)
 
def text (self)
 
def json (self, **kwargs)
 
def links (self)
 
def raise_for_status (self)
 
def close (self)
 

Data Fields

 status_code
 
 headers
 
 raw
 
 url
 
 encoding
 
 history
 
 reason
 
 cookies
 
 elapsed
 
 request
 

Detailed Description

The :class:`Response <Response>` object, which contains a
server's response to an HTTP request.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self)

Member Function Documentation

◆ __bool__()

def __bool__ (   self)
Returns True if :attr:`status_code` is less than 400.

This attribute checks if the status code of the response is between
400 and 600 to see if there was a client error or a server error. If
the status code, is between 200 and 400, this will return True. This
is **not** a check to see if the response code is ``200 OK``.

◆ __enter__()

def __enter__ (   self)

◆ __exit__()

def __exit__ (   self,
args 
)

◆ __getstate__()

def __getstate__ (   self)

◆ __iter__()

def __iter__ (   self)
Allows you to use a response as an iterator.

◆ __nonzero__()

def __nonzero__ (   self)
Returns True if :attr:`status_code` is less than 400.

This attribute checks if the status code of the response is between
400 and 600 to see if there was a client error or a server error. If
the status code, is between 200 and 400, this will return True. This
is **not** a check to see if the response code is ``200 OK``.

◆ __repr__()

def __repr__ (   self)

◆ __setstate__()

def __setstate__ (   self,
  state 
)

◆ apparent_encoding()

def apparent_encoding (   self)
The apparent encoding, provided by the chardet library.

◆ close()

def close (   self)
Releases the connection back to the pool. Once this method has been
called the underlying ``raw`` object must not be accessed again.

*Note: Should not normally need to be called explicitly.*

◆ content()

def content (   self)
Content of the response, in bytes.

◆ is_permanent_redirect()

def is_permanent_redirect (   self)
True if this Response one of the permanent versions of redirect.

◆ is_redirect()

def is_redirect (   self)
True if this Response is a well-formed HTTP redirect that could have
been processed automatically (by :meth:`Session.resolve_redirects`).

◆ iter_content()

def iter_content (   self,
  chunk_size = 1,
  decode_unicode = False 
)
Iterates over the response data.  When stream=True is set on the
request, this avoids reading the content at once into memory for
large responses.  The chunk size is the number of bytes it should
read into memory.  This is not necessarily the length of each item
returned as decoding can take place.

chunk_size must be of type int or None. A value of None will
function differently depending on the value of `stream`.
stream=True will read data as it arrives in whatever size the
chunks are received. If stream=False, data is returned as
a single chunk.

If decode_unicode is True, content will be decoded using the best
available encoding based on the response.

◆ iter_lines()

def iter_lines (   self,
  chunk_size = ITER_CHUNK_SIZE,
  decode_unicode = False,
  delimiter = None 
)
Iterates over the response data, one line at a time.  When
stream=True is set on the request, this avoids reading the
content at once into memory for large responses.

.. note:: This method is not reentrant safe.

◆ json()

def json (   self,
**  kwargs 
)
Returns the json-encoded content of a response, if any.

:param \*\*kwargs: Optional arguments that ``json.loads`` takes.
:raises ValueError: If the response body does not contain valid json.

◆ links()

def links (   self)
Returns the parsed header links of the response, if any.

◆ next()

def next (   self)
Returns a PreparedRequest for the next request in a redirect chain, if there is one.

◆ ok()

def ok (   self)
Returns True if :attr:`status_code` is less than 400, False if not.

This attribute checks if the status code of the response is between
400 and 600 to see if there was a client error or a server error. If
the status code is between 200 and 400, this will return True. This
is **not** a check to see if the response code is ``200 OK``.

◆ raise_for_status()

def raise_for_status (   self)
Raises :class:`HTTPError`, if one occurred.

◆ text()

def text (   self)
Content of the response, in unicode.

If Response.encoding is None, encoding will be guessed using
``chardet``.

The encoding of the response content is determined based solely on HTTP
headers, following RFC 2616 to the letter. If you can take advantage of
non-HTTP knowledge to make a better guess at the encoding, you should
set ``r.encoding`` appropriately before accessing this property.

Field Documentation

◆ cookies

cookies

◆ elapsed

elapsed

◆ encoding

encoding

◆ headers

headers

◆ history

history

◆ raw

raw

◆ reason

reason

◆ request

request

◆ status_code

status_code

◆ url

url

The documentation for this class was generated from the following file: