Warning: session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
3 ÝPfwYã@sddlmZddlmZddlZddlZddlZddlmZ ddlm Z ddl m Z ddlmZmZmZmZmZmZmZdd lmZmZmZdd lmZdd lmZm Z dd l!m"Z"m#Z#ej$e%ƒZ&Gd d„de'ƒZ(Gdd„de'ƒZ)dd„Z*Gdd„dej+ƒZ,dS)é)Úabsolute_import)ÚcontextmanagerN)Útimeout)Úerroré)ÚHTTPHeaderDict)ÚBodyNotHttplibCompatibleÚ ProtocolErrorÚ DecodeErrorÚReadTimeoutErrorÚResponseNotChunkedÚIncompleteReadÚ InvalidHeader)Ú string_typesÚ binary_typeÚPY3)Ú http_client)Ú HTTPExceptionÚ BaseSSLError)Ú is_fp_closedÚis_response_to_headc@s$eZdZdd„Zdd„Zdd„ZdS)ÚDeflateDecodercCsd|_tƒ|_tjƒ|_dS)NT)Ú _first_tryrÚ_dataÚzlibÚ decompressobjÚ_obj)Úself©rú/usr/lib/python3.6/response.pyÚ__init__szDeflateDecoder.__init__cCs t|j|ƒS)N)Úgetattrr)rÚnamerrrÚ __getattr__szDeflateDecoder.__getattr__cCs�|s|S|js|jj|ƒS|j|7_y |jj|ƒ}|rFd|_d|_|Stjk rŠd|_tjtj ƒ|_z |j|jƒSd|_XYnXdS)NF)rrÚ decompressrrrrÚ MAX_WBITS)rÚdataZ decompressedrrrr$ s"   zDeflateDecoder.decompressN)Ú__name__Ú __module__Ú __qualname__r r#r$rrrrrsrc@s$eZdZdd„Zdd„Zdd„ZdS)Ú GzipDecodercCstjdtjƒ|_dS)Né)rrr%r)rrrrr 9szGzipDecoder.__init__cCs t|j|ƒS)N)r!r)rr"rrrr#<szGzipDecoder.__getattr__cCs|s|S|jj|ƒS)N)rr$)rr&rrrr$?szGzipDecoder.decompressN)r'r(r)r r#r$rrrrr*7sr*cCs|dkrtƒStƒS)NÚgzip)r*r)ÚmoderrrÚ _get_decoderEsr.c@seZdZdZddgZdddddgZdFdd„Zdd„Zdd„Ze dd„ƒZ e dd„ƒZ dd„Z dd„Z dd„Zdd„Zd d!„Zed"d#„ƒZdGd$d%„ZdId(d)„Zed*d+„ƒZd,d-„ZdJd.d/„Zd0d1„Zd2d3„Ze d4d5„ƒZd6d7„Zd8d9„Zd:d;„Zdd?„Z d@dA„Z!dBdC„Z"dKdDdE„Z#d S)LÚ HTTPResponsea  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,Zdeflatei-i.i/i3i4ÚNrTFcCst|tƒr||_n t|ƒ|_||_||_||_||_||_| |_| |_ d|_ d|_ d|_ | |_ d|_|r|t|ttfƒr|||_ | |_| |_t|dƒr˜||_ d|_d|_|jjddƒjƒ}dd„|jdƒDƒ}d |krØd |_|j|ƒ|_|rþ|j rþ|j|d �|_ dS) NrÚreadFztransfer-encodingr0css|]}|jƒVqdS)N)Ústrip)Ú.0Úencrrrú –sz(HTTPResponse.__init__..ú,ÚchunkedT)Údecode_content)Ú isinstancerÚheadersÚstatusÚversionÚreasonÚstrictr8ÚretriesÚenforce_content_lengthÚ_decoderÚ_bodyÚ_fpÚ_original_responseÚ_fp_bytes_readÚ basestringrÚ_poolÚ _connectionÚhasattrr7Ú chunk_leftÚgetÚlowerÚsplitÚ _init_lengthÚlength_remainingr1)rÚbodyr:r;r<r=r>Zpreload_contentr8Úoriginal_responseZpoolÚ connectionr?r@Úrequest_methodZtr_encZ encodingsrrrr qs<     zHTTPResponse.__init__cCs|j|jkr|jjdƒSdS)a 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. ÚlocationF)r;ÚREDIRECT_STATUSESr:rK)rrrrÚget_redirect_location¡s  z"HTTPResponse.get_redirect_locationcCs,|j s|j rdS|jj|jƒd|_dS)N)rGrHZ _put_conn)rrrrÚ release_conn®szHTTPResponse.release_conncCs"|jr |jS|jr|jdd�SdS)NT)Ú cache_content)rBrCr1)rrrrr&µszHTTPResponse.datacCs|jS)N)rH)rrrrrR¾szHTTPResponse.connectioncCs|jS)zÛ 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). )rE)rrrrÚtellÂszHTTPResponse.tellcCsê|jjdƒ}|dk r(|jr(tjdƒdS|dk r’yâsz-HTTPResponse._init_length..r6rz8Content-Length contained multiple unmatching values (%s)réÌé0édéÈZHEAD)r]r^) r:rKr7ÚlogZwarningÚsetrMÚlenrÚpopÚ ValueErrorrZr;)rrSZlengthZlengthsr;rrrrNÊs,      (zHTTPResponse._init_lengthcCs4|jjddƒjƒ}|jdkr0||jkr0t|ƒ|_dS)z= Set-up the _decoder attribute if necessary. zcontent-encodingr0N)r:rKrLrAÚCONTENT_DECODERSr.)rÚcontent_encodingrrrÚ _init_decoderúszHTTPResponse._init_decodercCs|y|r|jr|jj|ƒ}WnHttjfk rb}z&|jjddƒjƒ}td||ƒ‚WYdd}~XnX|rx|rx||j ƒ7}|S)zN Decode the data passed in and potentially flush the decoder. zcontent-encodingr0zEReceived response with content-encoding: %s, but failed to decode it.N) rAr$ÚIOErrorrrr:rKrLr Ú_flush_decoder)rr&r8Ú flush_decoderÚergrrrÚ_decodes  zHTTPResponse._decodecCs$|jr |jjdƒ}||jjƒSdS)zk Flushes the decoder. Should only be called if the decoder is actually being used. ó)rAr$Úflush)rZbufrrrrjs zHTTPResponse._flush_decoderccsìd}z¤y dVWn�tk r2t|jddƒ‚Ynptk rn}z"dt|ƒkrP‚t|jddƒ‚WYdd}~Xn4ttfk r }ztd||ƒ‚WYdd}~XnXd}Wd|sÎ|jr¾|jj ƒ|j rÎ|j j ƒ|jræ|jj ƒræ|j ƒXdS)zç 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. FNzRead timed out.zread operation timed outzConnection broken: %rT) Ú SocketTimeoutr rGrÚstrrÚ SocketErrorr rDÚcloserHÚisclosedrW)rZ clean_exitrlrrrÚ_error_catcher!s(      zHTTPResponse._error_catcherc Csð|jƒ|dkr|j}|jdkr$dSd}d}|jƒ�h|dkrN|jjƒ}d}nJd}|jj|ƒ}|dkr˜| r˜|jjƒd}|jr˜|jdkr˜t|j |jƒ‚WdQRX|rì|j t |ƒ7_ |jdk rÔ|jt |ƒ8_|j |||ƒ}|rì||_ |S)aP 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.) NFTr)rN) rhr8rCrur1rsr@rOr rErcrmrB)rÚamtr8rXrkr&rrrr1Zs4      zHTTPResponse.readér+ccsZ|jr.|jƒr.xF|j||d�D] }|VqWn(x&t|jƒsT|j||d�}|r0|Vq0WdS)a_ 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. )r8)rvr8N)r7Úsupports_chunked_readsÚ read_chunkedrrCr1)rrvr8Úliner&rrrÚstreamŸs  zHTTPResponse.streamc Ks`|j}t|tƒs,tr"t|jƒƒ}n tj|ƒ}t|ddƒ}|f|||j|j|j ||dœ|—Ž}|S)a  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>r)rPr:r;r<r=r>rQ) Úmsgr9rrÚitemsÚ from_httplibr!r;r<r=)Z ResponseClsÚrZ response_kwr:r>Zresprrrr~¹s    zHTTPResponse.from_httplibcCs|jS)N)r:)rrrrÚ getheaders×szHTTPResponse.getheaderscCs|jj||ƒS)N)r:rK)rr"ÚdefaultrrrÚ getheaderÚszHTTPResponse.getheadercCs|jS)N)r:)rrrrÚinfoÞszHTTPResponse.infocCs$|js|jjƒ|jr |jjƒdS)N)ÚclosedrCrsrH)rrrrrsâs zHTTPResponse.closecCs@|jdkrdSt|jdƒr$|jjƒSt|jdƒr8|jjSdSdS)NTrtr„)rCrIrtr„)rrrrr„és    zHTTPResponse.closedcCs6|jdkrtdƒ‚nt|jdƒr*|jjƒStdƒ‚dS)Nz-HTTPResponse has no file to get a fileno fromÚfilenozOThe file-like object this HTTPResponse is wrapped around has no file descriptor)rCrirIr…)rrrrr…ôs     zHTTPResponse.filenocCs$|jdk r t|jdƒr |jjƒSdS)Nro)rCrIro)rrrrroýszHTTPResponse.flushcCsdS)NTr)rrrrÚreadableszHTTPResponse.readablecCs:|jt|ƒƒ}t|ƒdkrdS||dt|ƒ…<t|ƒSdS)Nr)r1rc)rÚbZtemprrrÚreadintos  zHTTPResponse.readintocCs t|jdƒS)zú 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(). Úfp)rIrC)rrrrrxsz#HTTPResponse.supports_chunked_readsc Csf|jdk rdS|jjjƒ}|jddƒd}yt|dƒ|_Wn&tk r`|jƒtj |ƒ‚YnXdS)Nó;rrr+) rJrCr‰ÚreadlinerMrZrersÚhttplibr )rrzrrrÚ_update_chunk_lengths  z!HTTPResponse._update_chunk_lengthcCs¬d}|dkr2|jj|jƒ}|}|jjdƒd|_nv||jkrZ|jj|ƒ}|j||_|}nN||jkrˆ|jj|ƒ}|jjdƒd|_|}n |jj|jƒ}|jjdƒd|_|S)Nrw)rCZ _safe_readrJ)rrvZreturned_chunkÚchunkÚvaluerrrÚ _handle_chunk%s&        zHTTPResponse._handle_chunkc csâ|jƒ|jstdƒ‚|jƒs&tdƒ‚|jrDt|jƒrD|jjƒdS|jƒ�Œx<|j ƒ|j dkrdP|j |ƒ}|j ||dd�}|rP|VqPW|r¢|j ƒ}|r¢|Vx |jjjƒ}|s¶P|dkr¤Pq¤W|jrÔ|jjƒWdQRXdS)zþ 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. zHResponse is not chunked. Header 'transfer-encoding: chunked' is missing.zgBody should be httplib.HTTPResponse like. It should have have an fp attribute which returns raw chunks.NrF)r8rks )rhr7r rxrrDrrsrur�rJr�rmrjrCr‰r‹)rrvr8rŽZdecodedrzrrrry;s@       zHTTPResponse.read_chunked)r0NrrNrTTNNNNFN)NNFé)r‘N)N)NN)$r'r(r)Ú__doc__rfrUr rVrWÚpropertyr&rRrYrNrhrmrjrrur1r{Ú classmethodr~r€r‚rƒrsr„r…ror†rˆrxr�r�ryrrrrr/LsB  -  0  9 E       r/)-Z __future__rÚ contextlibrrÚioZloggingZsocketrrprrrÚ _collectionsrÚ exceptionsrr r r r r rZ packages.sixrrFrrZpackages.six.movesrrŒrRrrZ util.responserrZ getLoggerr'raÚobjectrr*r.ÚIOBaser/rrrrÚs"     $  !