Files
old-nlp/venv/lib/python3.7/site-packages/urllib3/__pycache__/response.cpython-37.pyc

232 lines
20 KiB
Plaintext
Raw Normal View History

2019-10-20 13:16:49 +02:00
B
U%<25>]<5D>l<00>@s\ddlmZddlmZddlZddlZddlZddlmZ ddlm
Z y ddl Z Wne k
rldZ YnXddlmZddlmZmZmZmZmZmZmZdd lmZmZdd
lmZdd lm Z m!Z!dd l"m#Z#m$Z$e<06>%e&<26>Z'Gd d<0E>de(<28>Z)Gdd<10>de(<28>Z*Gdd<12>de(<28>Z+e dk <09>r.Gdd<14>de(<28>Z,Gdd<16>de(<28>Z-dd<18>Z.Gdd<1A>dej/<2F>Z0dS)<1B>)<01>absolute_import)<01>contextmanagerN)<01>timeout)<01>error<6F>)<01>HTTPHeaderDict)<07>BodyNotHttplibCompatible<6C> ProtocolError<6F> DecodeError<6F>ReadTimeoutError<6F>ResponseNotChunked<65>IncompleteRead<61> InvalidHeader)<02> string_types<65>PY3)<01> http_client)<02> HTTPException<6F> BaseSSLError)<02> is_fp_closed<65>is_response_to_headc@s$eZdZdd<02>Zdd<04>Zdd<06>ZdS)<08>DeflateDecodercCsd|_d|_t<02><03>|_dS)NT<4E>)<05>
_first_try<EFBFBD>_data<74>zlib<69> decompressobj<62>_obj)<01>self<6C>r<00>5/tmp/pip-install-_zqls8j0/urllib3/urllib3/response.py<70>__init__!szDeflateDecoder.__init__cCs t|j|<01>S)N)<02>getattrr)r<00>namerrr<00> __getattr__&szDeflateDecoder.__getattr__c Cs<>|s|S|js|j<01>|<01>S|j|7_y |j<01>|<01>}|rFd|_d|_|Stjk
r<EFBFBD>d|_t<04>tj <00>|_z |<00>|j<03>Sd|_XYnXdS)NF)rr<00>
decompressrrrr<00> MAX_WBITS)r<00>data<74> decompressedrrrr$)s"   zDeflateDecoder.decompressN)<06>__name__<5F>
__module__<EFBFBD> __qualname__r r#r$rrrrr src@seZdZdZdZdZdS)<05>GzipDecoderStaterr<00>N)r(r)r*<00> FIRST_MEMBER<45> OTHER_MEMBERS<52> SWALLOW_DATArrrrr+@sr+c@s$eZdZdd<02>Zdd<04>Zdd<06>ZdS)<08> GzipDecodercCst<00>dtj<00>|_tj|_dS)N<>)rrr%rr+r-<00>_state)rrrrr HszGzipDecoder.__init__cCs t|j|<01>S)N)r!r)rr"rrrr#LszGzipDecoder.__getattr__cCs<>t<00>}|jtjks|st|<02>Sx<>y||j<05>|<01>7}Wn8tjk
rl|j}tj|_|tj krft|<02>S<00>YnX|jj
}|s<>t|<02>Stj |_t<07> dtj <00>|_q WdS)Nr1) <0A> bytearrayr2r+r/<00>bytesrr$rrr.<00> unused_datarr%)rr&<00>ret<65>previous_staterrrr$Os"
zGzipDecoder.decompressN)r(r)r*r r#r$rrrrr0Gsr0c@s$eZdZdd<02>Zdd<04>Zdd<06>ZdS)<08> BrotliDecodercCst<00><01>|_dS)N)<03>brotliZ Decompressorr)rrrrr kszBrotliDecoder.__init__cCs$t|jd<01>r|j<01>|<01>S|j<01>|<01>S)Nr$)<04>hasattrrr$<00>process)rr&rrrr$ns  zBrotliDecoder.decompresscCst|jd<01>r|j<01><02>SdS)N<>flushr)r:rr<)rrrrr<ss 
zBrotliDecoder.flushN)r(r)r*r r$r<rrrrr8gsr8c@s(eZdZdZdd<03>Zdd<05>Zdd<07>ZdS) <09> MultiDecodera
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.
cCsdd<02>|<01>d<03>D<00>|_dS)NcSsg|]}t|<01><01><00><01>qSr)<02> _get_decoder<65>strip)<02>.0<EFBFBD>mrrr<00>
<listcomp><3E>sz)MultiDecoder.__init__.<locals>.<listcomp><3E>,)<02>split<69> _decoders)r<00>modesrrrr <00>szMultiDecoder.__init__cCs|jd<00><01>S)Nr)rEr<)rrrrr<<00>szMultiDecoder.flushcCs"xt|j<01>D]}|<02>|<01>}q W|S)N)<03>reversedrEr$)rr&<00>drrrr$<00>szMultiDecoder.decompressN)r(r)r*<00>__doc__r r<r$rrrrr=ysr=cCs:d|krt|<00>S|dkrt<01>Stdk r4|dkr4t<03>St<04>S)NrC<00>gzip<69>br)r=r0r9r8r)<01>moderrrr><00>sr>c@sdeZdZdZddgZedk r&edg7Zdddd d
gZdLdd<10>Zdd<12>Zdd<14>Z e
dd<16><00>Z e
dd<18><00>Z dd<1A>Z dd<1C>Zdd<1E>Zdd <20>ZeejfZedk r<>eejf7Zd!d"<22>Zd#d$<24>Zed%d&<26><00>ZdMd'd(<28>ZdNd*d+<2B>Zed,d-<2D><00>Zd.d/<2F>ZdOd0d1<64>Zd2d3<64>Zd4d5<64>Z e
d6d7<EFBFBD><00>Z!d8d9<64>Z"d:d;<3B>Z#d<d=<3D>Z$d>d?<3F>Z%d@dA<64>Z&dBdC<64>Z'dDdE<64>Z(dPdFdG<64>Z)dHdI<64>Z*dJdK<64>Z+dS)Q<> HTTPResponsea<65>
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.
rJ<00>deflateNrKi-i.i/i3i4<00>rTFcCst|t<01>r||_n
t|<02>|_||_||_||_||_||_| |_||_ ||_
d|_ d|_ d|_ | |_d|_| |_||_|r<>t|ttf<02>r<>||_ |
|_| |_t|d<02>r<>||_ d|_d|_|j<02>dd<05><02><1A>}dd<07>|<12>d<08>D<00>}d |kr<>d
|_|<00>|<0F>|_|<07>r|j <0C>s|j|d <0B>|_ dS) Nr<00>readFztransfer-encodingrOcss|]}|<01><00>VqdS)N)r?)r@<00>encrrr<00> <genexpr><3E>sz(HTTPResponse.__init__.<locals>.<genexpr>rC<00>chunkedT)<01>decode_content)<1F>
isinstancer<00>headers<72>status<75>version<6F>reason<6F>strictrT<00>retries<65>enforce_content_length<74>
auto_close<EFBFBD>_decoder<65>_body<64>_fp<66>_original_response<73>_fp_bytes_read<61>msg<73> _request_url<72>
basestringr4<00>_pool<6F> _connectionr:rS<00>
chunk_left<EFBFBD>get<65>lowerrD<00> _init_length<74>length_remainingrP)r<00>bodyrVrWrXrYrZ<00>preload_contentrT<00>original_response<73>pool<6F>
connectionrcr[r\<00>request_method<6F> request_urlr]<00>tr_enc<6E> encodingsrrrr <00>sB


 zHTTPResponse.__init__cCs|j|jkr|j<02>d<01>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.
<20>locationF)rW<00>REDIRECT_STATUSESrVri)rrrr<00>get_redirect_locations  z"HTTPResponse.get_redirect_locationcCs(|jr |jsdS|j<00>|j<01>d|_dS)N)rfrg<00> _put_conn)rrrr<00> release_conns zHTTPResponse.release_conncCs"|jr |jS|jr|jdd<02>SdS)NT)<01> cache_content)r_r`rP)rrrrr&szHTTPResponse.datacCs|jS)N)rg)rrrrrq!szHTTPResponse.connectioncCs
t|j<01>S)N)rr`)rrrr<00>isclosed%szHTTPResponse.isclosedcCs|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).
)rb)rrrr<00>tell(szHTTPResponse.tellcCs<>|j<00>d<01>}|dk r<>|jr(t<03>d<03>dSy<tdd<05>|<02>d<06>D<00><01>}t|<03>dkrZtd|<00><01>|<03> <09>}Wnt
k
r|d}YnX|d kr<>d}yt |j <0C>}Wnt
k
r<EFBFBD>d }YnX|d
ks<>d |kr<>d ks<>n|d kr<>d }|S)zM
Set initial length value for Response content if available.
zcontent-lengthNz<4E>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.cSsg|] }t|<01><01>qSr)<01>int)r@<00>valrrrrBJsz-HTTPResponse._init_length.<locals>.<listcomp>rCrz8Content-Length contained multiple unmatching values (%s)r)<02><>i0<00>d<00><><00>HEAD) rVrirS<00>log<6F>warning<6E>setrD<00>lenr<00>pop<6F>
ValueErrorr~rW)rrr<00>length<74>lengthsrWrrrrk0s0   

&zHTTPResponse._init_lengthcsh<00>j<00>dd<02><02><02>}<01>jdkrd|<01>jkr2t|<01><01>_n2d|krd<72>fdd<06>|<01>d<04>D<00>}t|<02>rdt|<01><01>_dS)z=
Set-up the _decoder attribute if necessary.
zcontent-encodingrONrCcs"g|]}|<01><00><00>jkr|<01><00><00>qSr)r?<00>CONTENT_DECODERS)r@<00>e)rrrrBpsz.HTTPResponse._init_decoder.<locals>.<listcomp>)rVrirjr^r<>r>rDr<>)r<00>content_encodingrur)rr<00> _init_decoderds

 
zHTTPResponse._init_decoderc
Csx|s|Sy|jr|j<00>|<01>}WnD|jk
rb}z$|j<03>dd<02><02><05>}td||<04><02>Wdd}~XYnX|rt||<00><07>7}|S)zN
Decode the data passed in and potentially flush the decoder.
zcontent-encodingrOzEReceived response with content-encoding: %s, but failed to decode it.N)r^r$<00>DECODER_ERROR_CLASSESrVrirjr
<00>_flush_decoder)rr&rT<00> flush_decoderr<72>r<>rrr<00>_decode{s zHTTPResponse._decodecCs$|jr |j<00>d<01>}||j<00><02>SdS)zk
Flushes the decoder. Should only be called if the decoder is actually
being used.
r)r^r$r<)r<00>bufrrrr<><00>s zHTTPResponse._flush_decoderc
cs<>d}z<>y
dVWn<>tk
r2t|jdd<03><03>Ynptk
rn}z dt|<02>krP<72>t|jdd<03><03>Wdd}~XYn4ttfk
r<EFBFBD>}ztd||<02><02>Wdd}~XYnXd}Wd|s<>|jr<>|j<08> <09>|j
r<EFBFBD>|j
<EFBFBD> <09>|jr<>|j<08> <0B>r<>|<00> <0C>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) <0A> SocketTimeoutr rfr<00>strr<00> SocketErrorr ra<00>closergr|rz)r<00>
clean_exitr<EFBFBD>rrr<00>_error_catcher<65>s( 
  

zHTTPResponse._error_catcherc Cs |<00><00>|dkr|j}|jdkr$dSd}t|jdd<02>}|<00><04><00>v|dkr`|sV|j<02><05>nd}d}nPd}|st|j<02>|<01>nd}|dkr<>|s<>|j<02><06>d}|jr<>|jdkr<>t |j
|j<08><02>WdQRX|<06>r|j
t |<06>7_
|jdk r<>|jt |<06>8_|<00> |||<04>}|<03>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.)
NF<4E>closedrTr)rN)r<>rTr`r!r<>rPr<>r\rlr rbr<>r<>r_)r<00>amtrTr{r<><00> fp_closedr&rrrrP<00>s6




zHTTPResponse.read<61>ccsZ|jr.|<00><01>r.xF|j||d<01>D]
}|VqWn(x&t|j<04>sT|j||d<02>}|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.
)rT)r<>rTN)rS<00>supports_chunked_reads<64> read_chunkedrr`rP)rr<>rT<00>liner&rrr<00>streams  zHTTPResponse.streamc
Ks`|j}t|t<02>s,tr"t|<03><04><00>}n
t<02>|<03>}t|dd<02>}|f|||j|j|j ||d<03>|<02><02>}|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``.
rZr)rmrVrWrXrYrZro)
rcrUrr<00>items<6D> from_httplibr!rWrXrY)<06> ResponseCls<6C>r<> response_kwrVrZ<00>resprrrr<>9s 

 zHTTPResponse.from_httplibcCs|jS)N)rV)rrrr<00>
getheadersZszHTTPResponse.getheaderscCs|j<00>||<02>S)N)rVri)rr"<00>defaultrrr<00> getheader]szHTTPResponse.getheadercCs|jS)N)rV)rrrr<00>infoaszHTTPResponse.infocCs6|js|j<01><02>|jr |j<03><02>|js2tj<06>|<00>dS)N)r<>r`r<>rgr]<00>io<69>IOBase)rrrrr<>es 

zHTTPResponse.closecCsT|jstjj<03>|<00>S|jdkr"dSt|jd<02>r8|j<05><07>St|jd<03>rL|jjSdSdS)NTr|r<>)r]r<>r<>r<><00>__get__r`r:r|)rrrrr<>os
 
 zHTTPResponse.closedcCs6|jdkrtd<01><01>nt|jd<02>r*|j<00><03>Std<03><01>dS)Nz-HTTPResponse has no file to get a fileno from<6F>filenozOThe file-like object this HTTPResponse is wrapped around has no file descriptor)r`<00>IOErrorr:r<>)rrrrr<>|s 

 
zHTTPResponse.filenocCs2|jdk r.t|jd<01>r.t|jdd<03>s.|j<00><03>SdS)Nr<r<>F)r`r:r!r<)rrrrr<<00>s
 zHTTPResponse.flushcCsdS)NTr)rrrr<00>readable<6C>szHTTPResponse.readablecCs:|<00>t|<01><01>}t|<02>dkrdS||dt|<02><01><t|<02>SdS)Nr)rPr<>)r<00>b<>temprrr<00>readinto<74>s
 zHTTPResponse.readintocCs t|jd<01>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().
<20>fp)r:r`)rrrrr<><00>sz#HTTPResponse.supports_chunked_readscCsf|jdk rdS|jj<02><03>}|<01>dd<02>d}yt|d<04>|_Wn&tk
r`|<00><07>t<08> |<01><01>YnXdS)N<>;rrr1)
rhr`r<><00>readlinerDr~r<>r<><00>httplibr )rr<>rrr<00>_update_chunk_length<74>s
 z!HTTPResponse._update_chunk_lengthcCs<>d}|dkr2|j<00>|j<02>}|}|j<00>d<01>d|_nv||jkrZ|j<00>|<01>}|j||_|}nN||jkr<>|j<00>|<01>}|j<00>d<01>d|_|}n |j<00>|j<02>}|j<00>d<01>d|_|S)Nr,)r`<00>
_safe_readrh)rr<><00>returned_chunk<6E>chunk<6E>valuerrr<00> _handle_chunk<6E>s& 
  
   zHTTPResponse._handle_chunkc cs<>|<00><00>|jstd<01><01>|<00><03>s&td<02><01>|<00><05><00><>|jrNt|j<06>rN|j<06><08>dS|j j
dkr^dSx<|<00> <0B>|j dkrtP|<00> |<01>}|j||dd<06>}|r`|Vq`W|r<>|<00><0F>}|r<>|Vx |j j
<EFBFBD><10>}|s<>P|dkr<>Pq<>W|jr<>|j<06><08>WdQRXdS)a<>
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.
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)rTr<>s
)r<>rSr r<>rr<>rarr<>r`r<>r<>rhr<>r<>r<>r<>)rr<>rTr<><00>decodedr<64>rrrr<><00>sD

 

 
 zHTTPResponse.read_chunkedcCs.|jdk r$t|jj<02>r$|jjdjS|jSdS)z<>
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.
N<><4E><EFBFBD><EFBFBD><EFBFBD>)r[r<><00>history<72>redirect_locationrd)rrrr<00>geturlszHTTPResponse.geturlccs<>dg}x<>|jdd<03>D]r}d|kr||<02>d<04>}d<01>|<01>|ddVx|dd<07>D]}|dVqPW|drv|dg}q<>g}q|<01>|<02>qW|r<>d<01>|<01>VdS)NrT)rT<00>
rrr<>)r<>rD<00>join<69>append)r<00>bufferr<72><00>xrrr<00>__iter__s
 zHTTPResponse.__iter__)rONrrNrTTNNNNNFNNT)NNF)r<>N)N)NN),r(r)r*rIr<>r9rwr rxrz<00>propertyr&rqr|r}rkr<>r<>rrr<>r<>r<>rr<>rPr<><00> classmethodr<64>r<>r<>r<>r<>r<>r<>r<r<>r<>r<>r<>r<>r<>r<>r<>rrrrrM<00>sl

1  4
  9
J
 !

   
F rM)1<>
__future__r<00>
contextlibrrr<><00>logging<6E>socketrr<>rr<>r9<00> ImportError<6F> _collectionsr<00>
exceptionsrr r
r r r rZ packages.sixrrerZpackages.six.movesrr<>rqrrZ util.responserr<00> getLoggerr(r<><00>objectrr+r0r8r=r>r<>rMrrrr<00><module>s2     
 $