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/response.pyo

�
��abc@@saddlmZddlmZddlZddlZddlZddlmZ	ddlm
Zddlm
Z
ddlmZmZmZmZmZmZmZdd	lmZmZmZdd
lmZddlmZm Z ddl!m"Z"m#Z#ej$e%�Z&d
e'fd��YZ(de'fd��YZ)d�Z*dej+fd��YZ,dS(i(tabsolute_import(tcontextmanagerN(ttimeout(terrori(tHTTPHeaderDict(tBodyNotHttplibCompatiblet
ProtocolErrortDecodeErrortReadTimeoutErrortResponseNotChunkedtIncompleteReadt
InvalidHeader(tstring_typestbinary_typetPY3(thttp_client(t
HTTPExceptiontBaseSSLError(tis_fp_closedtis_response_to_headtDeflateDecodercB@s#eZd�Zd�Zd�ZRS(cC@s(t|_t�|_tj�|_dS(N(tTruet
_first_tryR
t_datatzlibt
decompressobjt_obj(tself((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pyt__init__s	cC@st|j|�S(N(tgetattrR(Rtname((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pyt__getattr__scC@s�|s
|S|js#|jj|�S|j|7_y5|jj|�}|rbt|_d|_n|SWnTtjk
r�t|_tjtj	�|_z|j|j�SWdd|_XnXdS(N(
RRt
decompressRtFalsetNoneRRRt	MAX_WBITS(Rtdatatdecompressed((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pyR  s"			(t__name__t
__module__RRR (((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pyRs		tGzipDecodercB@s#eZd�Zd�Zd�ZRS(cC@stjdtj�|_dS(Ni(RRR#R(R((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pyR9scC@st|j|�S(N(RR(RR((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pyR<scC@s|s
|S|jj|�S(N(RR (RR$((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pyR ?s(R&R'RRR (((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pyR(7s		cC@s|dkrt�St�S(Ntgzip(R(R(tmode((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pyt_get_decoderEstHTTPResponsecB@s�eZdZddgZdddddgZdd'd	d	d'd	eed'd'd'd'ed'd
�Zd�Z	d�Z
ed
��Zed��Z
d�Zd�Zd�Zd�Zd�Zed��Zd'd'ed�Zd(d'd�Zed��Zd�Zd'd�Zd�Zd�Zed��Zd�Zd �Zd!�Z d"�Z!d#�Z"d$�Z#d%�Z$d'd'd&�Z%RS()s	
    HTTP Response container.

    Backwards-compatible to httplib's HTTPResponse but the response ``body`` is
    loaded and decoded on-demand when the ``data`` property is accessed.  This
    class is also compatible with the Python standard library's :mod:`io`
    module, and can hence be treated as a readable object in the context of that
    framework.

    Extra parameters for behaviour not present in httplib.HTTPResponse:

    :param preload_content:
        If True, the response's body will be preloaded during construction.

    :param decode_content:
        If True, attempts to decode specific content-encoding's based on headers
        (like 'gzip' and 'deflate') will be skipped and raw data will be used
        instead.

    :param original_response:
        When this HTTPResponse wrapper is generated from an httplib.HTTPResponse
        object, it's convenient to include the original for debug purposes. It's
        otherwise unused.

    :param retries:
        The retries contains the last :class:`~urllib3.util.retry.Retry` that
        was used during the request.

    :param enforce_content_length:
        Enforce content length checking. Body returned by server must match
        value of Content-Length header, if present. Otherwise, raise error.
    R)tdeflatei-i.i/i3i4ticC@s�t|t�r||_nt|�|_||_||_||_||_||_||_|
|_	d|_d|_d|_
|	|_d|_|r�t|ttf�r�||_n|
|_||_t|d�r�||_
nt|_d|_|jjdd�j�}d�|jd�D�}d|krHt|_n|j|�|_|r�|jr�|jd|�|_ndS(	Nitreadstransfer-encodingR.cs@s|]}|j�VqdS(N(tstrip(t.0tenc((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pys	<genexpr>�st,tchunkedtdecode_content(t
isinstanceRtheaderststatustversiontreasontstrictR5tretriestenforce_content_lengthR"t_decodert_bodyt_fpt_original_responset_fp_bytes_readt
basestringR
t_poolt_connectionthasattrR!R4t
chunk_lefttgettlowertsplitRt_init_lengthtlength_remainingR/(RtbodyR7R8R9R:R;tpreload_contentR5toriginal_responsetpoolt
connectionR<R=trequest_methodttr_enct	encodings((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pyRqs<																cC@s&|j|jkr"|jjd�StS(s
        Should we redirect and where to?

        :returns: Truthy redirect location string if we got a redirect status
            code and valid location. ``None`` if redirect status and no
            location. ``False`` if not a redirect status code.
        tlocation(R8tREDIRECT_STATUSESR7RHR!(R((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pytget_redirect_location�scC@s8|js|jrdS|jj|j�d|_dS(N(RDREt	_put_connR"(R((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pytrelease_conn�scC@s-|jr|jS|jr)|jdt�SdS(Nt
cache_content(R?R@R/R(R((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pyR$�s		cC@s|jS(N(RE(R((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pyRQ�scC@s|jS(s�
        Obtain the number of bytes pulled over the wire so far. May differ from
        the amount of content returned by :meth:``HTTPResponse.read`` if bytes
        are encoded on the wire (e.g, compressed).
        (RB(R((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pyttell�scC@sG|jjd�}|dk	r8|jr8tjd�dS|dk	r�yctg|jd�D]}t|�^qZ�}t	|�dkr�t
d|��n|j�}Wntk
r�d}q�X|dkr�d}q�nyt|j
�}Wntk
rd}nX|d
ks:d	|ko)d
kns:|dkrCd}n|S(sM
        Set initial length value for Response content if available.
        scontent-lengths�Received response with both Content-Length and Transfer-Encoding set. This is expressly forbidden by RFC 7230 sec 3.3.2. Ignoring Content-Length and attempting to process response as Transfer-Encoding: chunked.R3is8Content-Length contained multiple unmatching values (%s)ii�i0idi�tHEADN(i�i0(R7RHR"R4tlogtwarningtsetRJtinttlenRtpopt
ValueErrorR8(RRRtlengthtvaltlengthsR8((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pyRK�s,
.




4	cC@sO|jjdd�j�}|jdkrK||jkrKt|�|_ndS(s=
        Set-up the _decoder attribute if necessary.
        scontent-encodingR.N(R7RHRIR>R"tCONTENT_DECODERSR+(Rtcontent_encoding((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pyt
_init_decoder�scC@s�y(|r'|jr'|jj|�}nWnJttjfk
rt}|jjdd�j�}td||��nX|r�|r�||j	�7}n|S(sN
        Decode the data passed in and potentially flush the decoder.
        scontent-encodingR.sEReceived response with content-encoding: %s, but failed to decode it.(
R>R tIOErrorRRR7RHRIRt_flush_decoder(RR$R5t
flush_decoderteRh((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pyt_decodescC@s0|jr,|jjd�}||jj�SdS(sk
        Flushes the decoder. Should only be called if the decoder is actually
        being used.
        R.(R>R tflush(Rtbuf((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pyRks	cc@st}z�y	dVWn�tk
r:t|jdd��nktk
ry}dt|�kra�nt|jdd��n,ttfk
r�}t	d||��nXt
}Wd|s�|jr�|jj�n|j
r�|j
j�q�n|jr|jj�r|j�nXdS(s�
        Catch low-level python exceptions, instead re-raising urllib3
        variants, so that low-level exceptions are not leaked in the
        high-level api.

        On exit, release the connection back to the pool.
        NsRead timed out.sread operation timed outsConnection broken: %r(R!t
SocketTimeoutRRDR"RtstrRtSocketErrorRRRAtcloseREtisclosedRY(Rt
clean_exitRm((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pyt_error_catcher!s(		

		cC@sY|j�|dkr"|j}n|jdkr5dSt}d}|j���|dkrr|jj�}t}nqt}|jj|�}|dkr�|r�|jj�t}|j	r�|j
dkr�t|j|j
��q�nWdQX|rU|jt
|�7_|j
dk	r+|j
t
|�8_
n|j|||�}|rU||_qUn|S(sP
        Similar to :meth:`httplib.HTTPResponse.read`, but with two additional
        parameters: ``decode_content`` and ``cache_content``.

        :param amt:
            How much of the content to read. If specified, caching is skipped
            because it doesn't make sense to cache partial content as the full
            response.

        :param decode_content:
            If True, will attempt to decode the body based on the
            'content-encoding' header.

        :param cache_content:
            If True, will save the returned data such that the same result is
            returned despite of the state of the underlying file object. This
            is useful if you want the ``.data`` property to continue working
            after having ``.read()`` the file object. (Overridden if ``amt`` is
            set.)
        Ni(iN(RiR"R5R@R!RwR/RRtR=RLR
RBRaRnR?(RtamtR5RZRlR$((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pyR/Zs4

	
!iicc@s}|jr=|j�r=xa|j|d|�D]}|Vq+Wn<x9t|j�sx|jd|d|�}|r@|Vq@q@WdS(s_
        A generator wrapper for the read() method. A call will block until
        ``amt`` bytes have been read from the connection or until the
        connection is closed.

        :param amt:
            How much of the content to read. The generator will return up to
            much data per iteration, but may return less. This is particularly
            likely when using compressed data. However, the empty string will
            never be returned.

        :param decode_content:
            If True, will attempt to decode the body based on the
            'content-encoding' header.
        R5RxN(R4tsupports_chunked_readstread_chunkedRR@R/(RRxR5tlineR$((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pytstream�scK@s�|j}t|t�sEtr3t|j��}qEtj|�}nt|dd�}|d|d|d|jd|jd|j	d|d||�}|S(	s
        Given an :class:`httplib.HTTPResponse` instance ``r``, return a
        corresponding :class:`urllib3.response.HTTPResponse` object.

        Remaining parameters are passed to the HTTPResponse constructor, along
        with ``original_response=r``.
        R;iRMR7R8R9R:RO(
tmsgR6RRtitemstfrom_httplibRR8R9R:(tResponseClstrtresponse_kwR7R;tresp((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pyR�s						cC@s|jS(N(R7(R((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pyt
getheaders�scC@s|jj||�S(N(R7RH(RRtdefault((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pyt	getheader�scC@s|jS(N(R7(R((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pytinfo�scC@s6|js|jj�n|jr2|jj�ndS(N(tclosedR@RtRE(R((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pyRt�s		cC@sV|jdkrtSt|jd�r2|jj�St|jd�rN|jjStSdS(NRuR�(R@R"RRFRuR�(R((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pyR��s

cC@sM|jdkrtd��n+t|jd�r=|jj�Std��dS(Ns-HTTPResponse has no file to get a fileno fromtfilenosOThe file-like object this HTTPResponse is wrapped around has no file descriptor(R@R"RjRFR�(R((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pyR��s

cC@s2|jdk	r.t|jd�r.|jj�SdS(NRo(R@R"RFRo(R((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pyRo�s!cC@stS(N(R(R((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pytreadablescC@sI|jt|��}t|�dkr+dS||t|�*t|�SdS(Ni(R/Ra(Rtbttemp((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pytreadintos
cC@st|jd�S(s�
        Checks if the underlying file-like object looks like a
        httplib.HTTPResponse object. We do this by testing for the fp
        attribute. If it is present we assume it returns raw chunks as
        processed by read_chunked().
        tfp(RFR@(R((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pyRyscC@s�|jdk	rdS|jjj�}|jdd�d}yt|d�|_Wn*tk
r}|j�t	j
|��nXdS(Nt;iii(RGR"R@R�treadlineRJR`RcRtthttplibR
(RR{((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pyt_update_chunk_lengths

cC@s�d}|dkrI|jj|j�}|}|jjd�d|_n�||jkr�|jj|�}|j||_|}nq||jkr�|jj|�}|jjd�d|_|}n.|jj|j�}|jjd�d|_|S(Ni(R"R@t
_safe_readRG(RRxtreturned_chunktchunktvalue((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pyt
_handle_chunk%s&				c
c@sT|j�|js"td��n|j�s=td��n|jrft|j�rf|jj�dS|j���x_t	r�|j
�|jdkr�Pn|j|�}|j
|d|dt�}|rv|VqvqvW|r�|j�}|r�|Vq�nx6t	r0|jjj�}|sPn|dkr�Pq�q�W|jrJ|jj�nWdQXdS(s�
        Similar to :meth:`HTTPResponse.read`, but with an additional
        parameter: ``decode_content``.

        :param decode_content:
            If True, will attempt to decode the body based on the
            'content-encoding' header.
        sHResponse is not chunked. Header 'transfer-encoding: chunked' is missing.sgBody should be httplib.HTTPResponse like. It should have have an fp attribute which returns raw chunks.NiR5Rls
(RiR4R	RyRRARRtRwRR�RGR�RnR!RkR@R�R�(RRxR5R�tdecodedR{((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pyRz;s@	
	

	
			Ni(&R&R't__doc__RgRVR"RR!RRWRYtpropertyR$RQR[RKRiRnRkRRwR/R|tclassmethodRR�R�R�RtR�R�RoR�R�RyR�R�Rz(((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pyR,LsB 		-	
				0	
		9E													(-t
__future__Rt
contextlibRRtiotloggingtsocketRRqRRst_collectionsRt
exceptionsRRRRR	R
Rtpackages.sixRRCR
Rtpackages.six.movesRR�RQRRt
util.responseRRt	getLoggerR&R]tobjectRR(R+tIOBaseR,(((s@/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.pyt<module>s"4!	

Hacked By AnonymousFox1.0, Coded By AnonymousFox