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

Public Member Functions

def __init__ (self, host, port=None, strict=False, timeout=Timeout.DEFAULT_TIMEOUT, maxsize=1, block=False, headers=None, retries=None, _proxy=None, _proxy_headers=None, _proxy_config=None, **conn_kw)
 
def close (self)
 
def is_same_host (self, url)
 
def urlopen (self, method, url, body=None, headers=None, retries=None, redirect=True, assert_same_host=True, timeout=_Default, pool_timeout=None, release_conn=None, chunked=False, body_pos=None, **response_kw)
 
- Public Member Functions inherited from ConnectionPool
def __init__ (self, host, port=None)
 
def __str__ (self)
 
def __enter__ (self)
 
def __exit__ (self, exc_type, exc_val, exc_tb)
 
- Public Member Functions inherited from RequestMethods
def __init__ (self, headers=None)
 
def urlopen (self, method, url, body=None, headers=None, encode_multipart=True, multipart_boundary=None, **kw)
 
def request (self, method, url, fields=None, headers=None, **urlopen_kw)
 
def request_encode_url (self, method, url, fields=None, headers=None, **urlopen_kw)
 
def request_encode_body (self, method, url, fields=None, headers=None, encode_multipart=True, multipart_boundary=None, **urlopen_kw)
 

Data Fields

 strict
 
 timeout
 
 retries
 
 pool
 
 block
 
 proxy
 
 proxy_headers
 
 proxy_config
 
 num_connections
 
 num_requests
 
 conn_kw
 
- Data Fields inherited from ConnectionPool
 host
 
 port
 
- Data Fields inherited from RequestMethods
 headers
 

Static Public Attributes

 scheme
 
 ConnectionCls
 
 ResponseCls
 
- Static Public Attributes inherited from ConnectionPool
 scheme
 
 QueueCls
 

Detailed Description

Thread-safe connection pool for one host.

:param host:
    Host used for this HTTP Connection (e.g. "localhost"), passed into
    :class:`http.client.HTTPConnection`.

:param port:
    Port used for this HTTP Connection (None is equivalent to 80), passed
    into :class:`http.client.HTTPConnection`.

:param strict:
    Causes BadStatusLine to be raised if the status line can't be parsed
    as a valid HTTP/1.0 or 1.1 status line, passed into
    :class:`http.client.HTTPConnection`.

    .. note::
       Only works in Python 2. This parameter is ignored in Python 3.

:param timeout:
    Socket timeout in seconds for each individual connection. This can
    be a float or integer, which sets the timeout for the HTTP request,
    or an instance of :class:`urllib3.util.Timeout` which gives you more
    fine-grained control over request timeouts. After the constructor has
    been parsed, this is always a `urllib3.util.Timeout` object.

:param maxsize:
    Number of connections to save that can be reused. More than 1 is useful
    in multithreaded situations. If ``block`` is set to False, more
    connections will be created but they will not be saved once they've
    been used.

:param block:
    If set to True, no more than ``maxsize`` connections will be used at
    a time. When no free connections are available, the call will block
    until a connection has been released. This is a useful side effect for
    particular multithreaded situations where one does not want to use more
    than maxsize connections per host to prevent flooding.

:param headers:
    Headers to include with all requests, unless other headers are given
    explicitly.

:param retries:
    Retry configuration to use by default with requests in this pool.

:param _proxy:
    Parsed proxy URL, should not be used directly, instead, see
    :class:`urllib3.ProxyManager`

:param _proxy_headers:
    A dictionary with proxy headers, should not be used directly,
    instead, see :class:`urllib3.ProxyManager`

:param \\**conn_kw:
    Additional parameters are used to create fresh :class:`urllib3.connection.HTTPConnection`,
    :class:`urllib3.connection.HTTPSConnection` instances.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  host,
  port = None,
  strict = False,
  timeout = Timeout.DEFAULT_TIMEOUT,
  maxsize = 1,
  block = False,
  headers = None,
  retries = None,
  _proxy = None,
  _proxy_headers = None,
  _proxy_config = None,
**  conn_kw 
)

Member Function Documentation

◆ close()

def close (   self)
Close all pooled connections and disable the pool.

Reimplemented from ConnectionPool.

◆ is_same_host()

def is_same_host (   self,
  url 
)
Check if the given ``url`` is a member of the same host as this
connection pool.

◆ urlopen()

def urlopen (   self,
  method,
  url,
  body = None,
  headers = None,
  retries = None,
  redirect = True,
  assert_same_host = True,
  timeout = _Default,
  pool_timeout = None,
  release_conn = None,
  chunked = False,
  body_pos = None,
**  response_kw 
)
Get a connection from the pool and perform an HTTP request. This is the
lowest level call for making a request, so you'll need to specify all
the raw details.

.. note::

   More commonly, it's appropriate to use a convenience method provided
   by :class:`.RequestMethods`, such as :meth:`request`.

.. note::

   `release_conn` will only behave as expected if
   `preload_content=False` because we want to make
   `preload_content=False` the default behaviour someday soon without
   breaking backwards compatibility.

:param method:
    HTTP request method (such as GET, POST, PUT, etc.)

:param url:
    The URL to perform the request on.

:param body:
    Data to send in the request body, either :class:`str`, :class:`bytes`,
    an iterable of :class:`str`/:class:`bytes`, or a file-like object.

:param headers:
    Dictionary of custom headers to send, such as User-Agent,
    If-None-Match, etc. If None, pool headers are used. If provided,
    these headers completely replace any pool-specific headers.

:param retries:
    Configure the number of retries to allow before raising a
    :class:`~urllib3.exceptions.MaxRetryError` exception.

    Pass ``None`` to retry until you receive a response. Pass a
    :class:`~urllib3.util.retry.Retry` object for fine-grained control
    over different types of retries.
    Pass an integer number to retry connection errors that many times,
    but no other types of errors. Pass zero to never retry.

    If ``False``, then retries are disabled and any exception is raised
    immediately. Also, instead of raising a MaxRetryError on redirects,
    the redirect response will be returned.

:type retries: :class:`~urllib3.util.retry.Retry`, False, or an int.

:param redirect:
    If True, automatically handle redirects (status codes 301, 302,
    303, 307, 308). Each redirect counts as a retry. Disabling retries
    will disable redirect, too.

:param assert_same_host:
    If ``True``, will make sure that the host of the pool requests is
    consistent else will raise HostChangedError. When ``False``, you can
    use the pool on an HTTP proxy and request foreign hosts.

:param timeout:
    If specified, overrides the default timeout for this one
    request. It may be a float (in seconds) or an instance of
    :class:`urllib3.util.Timeout`.

:param pool_timeout:
    If set and the pool is set to block=True, then this method will
    block for ``pool_timeout`` seconds and raise EmptyPoolError if no
    connection is available within the time period.

:param release_conn:
    If False, then the urlopen call will not release the connection
    back into the pool once a response is received (but will release if
    you read the entire contents of the response such as when
    `preload_content=True`). This is useful if you're not preloading
    the response's content immediately. You will need to call
    ``r.release_conn()`` on the response ``r`` to return the connection
    back into the pool. If None, it takes the value of
    ``response_kw.get('preload_content', True)``.

:param chunked:
    If True, urllib3 will send the body using chunked transfer
    encoding. Otherwise, urllib3 will send the body using the standard
    content-length form. Defaults to False.

:param int body_pos:
    Position to seek to in file-like body in the event of a retry or
    redirect. Typically this won't need to be set because urllib3 will
    auto-populate the value when needed.

:param \\**response_kw:
    Additional parameters are passed to
    :meth:`urllib3.response.HTTPResponse.from_httplib`

Field Documentation

◆ block

block

◆ conn_kw

conn_kw

◆ ConnectionCls

ConnectionCls
static

◆ num_connections

num_connections

◆ num_requests

num_requests

◆ pool

pool

◆ proxy

proxy

◆ proxy_config

proxy_config

◆ proxy_headers

proxy_headers

◆ ResponseCls

ResponseCls
static

◆ retries

retries

◆ scheme

scheme
static

◆ strict

strict

◆ timeout

timeout

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