%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/self/root/opt/alt/python27/lib/python2.7/site-packages/urllib3/
Upload File :
Create Path :
Current File : //proc/self/root/opt/alt/python27/lib/python2.7/site-packages/urllib3/poolmanager.pyo

�
��Vc@@sGddlmZddlZyddlmZWn!ek
rSddlmZnXddlmZddl	m
Z
mZddl	mZddl
mZmZmZdd	lmZdd
lmZddlmZdd
dgZeje�ZdZie
d6ed6Zdefd��YZd
efd��YZd�ZdS(i(tabsolute_importN(turljoini(tRecentlyUsedContainer(tHTTPConnectionPooltHTTPSConnectionPool(tport_by_scheme(tLocationValueErrort
MaxRetryErrortProxySchemeUnknown(tRequestMethods(t	parse_url(tRetrytPoolManagertProxyManagertproxy_from_urltkey_filet	cert_filet	cert_reqstca_certstssl_versiontca_cert_dirthttpthttpscB@skeZdZdZddd�Zd�Zd�Zd�Zd�Z	ddd�Z
d	�Zed
�Z
RS(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@s>tj||�||_t|dd��|_t|_dS(Ntdispose_funccS@s
|j�S(N(tclose(tp((sD/opt/alt/python27/lib/python2.7/site-packages/urllib3/poolmanager.pyt<lambda>Bs(R	t__init__tconnection_pool_kwRtpoolstpool_classes_by_scheme(tselft	num_poolstheadersR((sD/opt/alt/python27/lib/python2.7/site-packages/urllib3/poolmanager.pyR>s
		cC@s|S(N((R((sD/opt/alt/python27/lib/python2.7/site-packages/urllib3/poolmanager.pyt	__enter__GscC@s|j�tS(N(tcleartFalse(Rtexc_typetexc_valtexc_tb((sD/opt/alt/python27/lib/python2.7/site-packages/urllib3/poolmanager.pyt__exit__Js
cC@se|j|}|j}|dkrU|jj�}x!tD]}|j|d�q8Wn||||�S(s
        Create a new :class:`ConnectionPool` based on host, port and scheme.

        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.
        RN(RRtcopytSSL_KEYWORDStpoptNone(Rtschemethosttporttpool_clstkwargstkw((sD/opt/alt/python27/lib/python2.7/site-packages/urllib3/poolmanager.pyt	_new_poolOs
	
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(RR#(R((sD/opt/alt/python27/lib/python2.7/site-packages/urllib3/poolmanager.pyR#`sRcC@s�|std��n|pd}|p6tj|d�}|||f}|jj�C|jj|�}|rq|S|j|||�}||j|<WdQX|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``.
        sNo host specified.RiPN(RRtgetRtlockR3(RR.R/R-tpool_keytpool((sD/opt/alt/python27/lib/python2.7/site-packages/urllib3/poolmanager.pytconnection_from_hostis
cC@s.t|�}|j|jd|jd|j�S(s*
        Similar to :func:`urllib3.connectionpool.connection_from_url` but
        doesn't pass any additional parameters to the
        :class:`urllib3.connectionpool.ConnectionPool` constructor.

        Additional parameters are taken from the :class:`.PoolManager`
        constructor.
        R/R-(R
R8R.R/R-(Rturltu((sD/opt/alt/python27/lib/python2.7/site-packages/urllib3/poolmanager.pytconnection_from_url�s	c
K@s�t|�}|j|jd|jd|j�}t|d<t|d<d|kr`|j|d<n|jd
k	r�|jdkr�|j	|||�}n|j	||j
|�}|o�|j�}|s�|St||�}|j
dkr�d}n|jd	�}	t|	t�s'tj|	d|�}	ny"|	j||d
|d|�}	Wn!tk
rl|	jrh�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_hosttredirectR!Ri/tGETtretriestresponset_poolsRedirecting %s -> %sN(R
R8R.R/R-R$R!tproxyR,turlopentrequest_uritget_redirect_locationRtstatusR4t
isinstanceRtfrom_intt	incrementRtraise_on_redirecttlogtinfo(
RtmethodR9R=R2R:tconnR@tredirect_locationR?((sD/opt/alt/python27/lib/python2.7/site-packages/urllib3/poolmanager.pyRC�s8	$

	"
	

N(t__name__t
__module__t__doc__R,RBRR"R(R3R#R8R;tTrueRC(((sD/opt/alt/python27/lib/python2.7/site-packages/urllib3/poolmanager.pyR s							cB@sGeZdZdddd�Zddd�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/RRt_proxyt_proxy_headers(shttpR(RGRR-R.R/R
RR4t_replaceRRBt
proxy_headerstsuperR
R(Rt	proxy_urlR R!RWRRBR/((sD/opt/alt/python27/lib/python2.7/site-packages/urllib3/poolmanager.pyR�s		

RcC@sV|dkr(tt|�j|||�Stt|�j|jj|jj|jj�S(NR(RXR
R8RBR.R/R-(RR.R/R-((sD/opt/alt/python27/lib/python2.7/site-packages/urllib3/poolmanager.pyR8�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(RR9R!theaders_R\((sD/opt/alt/python27/lib/python2.7/site-packages/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.RR!R=(R
R-R4R!R_RXR
RC(RRMR9R=R2R:R!((sD/opt/alt/python27/lib/python2.7/site-packages/urllib3/poolmanager.pyRC
s
N(	RPRQRRR,RR8R_RSRC(((sD/opt/alt/python27/lib/python2.7/site-packages/urllib3/poolmanager.pyR
�scK@std||�S(NRY(R
(R9R2((sD/opt/alt/python27/lib/python2.7/site-packages/urllib3/poolmanager.pyRs(RRRRRR( t
__future__Rtloggingturllib.parseRtImportErrorturlparset_collectionsRtconnectionpoolRRRt
exceptionsRRRtrequestR	tutil.urlR
t
util.retryRt__all__t	getLoggerRPRKR*RRR
R(((sD/opt/alt/python27/lib/python2.7/site-packages/urllib3/poolmanager.pyt<module>s,

�W

Zerion Mini Shell 1.0