Qucs-S S-parameter Viewer & RF Synthesis Tools
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
pip._vendor.urllib3.response.HTTPResponse Class Reference
Inheritance diagram for pip._vendor.urllib3.response.HTTPResponse:
Inheritance graph
[legend]
Collaboration diagram for pip._vendor.urllib3.response.HTTPResponse:
Collaboration graph
[legend]

Public Member Functions

 __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, msg=None, retries=None, enforce_content_length=False, request_method=None, request_url=None, auto_close=True)
 
 get_redirect_location (self)
 
 release_conn (self)
 
 drain_conn (self)
 
 data (self)
 
 connection (self)
 
 isclosed (self)
 
 tell (self)
 
 read (self, amt=None, decode_content=None, cache_content=False)
 
 stream (self, amt=2 **16, decode_content=None)
 
 from_httplib (ResponseCls, r, **response_kw)
 
 getheaders (self)
 
 getheader (self, name, default=None)
 
 info (self)
 
 close (self)
 
 closed (self)
 
 fileno (self)
 
 flush (self)
 
 readable (self)
 
 readinto (self, b)
 
 supports_chunked_reads (self)
 
 read_chunked (self, amt=None, decode_content=None)
 
 geturl (self)
 
 __iter__ (self)
 

Public Attributes

 headers
 
 status
 
 version
 
 reason
 
 strict
 
 decode_content
 
 retries
 
 enforce_content_length
 
 auto_close
 
 msg
 
 chunked
 
 chunk_left
 
 length_remaining
 

Static Public Attributes

list CONTENT_DECODERS = ["gzip", "deflate"]
 
list REDIRECT_STATUSES = [301, 302, 303, 307, 308]
 
tuple DECODER_ERROR_CLASSES = (IOError, zlib.error)
 

Protected Member Functions

 _init_length (self, request_method)
 
 _init_decoder (self)
 
 _decode (self, data, decode_content, flush_decoder)
 
 _flush_decoder (self)
 
 _error_catcher (self)
 
 _fp_read (self, amt)
 
 _update_chunk_length (self)
 
 _handle_chunk (self, amt)
 

Protected Attributes

 _decoder
 
 _body
 
 _fp
 
 _original_response
 
 _fp_bytes_read
 
 _request_url
 
 _pool
 
 _connection
 

Detailed Description

HTTP Response container.

Backwards-compatible with :class:`http.client.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 :class:`http.client.HTTPResponse`:

:param preload_content:
    If True, the response's body will be preloaded during construction.

:param decode_content:
    If True, will attempt to decode the body based on the
    'content-encoding' header.

:param original_response:
    When this HTTPResponse wrapper is generated from an :class:`http.client.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.

Member Function Documentation

◆ _decode()

pip._vendor.urllib3.response.HTTPResponse._decode (   self,
  data,
  decode_content,
  flush_decoder 
)
protected
Decode the data passed in and potentially flush the decoder.

◆ _error_catcher()

pip._vendor.urllib3.response.HTTPResponse._error_catcher (   self)
protected
Catch low-level python exceptions, instead re-raising urllib3
variants, so that low-level exceptions are not leaked in the
high-level api.

On exit, release the connection back to the pool.

◆ _flush_decoder()

pip._vendor.urllib3.response.HTTPResponse._flush_decoder (   self)
protected
Flushes the decoder. Should only be called if the decoder is actually
being used.

◆ _fp_read()

pip._vendor.urllib3.response.HTTPResponse._fp_read (   self,
  amt 
)
protected
Read a response with the thought that reading the number of bytes
larger than can fit in a 32-bit int at a time via SSL in some
known cases leads to an overflow error that has to be prevented
if `amt` or `self.length_remaining` indicate that a problem may
happen.

The known cases:
  * 3.8 <= CPython < 3.9.7 because of a bug
    https://github.com/urllib3/urllib3/issues/2513#issuecomment-1152559900.
  * urllib3 injected with pyOpenSSL-backed SSL-support.
  * CPython < 3.10 only when `amt` does not fit 32-bit int.

◆ _init_decoder()

pip._vendor.urllib3.response.HTTPResponse._init_decoder (   self)
protected
Set-up the _decoder attribute if necessary.

◆ _init_length()

pip._vendor.urllib3.response.HTTPResponse._init_length (   self,
  request_method 
)
protected
Set initial length value for Response content if available.

◆ drain_conn()

pip._vendor.urllib3.response.HTTPResponse.drain_conn (   self)
Read and discard any remaining HTTP response data in the response connection.

Unread data in the HTTPResponse connection blocks the connection from being released back to the pool.

◆ from_httplib()

pip._vendor.urllib3.response.HTTPResponse.from_httplib (   ResponseCls,
  r,
**  response_kw 
)
Given an :class:`http.client.HTTPResponse` instance ``r``, return a
corresponding :class:`urllib3.response.HTTPResponse` object.

Remaining parameters are passed to the HTTPResponse constructor, along
with ``original_response=r``.

◆ get_redirect_location()

pip._vendor.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.

◆ geturl()

pip._vendor.urllib3.response.HTTPResponse.geturl (   self)
Returns the URL that was the source of this response.
If the request that generated this response redirected, this method
will return the final redirect location.

◆ read()

pip._vendor.urllib3.response.HTTPResponse.read (   self,
  amt = None,
  decode_content = None,
  cache_content = False 
)
Similar to :meth:`http.client.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.)

◆ read_chunked()

pip._vendor.urllib3.response.HTTPResponse.read_chunked (   self,
  amt = None,
  decode_content = None 
)
Similar to :meth:`HTTPResponse.read`, but with an additional
parameter: ``decode_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.

◆ stream()

pip._vendor.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.

◆ supports_chunked_reads()

pip._vendor.urllib3.response.HTTPResponse.supports_chunked_reads (   self)
Checks if the underlying file-like object looks like a
:class:`http.client.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().

◆ tell()

pip._vendor.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:``urllib3.response.HTTPResponse.read``
if bytes are encoded on the wire (e.g, compressed).

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