%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core/17212/usr/lib/python3/dist-packages/requests/__pycache__/
Upload File :
Create Path :
Current File : //snap/core/17212/usr/lib/python3/dist-packages/requests/__pycache__/adapters.cpython-35.pyc



~�VWD�@s�dZddlZddlZddlmZddlmZmZddl	m
Z
ddlmZ
ddlmZdd	lmZmZdd
lmZmZmZmZmZmZddlmZddlmZdd
lmZddlmZ ddlm!Z!ddlm"Z"ddlm#Z$ddlm%Z%ddlm&Z&ddlm'Z(ddlm)Z)ddl*m+Z+ddl,m-Z-m.Z.m/Z/m'Z'm#Z#m0Z0ddl1m2Z2dZ3dZ4dZ5dZ6Gdd�de7�Z8Gdd�de8�Z9dS)z�
requests.adapters
~~~~~~~~~~~~~~~~~

This module contains the transport adapters that Requests uses to define
and maintain connections.
�N�)�Response)�PoolManager�proxy_from_url)�HTTPResponse)�Timeout)�Retry)�urlparse�
basestring)�DEFAULT_CA_BUNDLE_PATH�get_encoding_from_headers�prepend_scheme_if_needed�get_auth_from_url�
urldefragauth�select_proxy)�CaseInsensitiveDict)�ClosedPoolError)�ConnectTimeoutError)�	HTTPError)�
MaxRetryError)�NewConnectionError)�
ProxyError)�
ProtocolError)�ReadTimeoutError)�SSLError)�
ResponseError)�extract_cookies_to_jar)�ConnectionError�ConnectTimeout�ReadTimeoutrr�
RetryError)�_basic_auth_strF�
cs@eZdZdZ�fdd�Zdd�Zdd�Z�S)�BaseAdapterzThe Base Transport Adaptercstt|�j�dS)N)�superr#�__init__)�self)�	__class__��3/usr/lib/python3/dist-packages/requests/adapters.pyr%0szBaseAdapter.__init__cCs
t�dS)N)�NotImplementedError)r&r(r(r)�send3szBaseAdapter.sendcCs
t�dS)N)r*)r&r(r(r)�close6szBaseAdapter.close)�__name__�
__module__�__qualname__�__doc__r%r+r,r(r()r'r)r#-sr#cs�eZdZdZdddddgZeeee�fdd�Zd	d
�Z	dd�Z
ed
d�Zdd�Zdd�Z
dd�Zddd�Zdd�Zdd�Zdd�Zdd�Zd dd!ddd"d#�Z�S)$�HTTPAdaptera�The built-in HTTP Adapter for urllib3.

    Provides a general-case interface for Requests sessions to contact HTTP and
    HTTPS urls by implementing the Transport Adapter interface. This class will
    usually be created by the :class:`Session <Session>` class under the
    covers.

    :param pool_connections: The number of urllib3 connection pools to cache.
    :param pool_maxsize: The maximum number of connections to save in the pool.
    :param int max_retries: The maximum number of retries each connection
        should attempt. Note, this applies only to failed DNS lookups, socket
        connections and connection timeouts, never to requests where data has
        made it to the server. By default, Requests does not retry failed
        connections. If you need granular control over the conditions under
        which we retry a request, import urllib3's ``Retry`` class and pass
        that instead.
    :param pool_block: Whether the connection pool should block for connections.

    Usage::

      >>> import requests
      >>> s = requests.Session()
      >>> a = requests.adapters.HTTPAdapter(max_retries=3)
      >>> s.mount('http://', a)
    �max_retries�config�_pool_connections�
_pool_maxsize�_pool_blockcs�|tkr$tddd�|_ntj|�|_i|_i|_tt|�j�||_	||_
||_|j||d|�dS)Nr�readF�block)
�DEFAULT_RETRIESrr2Zfrom_intr3�
proxy_managerr$r1r%r4r5r6�init_poolmanager)r&Zpool_connectionsZpool_maxsizer2Z
pool_block)r'r(r)r%Ws					zHTTPAdapter.__init__cs t�fdd��jD��S)Nc3s'|]}|t�|d�fVqdS)N)�getattr)�.0�attr)r&r(r)�	<genexpr>jsz+HTTPAdapter.__getstate__.<locals>.<genexpr>)�dict�	__attrs__)r&r()r&r)�__getstate__iszHTTPAdapter.__getstate__cCsbi|_i|_x*|j�D]\}}t|||�qW|j|j|jd|j�dS)Nr8)r:r3�items�setattrr;r4r5r6)r&�stater>�valuer(r(r)�__setstate__ms		zHTTPAdapter.__setstate__c
KsF||_||_||_td|d|d|dd|�|_dS)aInitializes a urllib3 PoolManager.

        This method should not be called from user code, and is only
        exposed for use when subclassing the
        :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.

        :param connections: The number of urllib3 connection pools to cache.
        :param maxsize: The maximum number of connections to save in the pool.
        :param block: Block when no free connections are available.
        :param pool_kwargs: Extra keyword arguments used to initialize the Pool Manager.
        �	num_pools�maxsizer8�strictTN)r4r5r6r�poolmanager)r&ZconnectionsrIr8Zpool_kwargsr(r(r)r;ys

			zHTTPAdapter.init_poolmanagercKs`||jkrU|j|�}t|d|d|jd|jd|j|�|j|<|j|S)a�Return urllib3 ProxyManager for the given proxy.

        This method should not be called from user code, and is only
        exposed for use when subclassing the
        :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.

        :param proxy: The proxy to return a urllib3 ProxyManager for.
        :param proxy_kwargs: Extra keyword arguments used to configure the Proxy Manager.
        :returns: ProxyManager
        �
proxy_headersrHrIr8)r:rLrr4r5r6)r&�proxyZproxy_kwargsrLr(r(r)�proxy_manager_for�s		zHTTPAdapter.proxy_manager_forcCs�|j�jd�r�|r�d}|dk	r3|}|s?t}|sQtd��d|_tjj|�sx||_q�||_	nd|_d|_d|_	|r�t
|t�s�|d|_|d|_
n	||_dS)	a�Verify a SSL certificate. This method should not be called from user
        code, and is only exposed for use when subclassing the
        :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.

        :param conn: The urllib3 connection object associated with the cert.
        :param url: The requested URL.
        :param verify: Whether we should actually verify the certificate.
        :param cert: The SSL certificate to verify.
        �httpsNTz4Could not find a suitable SSL CA certificate bundle.Z
CERT_REQUIREDZ	CERT_NONErr)�lower�
startswithr�	ExceptionZ	cert_reqs�os�path�isdirZca_certsZca_cert_dir�
isinstancer
Z	cert_fileZkey_file)r&�conn�url�verify�certZcert_locr(r(r)�cert_verify�s(
				
zHTTPAdapter.cert_verifycCs�t�}t|dd�|_tt|di��|_t|j�|_||_|jj|_t	|j
t�r�|j
jd�|_
n|j
|_
t
|j||�||_||_|S)a�Builds a :class:`Response <requests.Response>` object from a urllib3
        response. This should not be called from user code, and is only exposed
        for use when subclassing the
        :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`

        :param req: The :class:`PreparedRequest <PreparedRequest>` used to generate the response.
        :param resp: The urllib3 response object.
        ZstatusN�headerszutf-8)rr<Zstatus_coderr\r�encoding�raw�reasonrVrX�bytes�decoder�cookies�request�
connection)r&Zreq�respZresponser(r(r)�build_response�s					zHTTPAdapter.build_responseNcCsst||�}|rEt|d�}|j|�}|j|�}n*t|�}|j�}|jj|�}|S)aeReturns a urllib3 connection for the given URL. This should not be
        called from user code, and is only exposed for use when subclassing the
        :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.

        :param url: The URL to connect to.
        :param proxies: (optional) A Requests-style dictionary of proxies used on this request.
        Zhttp)rr
rNZconnection_from_urlr	ZgeturlrK)r&rX�proxiesrMr:rWZparsedr(r(r)�get_connection�szHTTPAdapter.get_connectioncCs|jj�dS)z�Disposes of any internal state.

        Currently, this just closes the PoolManager, which closes pooled
        connections.
        N)rK�clear)r&r(r(r)r,szHTTPAdapter.closecCsUt|j|�}t|j�j}|rH|dkrHt|j�}n	|j}|S)a+Obtain the url to use when making the final request.

        If the message is being sent through a HTTP proxy, the full URL has to
        be used. Otherwise, we should only use the path portion of the URL.

        This should not be called from user code, and is only exposed for use
        when subclassing the
        :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.

        :param request: The :class:`PreparedRequest <PreparedRequest>` being sent.
        :param proxies: A dictionary of schemes or schemes and hosts to proxy URLs.
        rO)rrXr	�schemerZpath_url)r&rcrgrMrjrXr(r(r)�request_urls
	zHTTPAdapter.request_urlcKsdS)a"Add any headers needed by the connection. As of v2.0 this does
        nothing by default, but is left for overriding by users that subclass
        the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.

        This should not be called from user code, and is only exposed for use
        when subclassing the
        :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.

        :param request: The :class:`PreparedRequest <PreparedRequest>` to add headers to.
        :param kwargs: The keyword arguments from the call to send().
        Nr()r&rc�kwargsr(r(r)�add_headers&szHTTPAdapter.add_headerscCs;i}t|�\}}|r7|r7t||�|d<|S)a�Returns a dictionary of the headers to add to any request sent
        through a proxy. This works with urllib3 magic to ensure that they are
        correctly sent to the proxy, rather than in a tunnelled request if
        CONNECT is being used.

        This should not be called from user code, and is only exposed for use
        when subclassing the
        :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.

        :param proxies: The url of the proxy being used for this request.
        zProxy-Authorization)rr!)r&rMr\ZusernameZpasswordr(r(r)rL4s
zHTTPAdapter.proxy_headersFTc,Cs�|j|j|�}|j||j||�|j||�}|j|�|jdkphd|jk}	t|t�r�y%|\}
}t	d|
d|�}Wq�t
k
r�}z dj|�}
t
|
��WYdd}~Xq�Xnt	d|d|�}y�|	s[|jd|j
d|d|jd	|jd
dddd
dddd|jd|�
}nkt|d�rs|j}|jdt�}y)|j|j
|dd�x-|jj�D]\}}|j||�q�W|j�xd|jD]Y}|jtt|��dd�jd��|jd�|j|�|jd�q�W|jd�y|jdd�}Wntk
r�|j�}YnXtj|d|d|d
ddd�}Wn|j��YnXWn�t t!j"fk
r	}
zt#|
d|��WYdd}
~
Xnlt$k
r�}zqt|j%t&�rQt|j%t'�sQt(|d|��t|j%t)�rut*|d|��t#|d|��WYdd}~Xn�t+k
r�}zt#|d|��WYdd}~Xn�t,k
r�}zt-|��WYdd}~Xnvt.t/fk
rt}zPt|t.�r;t0|d|��n't|t1�r_t2|d|��n�WYdd}~XnX|j3||�S)a�Sends PreparedRequest object. Returns Response object.

        :param request: The :class:`PreparedRequest <PreparedRequest>` being sent.
        :param stream: (optional) Whether to stream the request content.
        :param timeout: (optional) How long to wait for the server to send
            data before giving up, as a float, or a :ref:`(connect timeout,
            read timeout) <timeouts>` tuple.
        :type timeout: float or tuple
        :param verify: (optional) Whether to verify SSL certificates.
        :param cert: (optional) Any user-provided SSL certificate to be trusted.
        :param proxies: (optional) The proxies dictionary to apply to the request.
        NzContent-Length�connectr7zsInvalid timeout {0}. Pass a (connect, read) timeout tuple, or a single float to set both timeouts to the same value�methodrX�bodyr\ZredirectFZassert_same_hostZpreload_contentZdecode_contentZretries�timeout�
proxy_poolZskip_accept_encodingT�zutf-8s
s0

�	bufferingZpoolrdrc)4rhrXr[rkrmrpr\rV�tuple�TimeoutSauce�
ValueError�formatZurlopenror2�hasattrrrZ	_get_conn�DEFAULT_POOL_TIMEOUTZ
putrequestrCZ	putheaderZ
endheadersr+�hex�len�encodeZgetresponse�	TypeErrorrZfrom_httplibr,r�socket�errorrrr_rrrrr r�_ProxyErrorr�	_SSLError�
_HTTPErrorrrrrf)r&rc�streamrqrYrZrgrWrXZchunkedrnr7�e�errreZlow_conn�headerrF�i�rr(r(r)r+Is�
	"						
,





$$$zHTTPAdapter.send)r-r.r/r0rA�DEFAULT_POOLSIZEr9�DEFAULT_POOLBLOCKr%rBrGr;rNr[rfrhr,rkrmrLr+r(r()r'r)r1:s$	*$r1):r0�os.pathrSrZmodelsrZpackages.urllib3.poolmanagerrrZpackages.urllib3.responserZpackages.urllib3.utilrrvZpackages.urllib3.util.retryr�compatr	r
Zutilsrrr
rrrZ
structuresrZpackages.urllib3.exceptionsrrrr�rrrr�rrrr�rrbr�
exceptionsrrrr Zauthr!r�r�r9rz�objectr#r1r(r(r(r)�<module>	s:..

Zerion Mini Shell 1.0