Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
contego / home / tvault / .virtenv / lib / python2.7 / site-packages / urllib3 / response.pyc
Size: Mime:
ó
èEYc@@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((sE/home/tvault/.virtenv/lib/python2.7/site-packages/urllib3/response.pyt__init__s	cC@st|j|ƒS(N(tgetattrR(Rtname((sE/home/tvault/.virtenv/lib/python2.7/site-packages/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((sE/home/tvault/.virtenv/lib/python2.7/site-packages/urllib3/response.pyR  s"			(t__name__t
__module__RRR (((sE/home/tvault/.virtenv/lib/python2.7/site-packages/urllib3/response.pyRs		tGzipDecodercB@s#eZd„Zd„Zd„ZRS(cC@stjdtjƒ|_dS(Ni(RRR#R(R((sE/home/tvault/.virtenv/lib/python2.7/site-packages/urllib3/response.pyR9scC@st|j|ƒS(N(RR(RR((sE/home/tvault/.virtenv/lib/python2.7/site-packages/urllib3/response.pyR<scC@s|s
|S|jj|ƒS(N(RR (RR$((sE/home/tvault/.virtenv/lib/python2.7/site-packages/urllib3/response.pyR ?s(R&R'RRR (((sE/home/tvault/.virtenv/lib/python2.7/site-packages/urllib3/response.pyR(7s		cC@s|dkrtƒStƒS(Ntgzip(R(R(tmode((sE/home/tvault/.virtenv/lib/python2.7/site-packages/urllib3/response.pyt_get_decoderEstHTTPResponsecB@syeZdZddgZdddddgZdd&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„Zed„ƒZd„Zd„Zd „Zd!„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((sE/home/tvault/.virtenv/lib/python2.7/site-packages/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((sE/home/tvault/.virtenv/lib/python2.7/site-packages/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((sE/home/tvault/.virtenv/lib/python2.7/site-packages/urllib3/response.pytget_redirect_location¡scC@s8|js|jrdS|jj|jƒd|_dS(N(RDREt	_put_connR"(R((sE/home/tvault/.virtenv/lib/python2.7/site-packages/urllib3/response.pytrelease_conn®scC@s-|jr|jS|jr)|jdtƒSdS(Nt
cache_content(R?R@R/R(R((sE/home/tvault/.virtenv/lib/python2.7/site-packages/urllib3/response.pyR$µs		cC@s|jS(N(RE(R((sE/home/tvault/.virtenv/lib/python2.7/site-packages/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((sE/home/tvault/.virtenv/lib/python2.7/site-packages/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((sE/home/tvault/.virtenv/lib/python2.7/site-packages/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((sE/home/tvault/.virtenv/lib/python2.7/site-packages/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((sE/home/tvault/.virtenv/lib/python2.7/site-packages/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((sE/home/tvault/.virtenv/lib/python2.7/site-packages/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((sE/home/tvault/.virtenv/lib/python2.7/site-packages/urllib3/response.pyt_error_catcher!s(		

		c	C@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$((sE/home/tvault/.virtenv/lib/python2.7/site-packages/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$((sE/home/tvault/.virtenv/lib/python2.7/site-packages/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((sE/home/tvault/.virtenv/lib/python2.7/site-packages/urllib3/response.pyR¹s						cC@s|jS(N(R7(R((sE/home/tvault/.virtenv/lib/python2.7/site-packages/urllib3/response.pyt
getheaders×scC@s|jj||ƒS(N(R7RH(RRtdefault((sE/home/tvault/.virtenv/lib/python2.7/site-packages/urllib3/response.pyt	getheaderÚscC@s6|js|jjƒn|jr2|jjƒndS(N(tclosedR@RtRE(R((sE/home/tvault/.virtenv/lib/python2.7/site-packages/urllib3/response.pyRtÞs		cC@sV|jdkrtSt|jdƒr2|jjƒSt|jdƒrN|jjStSdS(NRuR‡(R@R"RRFRuR‡(R((sE/home/tvault/.virtenv/lib/python2.7/site-packages/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((sE/home/tvault/.virtenv/lib/python2.7/site-packages/urllib3/response.pyRˆðs

cC@s2|jdk	r.t|jdƒr.|jjƒSdS(NRo(R@R"RFRo(R((sE/home/tvault/.virtenv/lib/python2.7/site-packages/urllib3/response.pyRoùs!cC@stS(N(R(R((sE/home/tvault/.virtenv/lib/python2.7/site-packages/urllib3/response.pytreadableýscC@sI|jt|ƒƒ}t|ƒdkr+dS||t|ƒ*t|ƒSdS(Ni(R/Ra(Rtbttemp((sE/home/tvault/.virtenv/lib/python2.7/site-packages/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((sE/home/tvault/.virtenv/lib/python2.7/site-packages/urllib3/response.pyRy
scC@s‚|jdk	rdS|jjjƒ}|jddƒd}yt|dƒ|_Wn*tk
r}|jƒt	j
|ƒ‚nXdS(Nt;iii(RGR"R@RtreadlineRJR`RcRtthttplibR
(RR{((sE/home/tvault/.virtenv/lib/python2.7/site-packages/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((sE/home/tvault/.virtenv/lib/python2.7/site-packages/urllib3/response.pyt
_handle_chunk!s&				cc@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{((sE/home/tvault/.virtenv/lib/python2.7/site-packages/urllib3/response.pyRz7s@	
	

	
			Ni(%R&R't__doc__RgRVR"RR!RRWRYtpropertyR$RQR[RKRiRnRkRRwR/R|tclassmethodRR„R†RtR‡RˆRoR‰RŒRyR‘R–Rz(((sE/home/tvault/.virtenv/lib/python2.7/site-packages/urllib3/response.pyR,Ls@ 		-	
				0	
		9E												(-t
__future__Rt
contextlibRRtiotloggingtsocketRRqRRst_collectionsRt
exceptionsRRRRR	R
Rtpackages.sixRRCR
Rtpackages.six.movesRRRQRRt
util.responseRRt	getLoggerR&R]tobjectRR(R+tIOBaseR,(((sE/home/tvault/.virtenv/lib/python2.7/site-packages/urllib3/response.pyt<module>s"4!