ž 7’Rek(c@sΈddlZddlZddlZddlmZddlmZddlmZ m Z ddl m Z ej eƒZGdd„deƒZd d „ZGd d „d ejƒZdS( iNi(uHTTPHeaderDict(u DecodeError(u string_typesu binary_type(u is_fp_closedcBs8|EeZdZdd„Zdd„Zdd„ZdS(uDeflateDecodercCs(d|_tƒ|_tjƒ|_dS(NT(uTrueu _first_tryu binary_typeu_datauzlibu decompressobju_obj(uself((uG/tmp/pip-zej_zi-build/pip/_vendor/requests/packages/urllib3/response.pyu__init__s  uDeflateDecoder.__init__cCst|j|ƒS(N(ugetattru_obj(uselfuname((uG/tmp/pip-zej_zi-build/pip/_vendor/requests/packages/urllib3/response.pyu __getattr__suDeflateDecoder.__getattr__cCs˜|js|jj|ƒS|j|7_y|jj|ƒSWnUtjk r“d|_tjtj ƒ|_z|j|jƒSWdd|_XYnXdS(NF( u _first_tryu_obju decompressu_datauzlibuerroruFalseu decompressobju MAX_WBITSuNone(uselfudata((uG/tmp/pip-zej_zi-build/pip/_vendor/requests/packages/urllib3/response.pyu decompresss  uDeflateDecoder.decompressN(u__name__u __module__u __qualname__u__init__u __getattr__u decompress(u __locals__((uG/tmp/pip-zej_zi-build/pip/_vendor/requests/packages/urllib3/response.pyuDeflateDecoders  uDeflateDecodercCs'|dkr tjdtjƒStƒS(Nugzipi(uzlibu decompressobju MAX_WBITSuDeflateDecoder(umode((uG/tmp/pip-zej_zi-build/pip/_vendor/requests/packages/urllib3/response.pyu _get_decoder/s u _get_decoderc Bs4|EeZdZdZddgZdddddgZd d+d d d+d d,d,d+d+d+d d „ Zd d„Z dd„Z e dd„ƒZ dd„Z d+d+d-dd„Zd.d+dd„Zedd„ƒZdd„Zd+dd „Zd!d"„Ze d#d$„ƒZd%d&„Zd'd(„Zd)d*„Zd+S(/u HTTPResponseu 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. ugzipudeflatei-i.i/i3i4uic Csσtƒ|_|r%|jj|ƒn||_||_||_||_||_d|_ |rvt |t ƒrv|nd|_ d|_ | |_d|_| |_| |_t|dƒrΗ||_ n|rο|j rο|jd|ƒ|_ ndS(Niureadudecode_content(uHTTPHeaderDictuheadersuupdateustatusuversionureasonustrictudecode_contentuNoneu_decoderu isinstanceu basestringu_bodyu_fpu_original_responseu_fp_bytes_readu_poolu _connectionuhasattruread( uselfubodyuheadersustatusuversionureasonustrictupreload_contentudecode_contentuoriginal_responseupoolu connection((uG/tmp/pip-zej_zi-build/pip/_vendor/requests/packages/urllib3/response.pyu__init__Ps&       $      uHTTPResponse.__init__cCs&|j|jkr"|jjdƒSdS(u 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. ulocationF(ustatusuREDIRECT_STATUSESuheadersugetuFalse(uself((uG/tmp/pip-zej_zi-build/pip/_vendor/requests/packages/urllib3/response.pyuget_redirect_locationlsu"HTTPResponse.get_redirect_locationcCs8|j s|j rdS|jj|jƒd|_dS(N(u_poolu _connectionu _put_connuNone(uself((uG/tmp/pip-zej_zi-build/pip/_vendor/requests/packages/urllib3/response.pyu release_connysuHTTPResponse.release_conncCs-|jr|jS|jr)|jddƒSdS(Nu cache_contentT(u_bodyu_fpureaduTrue(uself((uG/tmp/pip-zej_zi-build/pip/_vendor/requests/packages/urllib3/response.pyudata€s  uHTTPResponse.datacCs|jS(uΫ 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). (u_fp_bytes_read(uself((uG/tmp/pip-zej_zi-build/pip/_vendor/requests/packages/urllib3/response.pyutell‰suHTTPResponse.tellc Csπ|jjddƒjƒ}|jdkrN||jkrNt|ƒ|_qNn|dkrf|j}n|jdkrydSd}zD|dkr¦|jj ƒ}d}nAd}|jj |ƒ}|dkrη| rη|jj ƒd}n|j t|ƒ7_ y(|r#|jr#|jj|ƒ}nWnAttjfk rg}ztd||ƒ‚WYdd}~XnX|r¬|r¬|jr¬|jjtƒƒ}|||jjƒ7}n|rΎ||_n|SWd|jrλ|jjƒrλ|jƒnXdS(uP 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.) ucontent-encodinguNiuEReceived response with content-encoding: %s, but failed to decode it.FT(uheadersugetuloweru_decoderuNoneuCONTENT_DECODERSu _get_decoderudecode_contentu_fpuFalseureaduTrueucloseu_fp_bytes_readulenu decompressuIOErroruzlibuerroru DecodeErroru binary_typeuflushu_bodyu_original_responseuisclosedu release_conn( uselfuamtudecode_contentu cache_contentucontent_encodingu flush_decoderudataueubuf((uG/tmp/pip-zej_zi-build/pip/_vendor/requests/packages/urllib3/response.pyuread‘sF       uHTTPResponse.readiiccs@x9t|jƒs;|jd|d|ƒ}|r|VqqWdS(u_ 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. uamtudecode_contentN(u is_fp_closedu_fpuread(uselfuamtudecode_contentudata((uG/tmp/pip-zej_zi-build/pip/_vendor/requests/packages/urllib3/response.pyustreamίsuHTTPResponse.streamcKs…tƒ}x*|jƒD]\}}|j||ƒqWt|ddƒ}|d|d|d|jd|jd|jd|d||S( u  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``. ustrictiubodyuheadersustatusuversionureasonuoriginal_response(uHTTPHeaderDictu getheadersuaddugetattrustatusuversionureason(u ResponseClsuru response_kwuheadersukuvustrict((uG/tmp/pip-zej_zi-build/pip/_vendor/requests/packages/urllib3/response.pyu from_httplibφs     uHTTPResponse.from_httplibcCs|jS(N(uheaders(uself((uG/tmp/pip-zej_zi-build/pip/_vendor/requests/packages/urllib3/response.pyu getheaderssuHTTPResponse.getheaderscCs|jj||ƒS(N(uheadersuget(uselfunameudefault((uG/tmp/pip-zej_zi-build/pip/_vendor/requests/packages/urllib3/response.pyu getheadersuHTTPResponse.getheadercCs|js|jjƒndS(N(uclosedu_fpuclose(uself((uG/tmp/pip-zej_zi-build/pip/_vendor/requests/packages/urllib3/response.pyucloses uHTTPResponse.closecCsV|jdkrdSt|jdƒr/|jjSt|jdƒrN|jjƒSdSdS(NucloseduisclosedT(u_fpuNoneuTrueuhasattrucloseduisclosed(uself((uG/tmp/pip-zej_zi-build/pip/_vendor/requests/packages/urllib3/response.pyucloseds  uHTTPResponse.closedcCsM|jdkrtdƒ‚n+t|jdƒr=|jjƒStdƒ‚dS(Nu-HTTPResponse has no file to get a fileno fromufilenouPThe file-like object this HTTPResponse is wrapped around has no file descriptor(u_fpuNoneuIOErroruhasattrufileno(uself((uG/tmp/pip-zej_zi-build/pip/_vendor/requests/packages/urllib3/response.pyufileno&s  uHTTPResponse.filenocCs2|jdk r.t|jdƒr.|jjƒSdS(Nuflush(u_fpuNoneuhasattruflush(uself((uG/tmp/pip-zej_zi-build/pip/_vendor/requests/packages/urllib3/response.pyuflush/s!uHTTPResponse.flushcCsdS(NT(uTrue(uself((uG/tmp/pip-zej_zi-build/pip/_vendor/requests/packages/urllib3/response.pyureadable3suHTTPResponse.readableNTFi(u__name__u __module__u __qualname__u__doc__uCONTENT_DECODERSuREDIRECT_STATUSESuNoneuTrueu__init__uget_redirect_locationu release_connupropertyudatautelluFalseureadustreamu classmethodu from_httplibu getheadersu getheaderucloseuclosedufilenouflushureadable(u __locals__((uG/tmp/pip-zej_zi-build/pip/_vendor/requests/packages/urllib3/response.pyu HTTPResponse6s(    N   u HTTPResponse(ulogginguzlibuiou _collectionsuHTTPHeaderDictu exceptionsu DecodeErroru packages.sixu string_typesu basestringu binary_typeuutilu is_fp_closedu getLoggeru__name__uloguobjectuDeflateDecoderu _get_decoderuIOBaseu HTTPResponse(((uG/tmp/pip-zej_zi-build/pip/_vendor/requests/packages/urllib3/response.pyus