ok

Mini Shell

Direktori : /proc/self/root/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/
Upload File :
Current File : //proc/self/root/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/poolmanager.pyo

�
Bu�_c@@s�ddlmZddlZddlZddlZddlZddlmZddlm	Z	m
Z
ddlmZddlm
Z
mZmZmZddlmZdd	lmZdd
lmZddlmZddlmZd
ddgZeje�Zd8Zd9Z ej!d1e �Z"d2�Z#iej$e#e"�d36ej$e#e"�d46Z%ie	d36e
d46Z&d
efd5��YZ'de'fd6��YZ(d7�Z)dS(:i(tabsolute_importNi(tRecentlyUsedContainer(tHTTPConnectionPooltHTTPSConnectionPool(tport_by_scheme(tLocationValueErrort
MaxRetryErrortProxySchemeUnknownt InvalidProxyConfigurationWarning(tsix(turljoin(tRequestMethods(t	parse_url(tRetrytPoolManagertProxyManagertproxy_from_urltkey_filet	cert_filet	cert_reqstca_certstssl_versiontca_cert_dirtssl_contexttkey_passwordt
key_schemetkey_hosttkey_porttkey_timeouttkey_retriest
key_strictt	key_blocktkey_source_addresstkey_key_filetkey_key_passwordt
key_cert_filet
key_cert_reqstkey_ca_certstkey_ssl_versiontkey_ca_cert_dirtkey_ssl_contexttkey_maxsizetkey_headerst
key__proxytkey__proxy_headerstkey_socket_optionstkey__socks_optionstkey_assert_hostnametkey_assert_fingerprinttkey_server_hostnametPoolKeycC@s|j�}|dj�|d<|dj�|d<xGdD]?}||kr;||d	k	r;t||j��||<q;q;W|jd�}|d	k	r�t|�|d<nx1t|j��D]}|j	|�|d|<q�Wx*|j
D]}||kr�d	||<q�q�W||�S(
s�
    Create a pool key out of a request context dictionary.

    According to RFC 3986, both the scheme and host are case-insensitive.
    Therefore, this function normalizes both before constructing the pool
    key for an HTTPS request. If you wish to change this behaviour, provide
    alternate callables to ``key_fn_by_scheme``.

    :param key_class:
        The class to use when constructing the key. This should be a namedtuple
        with the ``scheme`` and ``host`` keys at a minimum.
    :type  key_class: namedtuple
    :param request_context:
        A dictionary-like object that contain the context for a request.
    :type  request_context: dict

    :return: A namedtuple that can be used as a connection pool key.
    :rtype:  PoolKey
    tschemethosttheaderst_proxy_headerst_socks_optionstsocket_optionstkey_(sheadersR6R7N(tcopytlowertNonet	frozensettitemstgetttupletlisttkeystpopt_fields(t	key_classtrequest_contexttcontexttkeytsocket_optstfield((sP/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/poolmanager.pyt_default_key_normalizerJs
!thttpthttpscB@s�eZdZdZddd�Zd�Zd�Zdd�Zd�Z	dddd�Z
d	�Zdd
�Zdd�Z
d�Zed
�ZRS(s$
    Allows for arbitrary requests while transparently keeping track of
    necessary connection pools for you.

    :param num_pools:
        Number of connection pools to cache before discarding the least
        recently used pool.

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

    :param \**connection_pool_kw:
        Additional parameters are used to create fresh
        :class:`urllib3.connectionpool.ConnectionPool` instances.

    Example::

        >>> manager = PoolManager(num_pools=2)
        >>> r = manager.request('GET', 'http://google.com/')
        >>> r = manager.request('GET', 'http://google.com/mail')
        >>> r = manager.request('GET', 'http://yahoo.com/')
        >>> len(manager.pools)
        2

    i
cK@sMtj||�||_t|dd��|_t|_tj�|_dS(Ntdispose_funccS@s
|j�S(N(tclose(tp((sP/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/poolmanager.pyt<lambda>�s(Rt__init__tconnection_pool_kwRtpoolstpool_classes_by_schemetkey_fn_by_schemeR:(tselft	num_poolsR5RS((sP/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/poolmanager.pyRR�s
		cC@s|S(N((RW((sP/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/poolmanager.pyt	__enter__�scC@s|j�tS(N(tcleartFalse(RWtexc_typetexc_valtexc_tb((sP/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/poolmanager.pyt__exit__�s
cC@s�|j|}|dkr+|jj�}nxdD]}|j|d�q2W|dkr|x!tD]}|j|d�q_Wn||||�S(s�
        Create a new :class:`ConnectionPool` based on host, port, scheme, and
        any additional pool keyword arguments.

        If ``request_context`` is provided, it is provided as keyword arguments
        to the pool class used. This method is used to actually create the
        connection pools handed out by :meth:`connection_from_url` and
        companion methods. It is intended to be overridden for customization.
        R3R4tportRLN(sschemeshostsport(RUR<RSR:RCtSSL_KEYWORDS(RWR3R4R`RFtpool_clsRHtkw((sP/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/poolmanager.pyt	_new_pool�s



cC@s|jj�dS(s�
        Empty our store of pools and direct them all to close.

        This will not affect in-flight connections, but they will not be
        re-used after completion.
        N(RTRZ(RW((sP/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/poolmanager.pyRZ�sRLcC@sz|std��n|j|�}|p-d|d<|sYtj|dj�d�}n||d<||d<|j|�S(s�
        Get a :class:`ConnectionPool` based on the host, port, and scheme.

        If ``port`` isn't given, it will be derived from the ``scheme`` using
        ``urllib3.connectionpool.port_by_scheme``. If ``pool_kwargs`` is
        provided, it is merged with the instance's ``connection_pool_kw``
        variable and used to create the new connection pool, if one is
        needed.
        sNo host specified.RLR3iPR`R4(Rt_merge_pool_kwargsRR?R;tconnection_from_context(RWR4R`R3tpool_kwargsRF((sP/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/poolmanager.pytconnection_from_host�s

cC@s<|dj�}|j|}||�}|j|d|�S(s�
        Get a :class:`ConnectionPool` based on the request context.

        ``request_context`` must at least contain the ``scheme`` key and its
        value must be a key in ``key_fn_by_scheme`` instance variable.
        R3RF(R;RVtconnection_from_pool_key(RWRFR3tpool_key_constructortpool_key((sP/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/poolmanager.pyRf�s
c
C@sy|jj�g|jj|�}|r)|S|d}|d}|d}|j|||d|�}||j|<WdQX|S(s�
        Get a :class:`ConnectionPool` based on the provided pool key.

        ``pool_key`` should be a namedtuple that only contains immutable
        objects. At a minimum it must have the ``scheme``, ``host``, and
        ``port`` fields.
        R3R4R`RFN(RTtlockR?Rd(RWRkRFtpoolR3R4R`((sP/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/poolmanager.pyRi�s



cC@s4t|�}|j|jd|jd|jd|�S(s�
        Similar to :func:`urllib3.connectionpool.connection_from_url`.

        If ``pool_kwargs`` is not provided and a new pool needs to be
        constructed, ``self.connection_pool_kw`` is used to initialize
        the :class:`urllib3.connectionpool.ConnectionPool`. If ``pool_kwargs``
        is provided, it is used instead. Note that if a new pool does not
        need to be created for the request, the provided ``pool_kwargs`` are
        not used.
        R`R3Rg(RRhR4R`R3(RWturlRgtu((sP/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/poolmanager.pytconnection_from_urlscC@sq|jj�}|rmxU|j�D]D\}}|dkr\y||=Wqftk
rXqfXq"|||<q"Wn|S(s
        Merge a dictionary of override values for self.connection_pool_kw.

        This does not modify self.connection_pool_kw and returns a new dict.
        Any keys in the override dictionary with a value of ``None`` are
        removed from the merged dictionary.
        N(RSR:R>R<tKeyError(RWtoverridetbase_pool_kwargsRHtvalue((sP/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/poolmanager.pyRe's
c
K@s3t|�}|j|jd|jd|j�}t|d<t|d<d|krf|jj�|d<n|jd
k	r�|jdkr�|j
|||�}n|j
||j|�}|o�|j�}|s�|St
||�}|jdkr�d}n|jd	�}	t|	t�s-tj|	d|�}	n|	jr�|j|�r�ttj|d��}
x=|
D]2}|j�|	jkrf|dj|d
�qfqfWny"|	j||d
|d|�}	Wn+tk
r�|	jr�|j��n|SX|	|d	<||d<tjd||�|j�|j
|||�S(s]
        Same as :meth:`urllib3.connectionpool.HTTPConnectionPool.urlopen`
        with custom cross-host redirect logic and only sends the request-uri
        portion of the ``url``.

        The given ``url`` parameter must be absolute, such that an appropriate
        :class:`urllib3.connectionpool.ConnectionPool` can be chosen for it.
        R`R3tassert_same_hosttredirectR5RLi/tGETtretriestresponset_poolsRedirecting %s -> %sN( RRhR4R`R3R[R5R:tproxyR<turlopentrequest_uritget_redirect_locationR
tstatusR?t
isinstanceR
tfrom_inttremove_headers_on_redirecttis_same_hostRAR	titerkeysR;RCt	incrementRtraise_on_redirectt
drain_conntlogtinfo(RWtmethodRnRvRcRotconnRytredirect_locationRxR5theader((sP/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/poolmanager.pyR|;sH	$

	

"
	



N(t__name__t
__module__t__doc__R<R{RRRYR_RdRZRhRfRiRpRetTrueR|(((sP/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/poolmanager.pyR�s
					
	cB@sSeZdZdddd�Zdddd�Zdd�Zd�Zed�Z	RS(	sx
    Behaves just like :class:`PoolManager`, but sends all requests through
    the defined proxy, using the CONNECT method for HTTPS URLs.

    :param proxy_url:
        The URL of the proxy to be used.

    :param proxy_headers:
        A dictionary containing headers that will be sent to the proxy. In case
        of HTTP they are being sent with each request, while in the
        HTTPS/CONNECT case they are sent only once. Could be used for proxy
        authentication.

    Example:
        >>> proxy = urllib3.ProxyManager('http://localhost:3128/')
        >>> r1 = proxy.request('GET', 'http://google.com/')
        >>> r2 = proxy.request('GET', 'http://httpbin.org/')
        >>> len(proxy.pools)
        1
        >>> r3 = proxy.request('GET', 'https://httpbin.org/')
        >>> r4 = proxy.request('GET', 'https://twitter.com/')
        >>> len(proxy.pools)
        3

    i
cK@s�t|t�r.d|j|j|jf}nt|�}|jsmtj|jd�}|jd|�}n|jdkr�t	|j��n||_
|p�i|_|j
|d<|j|d<tt
|�j|||�dS(	Ns
%s://%s:%iiPR`RLRMt_proxyR6(shttpRM(R�RR3R4R`RRR?t_replaceRR{t
proxy_headerstsuperRRR(RWt	proxy_urlRXR5R�RSR{R`((sP/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/poolmanager.pyRR�s 			

RLcC@sb|dkr.tt|�j|||d|�Stt|�j|jj|jj|jjd|�S(NRMRg(R�RRhR{R4R`R3(RWR4R`R3Rg((sP/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/poolmanager.pyRh�s
cC@sIidd6}t|�j}|r/||d<n|rE|j|�n|S(s�
        Sets headers needed by proxies: specifically, the Accept and Host
        headers. Only sets headers not provided by the user.
        s*/*tAccepttHost(Rtnetloctupdate(RWRnR5theaders_R�((sP/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/poolmanager.pyt_set_proxy_headers�s

cC@s;|dkr7|jjdkr7tjdtdd�ndS(NRMsYour proxy configuration specified an HTTPS scheme for the proxy. Are you sure you want to use HTTPS to contact the proxy? This most likely indicates an error in your configuration. Read this issue for more info: https://github.com/urllib3/urllib3/issues/1850t
stackleveli(R{R3twarningstwarnR(RWt
url_scheme((sP/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/poolmanager.pyt$_validate_proxy_scheme_url_selection�s
cK@s{t|�}|j|j�|jdkrY|jd|j�}|j||�|d<ntt|�j||d||�S(s@Same as HTTP(S)ConnectionPool.urlopen, ``url`` must be absolute.RLR5Rv(	RR�R3R?R5R�R�RR|(RWR�RnRvRcRoR5((sP/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/poolmanager.pyR|�sN(
R�R�R�R<RRRhR�R�R�R|(((sP/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/poolmanager.pyR}s
	cK@std||�S(NR�(R(RnRc((sP/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/poolmanager.pyR�s(RRRRRRRR(RRRRRRRR R!R"R#R$R%R&R'R(R)R*R+R,R-R.R/R0R1(*t
__future__Rtcollectionst	functoolstloggingR�t_collectionsRtconnectionpoolRRRt
exceptionsRRRRtpackagesR	tpackages.six.moves.urllib.parseR
trequestRtutil.urlRt
util.retryR
t__all__t	getLoggerR�R�Rat_key_fieldst
namedtupleR2RKtpartialRVRURRR(((sP/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/poolmanager.pyt<module>sr"	5�n

Zerion Mini Shell 1.0