Hacked By AnonymousFox

Current Path : /proc/thread-self/root/proc/self/root/lib/python2.7/site-packages/pip/_vendor/urllib3/
Upload File :
Current File : //proc/thread-self/root/proc/self/root/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyo

�
��abc@@s�ddlmZddlZddlZddlZddlmZddlmZm	Z	ddlm
Z
ddlmZm
Z
mZddlmZdd	lmZdd
lmZddlmZdd
dgZeje�Zd4Zd5Zejd-e�Zd.�Ziej ee�d/6ej ee�d06Z!ied/6e	d06Z"defd1��YZ#d
e#fd2��YZ$d3�Z%dS(6i(tabsolute_importNi(tRecentlyUsedContainer(tHTTPConnectionPooltHTTPSConnectionPool(tport_by_scheme(tLocationValueErrort
MaxRetryErrortProxySchemeUnknown(turljoin(tRequestMethods(t	parse_url(tRetrytPoolManagertProxyManagertproxy_from_urltkey_filet	cert_filet	cert_reqstca_certstssl_versiontca_cert_dirtssl_contextt
key_schemetkey_hosttkey_porttkey_timeouttkey_retriest
key_strictt	key_blocktkey_source_addresstkey_key_filet
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_fingerprinttPoolKeycC@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_(R0R1R2N(tcopytlowertNonet	frozensettitemstgetttupletlisttkeystpopt_fields(t	key_classtrequest_contexttcontexttkeytsocket_optstfield((sC/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyt_default_key_normalizer9s
!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((sC/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyt<lambda>�t(R	t__init__tconnection_pool_kwRtpoolstpool_classes_by_schemetkey_fn_by_schemeR5(tselft	num_poolsR0RO((sC/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyRN�s			cC@s|S(N((RS((sC/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyt	__enter__�scC@s|j�tS(N(tcleartFalse(RStexc_typetexc_valtexc_tb((sC/usr/lib/python2.7/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.
        R.R/tportRGN(R.R/R\(RQR7ROR5R>tSSL_KEYWORDS(RSR.R/R\RAtpool_clsRCtkw((sC/usr/lib/python2.7/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(RPRV(RS((sC/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyRV�sRGcC@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.RGR.iPR\R/(Rt_merge_pool_kwargsRR:R6tconnection_from_context(RSR/R\R.tpool_kwargsRA((sC/usr/lib/python2.7/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.
        R.RA(R6RRtconnection_from_pool_key(RSRAR.tpool_key_constructortpool_key((sC/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyRb�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.
        R.R/R\RAN(RPtlockR:R`(RSRgRAtpoolR.R/R\((sC/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyRe�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\R.Rc(R
RdR/R\R.(RSturlRctu((sC/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pytconnection_from_url
s!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(ROR5R9R7tKeyError(RStoverridetbase_pool_kwargsRCtvalue((sC/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyRas
cK@s�t|�}|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|	jrq|j|�rqx(|	jD]}
|dj|
d
�qPWny"|	j||d
|d|�}	Wn!tk
r�|	jr��n|SX|	|d	<||d<tjd||�|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\R.tassert_same_hosttredirectR0RGi/tGETtretriestresponset_poolsRedirecting %s -> %sN(R
RdR/R\R.RWR0R5tproxyR7turlopentrequest_uritget_redirect_locationRtstatusR:t
isinstanceRtfrom_inttremove_headers_on_redirecttis_same_hostR>t	incrementRtraise_on_redirecttlogtinfo(RStmethodRjRrR_RktconnRutredirect_locationRttheader((sC/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyRx-s@	$

		"
	

N(t__name__t
__module__t__doc__R7RwRNRUR[R`RVRdRbReRlRatTrueRx(((sC/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyRys					
	cB@sJeZdZdddd�Zdddd�Zdd�Zed�ZRS(sw
    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 contaning 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\RGRHt_proxyR1(RGRH(R|RR.R/R\R
RR:t_replaceRRwt
proxy_headerstsuperR
RN(RSt	proxy_urlRTR0R�RORwR\((sC/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyRN�s		

RGcC@sb|dkr.tt|�j|||d|�Stt|�j|jj|jj|jjd|�S(NRHRc(R�R
RdRwR/R\R.(RSR/R\R.Rc((sC/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyRd�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(RSRjR0theaders_R�((sC/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyt_set_proxy_headers�s

cK@skt|�}|jdkrI|jd|j�}|j||�|d<ntt|�j||d||�S(s@Same as HTTP(S)ConnectionPool.urlopen, ``url`` must be absolute.RGR0Rr(R
R.R:R0R�R�R
Rx(RSR�RjRrR_RkR0((sC/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyRx�s
N(	R�R�R�R7RNRdR�R�Rx(((sC/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyR
iscK@std||�S(NR�(R
(RjR_((sC/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyR�s(RRRRRRR(RRRRRRRRRRR R!R"R#R$R%R&R'R(R)R*R+R,(&t
__future__Rtcollectionst	functoolstloggingt_collectionsRtconnectionpoolRRRt
exceptionsRRRtpackages.six.moves.urllib.parseRtrequestR	tutil.urlR
t
util.retryRt__all__t	getLoggerR�R�R]t_key_fieldst
namedtupleR-RFtpartialRRRQRR
R(((sC/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/poolmanager.pyt<module>sb	5
�W

Hacked By AnonymousFox1.0, Coded By AnonymousFox