ok

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/pip/_vendor/urllib3/
Upload File :
Current File : //usr/lib/python2.7/site-packages/pip/_vendor/urllib3/connectionpool.pyc

�
��abc@@sSddlmZddlZddlZddlZddlZddlmZm	Z
ddlZddlmZm
Z
mZmZmZmZmZmZmZmZmZmZmZddlmZddlmZddlmZdd	lm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&dd
l'm(Z(ddl)m*Z*ddl+m,Z,dd
l-m.Z.ddl/m0Z0ddl1m2Z2ddl3m4Z4ddl5m6Z6m7Z7ej8r�ddl9Z:nej;j<Z<ej=e>�Z?e@�ZAde@fd��YZBeCejDejEg�ZFdeBe(fd��YZGdeGfd��YZHd�ZId�ZJdS(i(tabsolute_importN(terrorttimeouti(
tClosedPoolErrort
ProtocolErrortEmptyPoolErrortHeaderParsingErrortHostChangedErrortLocationValueErrort
MaxRetryErrort
ProxyErrortReadTimeoutErrortSSLErrortTimeoutErrortInsecureRequestWarningtNewConnectionError(tCertificateError(tsix(tqueue(tport_by_schemetDummyConnectiontHTTPConnectiontHTTPSConnectiontVerifiedHTTPSConnectiont
HTTPExceptiontBaseSSLError(tRequestMethods(tHTTPResponse(tis_connection_dropped(tset_file_position(tassert_header_parsing(tRetry(tTimeout(tget_hosttUrltConnectionPoolcB@sMeZdZdZejZdd�Zd�Z	d�Z
d�Zd�ZRS(sz
    Base class for all connection pools, such as
    :class:`.HTTPConnectionPool` and :class:`.HTTPSConnectionPool`.
    cC@sF|std��nt|�j�|_|j�|_||_dS(NsNo host specified.(Rt
_ipv6_hosttlowerthostt_proxy_hosttport(tselfR&R(((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/connectionpool.pyt__init__Cs
cC@s dt|�j|j|jfS(Ns%s(host=%r, port=%r)(ttypet__name__R&R((R)((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/connectionpool.pyt__str__KscC@s|S(N((R)((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/connectionpool.pyt	__enter__OscC@s|j�tS(N(tclosetFalse(R)texc_typetexc_valtexc_tb((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/connectionpool.pyt__exit__Rs
cC@sdS(sD
        Close all pooled connections and disable the pool.
        N((R)((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/connectionpool.pyR/WsN(
R,t
__module__t__doc__tNonetschemeRt	LifoQueuetQueueClsR*R-R.R4R/(((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/connectionpool.pyR#:s				tHTTPConnectionPoolcB@s�eZdZdZeZeZde	e
jde	ddddd�	Zd�Z
dd�Zd�Zd�Zd�Zd	�Zd
�Zee	d�Zd�Zd
�Zd�Zdddeeedde	dd�
ZRS(sN	
    Thread-safe connection pool for one host.

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

    :param port:
        Port used for this HTTP Connection (None is equivalent to 80), passed
        into :class:`httplib.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:`httplib.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.connectionpool.ProxyManager`"

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

    :param \**conn_kw:
        Additional parameters are used to create fresh :class:`urllib3.connection.HTTPConnection`,
        :class:`urllib3.connection.HTTPSConnection` instances.
    thttpic
K@stj|||�tj||�||_t|t�sMtj|�}n|dkretj	}n||_
||_|j|�|_
||_|	|_|
p�i|_x$t|�D]}|j
jd�q�Wd|_d|_||_|jr|jjdg�ndS(Nitsocket_options(R#R*Rtstrictt
isinstanceR t
from_floatR7RtDEFAULTRtretriesR:tpooltblocktproxyt
proxy_headerstxrangetputtnum_connectionstnum_requeststconn_kwt
setdefault(
R)R&R(R>RtmaxsizeRDtheadersRBt_proxyt_proxy_headersRKt_((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/connectionpool.pyR*�s(									c
C@se|jd7_tjd|j|j�|jd|jd|jd|jjd|j|j	�}|S(s9
        Return a fresh :class:`HTTPConnection`.
        is%Starting new HTTP connection (%d): %sR&R(RR>(
RItlogtdebugR&t
ConnectionClsR(Rtconnect_timeoutR>RK(R)tconn((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/connectionpool.pyt	_new_conn�s	cC@s�d	}y"|jjd|jd|�}WnNtk
rJt|d��n/tjk
rx|jryt|d��qynX|r�t	|�r�t
jd|j�|j
�t|dd�dkr�d	}q�n|p�|j�S(
s�
        Get a connection. Will return a pooled connection if one is available.

        If no connections are available and :prop:`.block` is ``False``, then a
        fresh connection is returned.

        :param timeout:
            Seconds to wait before giving up and raising
            :class:`urllib3.exceptions.EmptyPoolError` if the pool is empty and
            :prop:`.block` is ``True``.
        RDRsPool is closed.s>Pool reached maximum size and no more connections are allowed.s Resetting dropped connection: %st	auto_openiiN(R7RCtgetRDtAttributeErrorRRtEmptyRRRRRSR&R/tgetattrRW(R)RRV((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/connectionpool.pyt	_get_conn�s "
	
cC@soy|jj|dt�dSWn7tk
r1n'tjk
rWtjd|j�nX|rk|j	�ndS(s�
        Put a connection back into the pool.

        :param conn:
            Connection object for the current host and port as returned by
            :meth:`._new_conn` or :meth:`._get_conn`.

        If the pool is already full, the connection is closed and discarded
        because we exceeded maxsize. If connections are discarded frequently,
        then maxsize should be increased.

        If the pool is closed, then the connection will be closed and discarded.
        RDNs2Connection pool is full, discarding connection: %s(
RCRHR0RZRtFullRRtwarningR&R/(R)RV((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/connectionpool.pyt	_put_conn�s
cC@sdS(sU
        Called right before a request is made, after the socket is created.
        N((R)RV((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/connectionpool.pyt_validate_connscC@sdS(N((R)RV((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/connectionpool.pyt_prepare_proxy!scC@sC|tkr|jj�St|t�r2|j�Stj|�SdS(s< Helper that always returns a :class:`urllib3.util.Timeout` N(t_DefaultRtcloneR?R R@(R)R((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/connectionpool.pyt_get_timeout%s


cC@s�t|t�r(t||d|��nt|d�r_|jtkr_t||d|��ndt|�ks�dt|�kr�t||d|��ndS(sAIs the error actually a timeout? Will raise a ReadTimeout or passs!Read timed out. (read timeout=%s)terrnos	timed outsdid not complete (read)N(R?t
SocketTimeoutRthasattrRft_blocking_errnoststr(R)terrturlt
timeout_value((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/connectionpool.pyt_raise_timeout1s$c

K@sh|jd7_|j|�}|j�|j|_y|j|�Wn;ttfk
r�}|jd|d|d|j��nX|r�|j	|||�n|j
|||�|j}	t|dd�r-|	dkr�t||d|	��n|	tjkr|jjtj��q-|jj|	�nydy|jdt�}
WnGtk
r�y|j�}
Wq�tk
r�}tj|d�q�XnXWn;tttfk
r�}|jd|d|d|	��nXt|d	d
�}tjd|j|j|j ||||
j!|
j"�	yt#|
j$�Wn;t%tfk
rc}tj&d|j'|�|d
t�nX|
S(s
        Perform a request on a given urllib connection object taken from our
        pool.

        :param conn:
            a connection from one of our connection pools

        :param timeout:
            Socket timeout in seconds for the request. This can be a
            float or integer, which will set the same timeout value for
            the socket connect and the socket read, or an instance of
            :class:`urllib3.util.Timeout`, which gives you more fine-grained
            control over your timeouts.
        iRkRlRmtsockis!Read timed out. (read timeout=%s)t	bufferingt
_http_vsn_strsHTTP/?s%s://%s:%s "%s %s %s" %s %ss$Failed to parse headers (url=%s): %stexc_infoN((RJRet
start_connectRURRaRgRRntrequest_chunkedtrequesttread_timeoutR\R7RR tDEFAULT_TIMEOUTRot
settimeouttsockettgetdefaulttimeouttgetresponsetTruet	TypeErrort	ExceptionRt
raise_fromtSocketErrorRRRSR8R&R(tstatustlengthRtmsgRR_t
_absolute_url(
R)RVtmethodRlRtchunkedthttplib_request_kwttimeout_objteRvthttplib_responsethttp_versionthpe((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/connectionpool.pyt
_make_requestBsT
	

c	C@s+td|jd|jd|jd|�jS(NR8R&R(tpath(R"R8R&R(Rl(R)R�((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/connectionpool.pyR��scC@sd|jd}|_y6x/trG|jdt�}|r|j�qqWWntjk
r_nXdS(sD
        Close all pooled connections and disable the pool.
        RDN(RCR7R|RYR0R/RR[(R)told_poolRV((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/connectionpool.pyR/�s	cC@s�|jd�rtSt|�\}}}t|�j�}|jr\|r\tj|�}n(|jr�|tj|�kr�d}n|||f|j	|j
|jfkS(sj
        Check if the given ``url`` is a member of the same host as this
        connection pool.
        t/N(t
startswithR|R!R$R%R(RRYR7R8R&(R)RlR8R&R(((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/connectionpool.pytis_same_host�s	c
K@sJ|dkr|j}nt|t�sHtj|d|d|j�}n|
dkri|
jdt�}
n|r�|j|�r�t	|||��nd}|
}|j
dkr�|j�}|j|j
�nd}t}t||�}z�y�|j|�}|jd|	�}|j|_|jdk	o;t|dd�}|rT|j|�n|j|||d|d|d|d	|�}|
s�|nd}||
d
<|jj|d|d|d
||
�}t}Wn	tjk
r�t|d��n�tttt t!t"t#fk
r�}t}t|t!t#f�r>t"|�}nWt|tt$f�rn|jrnt%d|�}n't|ttf�r�t d|�}n|j&||d|d|dt'j(�d�}|j)�|}nXWd|s�|o�|j*�}t}n|r|j+|�nX|sit,j-d|||�|j.|||||||d|d|	d|
d||
�Sd�}|o�|j/�}|r_|j0dkr�d}ny"|j&||d|d|�}Wn+t1k
r�|j2r�||��n|SX||�|j3|�t,j4d||�|j.||||d
|d|d|d|d|	d|
d||
�St5|j6d ��}|j7||j0|�rFy"|j&||d|d|�}Wn+t1k
r�|j8r�||��n|SX||�|j)|�t,j4d!|�|j.||||d
|d|d|d|d|	d|
d||
�S|S("s�
        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 body:
            Data to send in the request body (useful for creating
            POST requests, see HTTPConnectionPool.post_url for
            more convenience).

        :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`
        tredirecttdefaulttpreload_contentR<RRotbodyRNR�trequest_methodRCt
connectionRBs"No pool connections are available.sCannot connect to proxy.sConnection aborted.Rt_poolt_stacktraceiNs1Retrying (%r) after connection broken by '%r': %stpool_timeouttrelease_conntbody_posc
S@s:y|j�Wn%ttttttfk
r5}nXdS(N(treadR
RR�RRR(tresponseR�((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/connectionpool.pytdrain_and_release_conn�s

i/tGETR�sRedirecting %s -> %stassert_same_hostsRetry-Afters	Retry: %s(9R7RNR?Rtfrom_intRBRYR|R�RR8tcopytupdateRFR0RReR]RURRER\RbR�tResponseClstfrom_httplibRR[RR
RR�RRRRRR
t	incrementtsysRrtsleepR/R`RRR_turlopentget_redirect_locationR�R	traise_on_redirecttsleep_for_retryRStboolt	getheadertis_retrytraise_on_status(R)R�RlR�RNRBR�R�RR�R�R�R�tresponse_kwRVtrelease_this_connRkt
clean_exitR�tis_new_proxy_connR�t
response_connR�R�R�tredirect_locationthas_retry_after((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/connectionpool.pyR��s�^!"	
	


		
			
	"
	


	"
	



N(R,R5R6R8RRTRR�R7R0R RwR*RWR]R`RaRbReRnRcR�R�R/R�R|R�(((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/connectionpool.pyR;bs.:%	
&					U						tHTTPSConnectionPoolcB@s}eZdZdZeZdeej	deddddddddddddd�Z
d�Zd�Zd�Z
d�ZRS(	s�
    Same as :class:`.HTTPConnectionPool`, but HTTPS.

    When Python is compiled with the :mod:`ssl` module, then
    :class:`.VerifiedHTTPSConnection` is used, which *can* verify certificates,
    instead of :class:`.HTTPSConnection`.

    :class:`.VerifiedHTTPSConnection` uses one of ``assert_fingerprint``,
    ``assert_hostname`` and ``host`` in this order to verify connections.
    If ``assert_hostname`` is False, no verification is done.

    The ``key_file``, ``cert_file``, ``cert_reqs``, ``ca_certs``,
    ``ca_cert_dir``, and ``ssl_version`` are only used if :mod:`ssl` is
    available and are fed into :meth:`urllib3.util.ssl_wrap_socket` to upgrade
    the connection socket into an SSL socket.
    thttpsic
K@s�tj||||||||||	|
|�|rI|
dkrId}
n||_||_|
|_||_||_||_||_	||_
dS(Nt
CERT_REQUIRED(R;R*R7tkey_filet	cert_filet	cert_reqstca_certstca_cert_dirtssl_versiontassert_hostnametassert_fingerprint(R)R&R(R>RRMRDRNRBRORPR�R�R�R�R�R�R�R�RK((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/connectionpool.pyR*�s									cC@skt|t�rg|jd|jd|jd|jd|jd|jd|jd|j	�|j
|_
n|S(s�
        Prepare the ``connection`` for :meth:`urllib3.util.ssl_wrap_socket`
        and establish the tunnel if proxy is used.
        R�R�R�R�R�R�R�(R?Rtset_certR�R�R�R�R�R�R�R�(R)RV((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/connectionpool.pyt
_prepare_conns					
cC@s�y
|j}Wntk
r)|j}nXtjdkrY|jrY||j|j�n||j|j|j�|j�dS(s�
        Establish tunnel connection early, because otherwise httplib
        would improperly set Host: header to proxy's IP:port.
        iiiN(iii(	t
set_tunnelRZt_set_tunnelR�tversion_infoRFR'R(tconnect(R)RVR�((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/connectionpool.pyRb s


c
C@s�|jd7_tjd|j|j�|jsA|jtkrPtd��n|j}|j}|jdk	r�|jj}|jj}n|jd|d|d|j
jd|j|j
�}|j|�S(	sB
        Return a fresh :class:`httplib.HTTPSConnection`.
        is&Starting new HTTPS connection (%d): %ssCCan't connect to HTTPS URL because the SSL module is not available.R&R(RR>N(RIRRRSR&RTRRR(RER7RRUR>RKR�(R)tactual_hosttactual_portRV((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/connectionpool.pyRW2s			cC@sUtt|�j|�t|dd�s5|j�n|jsQtjdt	�ndS(sU
        Called right before a request is made, after the socket is created.
        Ros�Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warningsN(
tsuperR�RaR\R7R�tis_verifiedtwarningstwarnR(R)RV((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/connectionpool.pyRaJs
	N(R,R5R6R8RRTR7R0R RwR*R�RbRWRa(((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/connectionpool.pyR��s					cK@sct|�\}}}|p*tj|d�}|dkrLt|d||�St|d||�SdS(s�
    Given a url, return an :class:`.ConnectionPool` instance of its host.

    This is a shortcut for not having to parse out the scheme, host, and port
    of the url before creating an :class:`.ConnectionPool` instance.

    :param url:
        Absolute URL string that must include the scheme. Port is optional.

    :param \**kw:
        Passes additional parameters to the constructor of the appropriate
        :class:`.ConnectionPool`. Useful for specifying things like
        timeout, maxsize, headers, etc.

    Example::

        >>> conn = connection_from_url('http://google.com/')
        >>> r = conn.request('GET', '/')
    iPR�R(N(R!RRYR�R;(RltkwR8R&R(((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/connectionpool.pytconnection_from_url]s
cC@s@|jd�r<|jd�r<|jdd�jd�}n|S(s'
    Process IPv6 address literals
    t[t]s%25t%s[](R�tendswithtreplacetstrip(R&((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/connectionpool.pyR$ys(Kt
__future__RRftloggingR�R�RyRR�RRgt
exceptionsRRRRRRR	R
RRR
RRtpackages.ssl_match_hostnameRtpackagesRtpackages.six.movesRR�RRRRRRRRuRR�Rtutil.connectionRtutil.requestRt
util.responseRt
util.retryRtutil.timeoutR tutil.urlR!R"tPY2tQueuet_unused_module_QueuetmovesRGt	getLoggerR,RRtobjectRcR#tsettEAGAINtEWOULDBLOCKRiR;R�R�R$(((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/connectionpool.pyt<module>s@X4		%���|	

Zerion Mini Shell 1.0