|
netdata
|
Public Member Functions | |
| def | __init__ (self, body='', headers=None, status=0, version=0, reason=None, strict=0, preload_content=True, decode_content=True, original_response=None, pool=None, connection=None, retries=None, enforce_content_length=False, request_method=None) |
| def | get_redirect_location (self) |
| def | release_conn (self) |
| def | data (self) |
| def | connection (self) |
| def | tell (self) |
| def | read (self, amt=None, decode_content=None, cache_content=False) |
| def | stream (self, amt=2 **16, decode_content=None) |
| def | from_httplib (ResponseCls, r, response_kw) |
| def | getheaders (self) |
| def | getheader (self, name, default=None) |
| def | close (self) |
| def | closed (self) |
| def | fileno (self) |
| def | flush (self) |
| def | readable (self) |
| def | readinto (self, b) |
| def | supports_chunked_reads (self) |
| def | read_chunked (self, amt=None, decode_content=None) |
Public Attributes | |
| headers | |
| status | |
| version | |
| reason | |
| strict | |
| decode_content | |
| retries | |
| enforce_content_length | |
| chunked | |
| chunk_left | |
| length_remaining | |
Static Public Attributes | |
| CONTENT_DECODERS | |
| REDIRECT_STATUSES | |
HTTP Response container.
Backwards-compatible to httplib's HTTPResponse but the response ``body`` is
loaded and decoded on-demand when the ``data`` property is accessed. This
class is also compatible with the Python standard library's :mod:`io`
module, and can hence be treated as a readable object in the context of that
framework.
Extra parameters for behaviour not present in httplib.HTTPResponse:
:param preload_content:
If True, the response's body will be preloaded during construction.
:param decode_content:
If True, attempts to decode specific content-encoding's based on headers
(like 'gzip' and 'deflate') will be skipped and raw data will be used
instead.
:param original_response:
When this HTTPResponse wrapper is generated from an httplib.HTTPResponse
object, it's convenient to include the original for debug purposes. It's
otherwise unused.
:param retries:
The retries contains the last :class:`~urllib3.util.retry.Retry` that
was used during the request.
:param enforce_content_length:
Enforce content length checking. Body returned by server must match
value of Content-Length header, if present. Otherwise, raise error.
| def python_modules.urllib3.response.HTTPResponse.from_httplib | ( | ResponseCls, | |
| r, | |||
| response_kw | |||
| ) |
Given an :class:`httplib.HTTPResponse` instance ``r``, return a corresponding :class:`urllib3.response.HTTPResponse` object. Remaining parameters are passed to the HTTPResponse constructor, along with ``original_response=r``.
| def python_modules.urllib3.response.HTTPResponse.get_redirect_location | ( | self | ) |
Should we redirect and where to?
:returns: Truthy redirect location string if we got a redirect status
code and valid location. ``None`` if redirect status and no
location. ``False`` if not a redirect status code.
| def python_modules.urllib3.response.HTTPResponse.read | ( | self, | |
amt = None, |
|||
decode_content = None, |
|||
cache_content = False |
|||
| ) |
Similar to :meth:`httplib.HTTPResponse.read`, but with two additional
parameters: ``decode_content`` and ``cache_content``.
:param amt:
How much of the content to read. If specified, caching is skipped
because it doesn't make sense to cache partial content as the full
response.
:param decode_content:
If True, will attempt to decode the body based on the
'content-encoding' header.
:param cache_content:
If True, will save the returned data such that the same result is
returned despite of the state of the underlying file object. This
is useful if you want the ``.data`` property to continue working
after having ``.read()`` the file object. (Overridden if ``amt`` is
set.)
| def python_modules.urllib3.response.HTTPResponse.read_chunked | ( | self, | |
amt = None, |
|||
decode_content = None |
|||
| ) |
Similar to :meth:`HTTPResponse.read`, but with an additional
parameter: ``decode_content``.
:param decode_content:
If True, will attempt to decode the body based on the
'content-encoding' header.
| def python_modules.urllib3.response.HTTPResponse.stream | ( | self, | |
amt = 2**16, |
|||
decode_content = None |
|||
| ) |
A generator wrapper for the read() method. A call will block until
``amt`` bytes have been read from the connection or until the
connection is closed.
:param amt:
How much of the content to read. The generator will return up to
much data per iteration, but may return less. This is particularly
likely when using compressed data. However, the empty string will
never be returned.
:param decode_content:
If True, will attempt to decode the body based on the
'content-encoding' header.
| def python_modules.urllib3.response.HTTPResponse.supports_chunked_reads | ( | self | ) |
Checks if the underlying file-like object looks like a httplib.HTTPResponse object. We do this by testing for the fp attribute. If it is present we assume it returns raw chunks as processed by read_chunked().
| def python_modules.urllib3.response.HTTPResponse.tell | ( | self | ) |
Obtain the number of bytes pulled over the wire so far. May differ from the amount of content returned by :meth:``HTTPResponse.read`` if bytes are encoded on the wire (e.g, compressed).
1.8.12