ok

Mini Shell

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

�
Bu�_c@@s�ddlmZddlmZddlZddlZddlZddlmZ	ddlm
ZyddlZWne
k
r�dZnXddlmZddlmZmZmZmZmZmZmZmZdd	lmZmZdd
lmZ ddl!m"Z"m#Z#ddl$m%Z%m&Z&ej'e(�Z)d
e*fd��YZ+de*fd��YZ,de*fd��YZ-edk	r�de*fd��YZ.nde*fd��YZ/d�Z0dej1fd��YZ2dS(i(tabsolute_import(tcontextmanagerN(ttimeout(terrori(tHTTPHeaderDict(tBodyNotHttplibCompatiblet
ProtocolErrortDecodeErrortReadTimeoutErrortResponseNotChunkedtIncompleteReadt
InvalidHeadert	HTTPError(tstring_typestPY3(thttp_client(t
HTTPExceptiontBaseSSLError(tis_fp_closedtis_response_to_headtDeflateDecodercB@s#eZd�Zd�Zd�ZRS(cC@s%t|_d|_tj�|_dS(Nt(tTruet
_first_tryt_datatzlibt
decompressobjt_obj(tself((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyt__init__"s		cC@st|j|�S(N(tgetattrR(Rtname((sM/opt/alt/python36/lib/python3.6/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((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyR!*s"			(t__name__t
__module__RR R!(((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyR!s		tGzipDecoderStatecB@seZdZdZdZRS(iii(R'R(tFIRST_MEMBERt
OTHER_MEMBERStSWALLOW_DATA(((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyR)AstGzipDecodercB@s#eZd�Zd�Zd�ZRS(cC@s)tjdtj�|_tj|_dS(Ni(RRR$RR)R*t_state(R((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyRIscC@st|j|�S(N(RR(RR((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyR MscC@s�t�}|jtjks"|r,t|�Sx�tr�y||jj|�7}WnEtj	k
r�|j}tj|_|tj
kr�t|�S�nX|jj}|s�t|�Stj
|_tjdtj
�|_q/WdS(Ni(t	bytearrayR.R)R,tbytesRRR!RRR+tunused_dataRR$(RR%trettprevious_state((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyR!Ps"	
		

(R'R(RR R!(((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyR-Hs		t
BrotliDecodercB@s#eZd�Zd�Zd�ZRS(cC@stj�|_dS(N(tbrotlitDecompressorR(R((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyRlscC@s2t|jd�r"|jj|�S|jj|�S(NR!(thasattrRR!tprocess(RR%((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyR!oscC@s#t|jd�r|jj�SdS(NtflushR(R7RR9(R((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyR9ts
(R'R(RR!R9(((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyR4hs		tMultiDecodercB@s)eZdZd�Zd�Zd�ZRS(s
    From RFC7231:
        If one or more encodings have been applied to a representation, the
        sender that applied the encodings MUST generate a Content-Encoding
        header field that lists the content codings in the order in which
        they were applied.
    cC@s5g|jd�D]}t|j��^q|_dS(Nt,(tsplitt_get_decodertstript	_decoders(Rtmodestm((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyR�scC@s|jdj�S(Ni(R?R9(R((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyR9�scC@s-x&t|j�D]}|j|�}qW|S(N(treversedR?R!(RR%td((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyR!�s(R'R(t__doc__RR9R!(((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyR:zs		cC@sOd|krt|�S|dkr)t�Stdk	rH|dkrHt�St�S(NR;tgziptbr(R:R-R5R#R4R(tmode((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyR=�s
tHTTPResponsecB@s�eZdZddgZed,k	r4edg7ZndddddgZd	d,d
d
d,d
eed,d,d,d,d,ed,d,ed�Z	d�Z
d
�Zd�Ze
d��Ze
d��Zd�Zd�Zd�Zd�ZeejfZed,k	reejf7Znd�Zd�Zed��Zd,d,ed�Zd-d,d�Zed��Zd�Z d,d�Z!d�Z"d �Z#e
d!��Z$d"�Z%d#�Z&d$�Z'd%�Z(d&�Z)d'�Z*d(�Z+d,d,d)�Z,d*�Z-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, will attempt to decode the body based on the
        'content-encoding' header.

    :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.
    REtdeflateRFi-i.i/i3i4RicC@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|krct|_n|j|�|_ |r�|j
r�|j!d|�|_
ndS(	Nitreadstransfer-encodingRcs@s|]}|j�VqdS(N(R>(t.0tenc((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pys	<genexpr>�sR;tchunkedtdecode_content("t
isinstanceRtheaderststatustversiontreasontstrictRNtretriestenforce_content_lengtht
auto_closeR#t_decodert_bodyt_fpt_original_responset_fp_bytes_readtmsgt_request_urlt
basestringR0t_poolt_connectionR7R"RMt
chunk_lefttgettlowerR<Rt_init_lengthtlength_remainingRJ(RtbodyRPRQRRRSRTtpreload_contentRNtoriginal_responsetpoolt
connectionR]RURVtrequest_methodtrequest_urlRWttr_enct	encodings((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyR�sB																			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(RQtREDIRECT_STATUSESRPRcR"(R((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pytget_redirect_locationscC@s8|js|jrdS|jj|j�d|_dS(N(R`Rat	_put_connR#(R((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pytrelease_connscC@s2y|j�Wnttttfk
r-nXdS(s�
        Read and discard any remaining HTTP response data in the response connection.

        Unread data in the HTTPResponse connection blocks the connection from being released back to the pool.
        N(RJRtSocketErrorRR(R((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyt
drain_connscC@s-|jr|jS|jr)|jdt�SdS(Nt
cache_content(RYRZRJR(R((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyR%$s		cC@s|jS(N(Ra(R((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyRk-scC@s
t|j�S(N(RRZ(R((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pytisclosed1scC@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).
        (R\(R((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyttell4scC@s;|jjd�}|dk	r�|jr8tjd�dSyctg|jd�D]}t|�^qN�}t	|�dkr�t
d|��n|j�}Wntk
r�d}q�X|dkr�d}q�nyt|j
�}Wntk
r�d}nX|d
ks.d	|kod
kns.|dkr7d}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.R;is8Content-Length contained multiple unmatching values (%s)ii�i0idi�tHEADN(i�i0(RPRcR#RMtlogtwarningtsetR<tinttlenRtpopt
ValueErrorRQ(RRltlengthtvaltlengthsRQ((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyRe<s0	.




4	cC@s�|jjdd�j�}|jdkr�||jkrKt|�|_q�d|kr�g|jd�D]'}|j�|jkrg|j�^qg}t	|�r�t|�|_q�q�ndS(s=
        Set-up the _decoder attribute if necessary.
        scontent-encodingRR;N(
RPRcRdRXR#tCONTENT_DECODERSR=R<R>R(Rtcontent_encodingteRo((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyt
_init_decoderps'cC@s�|s
|Sy"|jr+|jj|�}nWnD|jk
rr}|jjdd�j�}td||��nX|r�||j�7}n|S(sN
        Decode the data passed in and potentially flush the decoder.
        scontent-encodingRsEReceived response with content-encoding: %s, but failed to decode it.(RXR!tDECODER_ERROR_CLASSESRPRcRdRt_flush_decoder(RR%RNt
flush_decoderR�R�((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyt_decode�s	
cC@s0|jr,|jjd�}||jj�SdS(sk
        Flushes the decoder. Should only be called if the decoder is actually
        being used.
        R(RXR!R9(Rtbuf((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyR��s	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
SocketTimeoutRR`R#RtstrRRuRRR[tcloseRaRxRt(Rt
clean_exitR�((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyt_error_catcher�s(		

		c	C@s�|j�|dkr"|j}n|jdkr5dSt}t|jdt�}|j���|dkr�|s~|jj�nd}t}n}t}|s�|jj|�nd}|dkr
|r
|jj	�t}|j
r
|jdkr
t|j
|j��q
nWdQX|r||j
t|�7_
|jdk	rR|jt|�8_n|j|||�}|r|||_q|n|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.)
        NtclosedRi(iN(R�R#RNRZR"RR�RJRR�RVRfR
R\RR�RY(RtamtRNRwR�t	fp_closedR%((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyRJ�s8

		
	!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.
        RNR�N(RMtsupports_chunked_readstread_chunkedRRZRJ(RR�RNtlineR%((sM/opt/alt/python36/lib/python3.6/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``.
        RTiRgRPRQRRRSRi(
R]RORRtitemstfrom_httplibRRQRRRS(tResponseClstrtresponse_kwRPRTtresp((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyR�Es 						cC@s|jS(N(RP(R((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyt
getheadersfscC@s|jj||�S(N(RPRc(RRtdefault((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyt	getheaderiscC@s|jS(N(RP(R((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pytinfomscC@sR|js|jj�n|jr2|jj�n|jsNtjj|�ndS(N(R�RZR�RaRWtiotIOBase(R((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyR�qs			cC@sr|jstjjj|�S|jdkr/tSt|jd�rN|jj	�St|jd�rj|jjStSdS(NRxR�(
RWR�R�R�t__get__RZR#RR7Rx(R((sM/opt/alt/python36/lib/python3.6/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(RZR#tIOErrorR7R�(R((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyR��s
cC@sH|jdk	rDt|jd�rDt|jdt�rD|jj�SdS(NR9R�(RZR#R7RR"R9(R((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyR9�scC@stS(N(R(R((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pytreadable�scC@sI|jt|��}t|�dkr+dS||t|�*t|�SdS(Ni(RJR(Rtbttemp((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pytreadinto�s
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(R7RZ(R((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyR��scC@s�|jdk	rdS|jjj�}|jdd�d}yt|d�|_Wn*tk
r}|j�t	j
|��nXdS(Nt;iii(RbR#RZR�treadlineR<R~R�R�thttplibR
(RR�((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyt_update_chunk_length�s

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#RZt
_safe_readRb(RR�treturned_chunktchunktvalue((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyt
_handle_chunk�s&				cc@sj|j�|js"td��n|j�s=td��n|j��|jrst|j�rs|jj�dS|j	j
dkr�dSx_tr�|j
�|jdkr�Pn|j|�}|j|d|dt�}|r�|Vq�q�W|r|j�}|r|Vqnx6trF|j	j
j�}|s3Pn|dkrPqqW|jr`|jj�nWdQXdS(s�
        Similar to :meth:`HTTPResponse.read`, but with an additional
        parameter: ``decode_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.
        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.NiRNR�s
(R�RMR	R�RR�R[RR�RZR�R#RR�RbR�R�R"R�R�(RR�RNR�tdecodedR�((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyR��sD
	

	
		cC@s=|jdk	r2t|jj�r2|jjdjS|jSdS(s�
        Returns the URL that was the source of this response.
        If the request that generated this response redirected, this method
        will return the final redirect location.
        i����N(RUR#Rthistorytredirect_locationR^(R((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pytgeturls!cc@s�g}x�|jdt�D]�}d|kr�|jd�}dj|�|ddVx|dd!D]}|dVqbW|dr�|dg}q�g}q|j|�qW|r�dj|�VndS(NRNs
Riii����(R�RR<tjointappend(RtbufferR�tx((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyt__iter__&s

	Ni(/R'R(RDR�R5R#RqRR"RRrRtRvtpropertyR%RkRxRyReR�R�RRR�R�R�RR�RJR�tclassmethodR�R�R�R�R�R�R�R9R�R�R�R�R�R�R�R�(((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyRH�sn1	
						4			9J!			

									F	(3t
__future__Rt
contextlibRRR�tloggingtsocketRR�RRuR5tImportErrorR#t_collectionsRt
exceptionsRRRRR	R
RRtpackages.sixR
R_Rtpackages.six.movesRR�RkRRt
util.responseRRt	getLoggerR'R{tobjectRR)R-R4R:R=R�RH(((sM/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/response.pyt<module>s2

:
 	

Zerion Mini Shell 1.0