ó gP¾[c@s¥ddlZddlZddlZddlmZddlmZmZddl m Z ej e ƒZ defd„ƒYZd„Zd ejfd „ƒYZdS( iÿÿÿÿNi(t DecodeError(t string_typest binary_type(t is_fp_closedtDeflateDecodercBs#eZd„Zd„Zd„ZRS(cCs(t|_tƒ|_tjƒ|_dS(N(tTruet _first_tryRt_datatzlibt decompressobjt_obj(tself((s4/usr/lib/python2.7/dist-packages/urllib3/response.pyt__init__s  cCst|j|ƒS(N(tgetattrR (R tname((s4/usr/lib/python2.7/dist-packages/urllib3/response.pyt __getattr__scCs—|js|jj|ƒS|j|7_y|jj|ƒSWnTtjk r’t|_tjtj ƒ|_z|j|jƒSWdd|_XnXdS(N( RR t decompressRRterrortFalseR t MAX_WBITStNone(R tdata((s4/usr/lib/python2.7/dist-packages/urllib3/response.pyRs  (t__name__t __module__R RR(((s4/usr/lib/python2.7/dist-packages/urllib3/response.pyRs  cCs'|dkr tjdtjƒStƒS(Ntgzipi(RR RR(tmode((s4/usr/lib/python2.7/dist-packages/urllib3/response.pyt _get_decoder.s t HTTPResponsec BsòeZdZddgZdddddgZddd d dd eedddd „ Zd „Zd „Z e d „ƒZ dde d„Z ddd„Zed„ƒZd„Zdd„Zd„Ze d„ƒZd„Zd„Zd„ZRS(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. 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. Rtdeflatei-i.i/i3i4tic CsÔ|p i|_||_||_||_||_||_d|_|r`t|t ƒr`|nd|_ d|_ | |_ | |_ | |_t|dƒr¨||_ n|rÐ|j rÐ|jd|ƒ|_ ndS(Ntreadtdecode_content(theaderststatustversiontreasontstrictRRt_decodert isinstancet basestringt_bodyt_fpt_original_responset_poolt _connectionthasattrR( R tbodyR R!R"R#R$tpreload_contentRtoriginal_responsetpoolt connection((s4/usr/lib/python2.7/dist-packages/urllib3/response.pyR Os       $     cCs&|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(R!tREDIRECT_STATUSESR tgetR(R ((s4/usr/lib/python2.7/dist-packages/urllib3/response.pytget_redirect_locationgscCs8|j s|j rdS|jj|jƒd|_dS(N(R+R,t _put_connR(R ((s4/usr/lib/python2.7/dist-packages/urllib3/response.pyt release_conntscCs-|jr|jS|jr)|jdtƒSdS(Nt cache_content(R(R)RR(R ((s4/usr/lib/python2.7/dist-packages/urllib3/response.pyR{s  c CsÉ|jjddƒjƒ}|jdkrN||jkrNt|ƒ|_qNn|dkrf|j}n|jdkrydSt }z|dkr¦|jj ƒ}t }nAt }|jj |ƒ}|dkrç| rç|jj ƒt }ny(|r|jr|jj |ƒ}nWn/ttjfk r@}td||ƒ‚nX|r…|r…|jr…|jj tƒƒ}|||jjƒ7}n|r—||_n|SWd|jrÄ|jjƒrÄ|jƒnXdS(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.) scontent-encodingRNisEReceived response with content-encoding: %s, but failed to decode it.(R R5tlowerR%RtCONTENT_DECODERSRRR)RRRtcloseRtIOErrorRRRRtflushR(R*tisclosedR8( R tamtRR9tcontent_encodingt flush_decoderRtetbuf((s4/usr/lib/python2.7/dist-packages/urllib3/response.pyR„sD        iiccs@x9t|jƒs;|jd|d|ƒ}|r|VqqWdS(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. R@RN(RR)R(R R@RR((s4/usr/lib/python2.7/dist-packages/urllib3/response.pytstreamÐscKsµi}x]|jƒD]O\}}|jƒ}|j|ƒ}|rXdj||gƒ}n|||(R)RR-R>(R ((s4/usr/lib/python2.7/dist-packages/urllib3/response.pyR>(s!cCstS(N(R(R ((s4/usr/lib/python2.7/dist-packages/urllib3/response.pytreadable,sNi(RRt__doc__R;R4RRR R6R8tpropertyRRRREt classmethodRNRFRPR<RQRRR>RS(((s4/usr/lib/python2.7/dist-packages/urllib3/response.pyR5s&    L"    (tloggingRtiot exceptionsRtsixRR'RtutilRt getLoggerRtlogtobjectRRtIOBaseR(((s4/usr/lib/python2.7/dist-packages/urllib3/response.pyts