5,j(ddlmZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl m Z ddlmZddlmZddlmZe jrddlmZ ddlZn#e$rddlZYnwxYwn #e$rdZYnwxYwdd lmZdd lmZdd lmZdd l m!Z!m"Z"m#Z#dd l$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/ddl0m1Z1m2Z2ddl3m4Z4e jrddl5m6Z6ej7e8Z9GddZ:Gdde:Z;GddZ<Gdde:Z=eGdde:Z> ej?dkrddl@mAZAnddlBmAZAdZCGdde:ZDn #e$rd ZCYnwxYwGd!d"e:ZEd-d&ZFGd'd(ZGGd)d*ejHZIGd+d,eIZdS).) annotationsN)contextmanager) HTTPMessage) HTTPResponse)timeout)BaseHTTPConnection)util) _TYPE_BODY)HTTPHeaderDict) BaseSSLErrorHTTPConnection HTTPException) BodyNotHttplibCompatible DecodeErrorDependencyWarning HTTPErrorIncompleteReadInvalidChunkLength InvalidHeader ProtocolErrorReadTimeoutErrorResponseNotChunkedSSLError) is_fp_closedis_response_to_head)Retry)HTTPConnectionPoolc8eZdZd d dZedd Zdd Zd S)ContentDecoderdatabytes max_lengthintreturnctNNotImplementedErrorselfr"r$s @C:\PYTHON\GemmaClient\venv\Lib\site-packages\urllib3/response.py decompresszContentDecoder.decompress7!###boolctr(r)r,s r-has_unconsumed_tailz"ContentDecoder.has_unconsumed_tail:!###r0ctr(r)r3s r-flushzContentDecoder.flush>r/r0Nr!r"r#r$r%r&r#r&r1r&r#)__name__ __module__ __qualname__r.propertyr4r7r0r-r r 6sa$$$$$$$$X$$$$$$$r0r c@eZdZddZddd Zedd Zdd Zd S)DeflateDecoderr&Nonec`d|_d|_d|_tj|_dS)NTr0) _first_try_first_try_data _unfed_datazlib decompressobj_objr3s r-__init__zDeflateDecoder.__init__Cs-"&(( r0r!r"r#r$r%c6|j|z}d|_|s|jjs|S|}|dkrd}n|dkr ||_dS|js)|j|jj|z|S|xj|z c_ |j||}|rd|_d|_|S#t j$r^d|_t jt j |_ ||j|d|_cYS#d|_wxYwwxYw)Nr0rr$F) rGrJunconsumed_tailrEr.rFrHerrorrI MAX_WBITS)r,r"r$original_max_length decompresseds r-r.zDeflateDecoder.decompressIss$& DI5 K(  " "JJ A % % $D 3 9'' )D0Z(  $ +9///LLL +"''*$ z + + +#DO*DN?;;DI +(5H'(+$$$$s$**** +s$=-B++:D&D D DDr1clt|jp t|jjo|j Sr()r1rGrJrNrEr3s r-r4z"DeflateDecoder.has_unconsumed_tailss4D$%% * + + CDO0C r0c4|jSr(rJr7r3s r-r7zDeflateDecoder.flushyy   r0Nr&rCr8r9r:r;r<r=r>rKr.r?r4r7r@r0r-rBrBBsv)))) (+(+(+(+(+T   X !!!!!!r0rBceZdZdZdZdZdS)GzipDecoderStaterrN)r<r=r> FIRST_MEMBER OTHER_MEMBERS SWALLOW_DATAr@r0r-rZrZ}sLMLLLr0rZc@eZdZddZddd Zedd Zdd Zd S) GzipDecoderr&rCctjdtjz|_tj|_d|_dS)Nr0)rHrIrPrJrZr\_state_unconsumed_tailr3s r-rKzGzipDecoder.__init__s3&rDN':;; &3 #r0r!r"r#r$r%c Ht}|jtjkrt |S|dkr|xj|z c_dS|j|z}|s|jjrt |S ||j|t|t|z dz }nT#tj $rB|j}tj|_d|_|tj krt |cYSwxYw|jjp |jjx|_}|dkrt||krnV|st |S|jjr7tj |_tjdtjz|_"t |S)Nrr0TrMrb) bytearrayrcrZr^r#rdrJeofr.maxlenrHrOr]rN unused_datarIrP)r,r"r$retprevious_states r-r.zGzipDecoder.decompressskk ;*7 7 7::  ??  ! !T ) ! !3$t+   ::  D ty++Sc#hh)>%B%B,:   !%.; (+%!%5%CCC ::%%%  )BTY-B D !DA~~#c((j"8"8 "Szz!y} D.<  .rDN/BCC 7 D:Szzs4=B22A DDr1c*t|jSr()r1rdr3s r-r4zGzipDecoder.has_unconsumed_tailsD)***r0c4|jSr(rUr3s r-r7zGzipDecoder.flushrVr0NrWr8r9r:r;rXr@r0r-r`r`sv$$$$ 00000d+++X+!!!!!!r0r`cJeZdZddZddd Zddd Zedd ZddZdS) BrotliDecoderr&rCctj|_t|jdrt |d|jjdSt |d|jjdS)Nr. _decompress)brotli DecompressorrJhasattrsetattrr.processr3s r-rKzBrotliDecoder.__init__sa+--DIty,// @mTY-ABBBBBmTY->?????r0r!r"r#output_buffer_limitr%ctr(r))r,r"rxs r-rrzBrotliDecoder._decompresss%'' 'r0r$c |dkr|||S||S#t$r2tjdt||cYSwxYw)Nr)rxz;Brotli >= 1.2.0 is required to prevent decompression bombs.)rr TypeErrorwarningswarnrr+s r-r.zBrotliDecoder.decompresss .>>++Dj+QQQ++D111 . . . Q%''----- .s449A0/A0r1cZ |j S#t$rYdSwxYw)NF)rJcan_accept_more_dataAttributeErrorr3s r-r4z!BrotliDecoder.has_unconsumed_tails@ 999;;;;!   uu s  **cbt|jdr|jSdS)Nr7r0)rurJr7r3s r-r7zBrotliDecoder.flushs-ty'** )y(((3r0NrWr8)r"r#rxr%r&r#r9r:r;) r<r=r>rKrrr.r?r4r7r@r0r-rprps @ @ @ @ ( ( ( ( ( . . . . .             r0rp))zstdTc@eZdZddZddd Zedd Zdd Zd S) ZstdDecoderr&rCc6tj|_dSr()rZstdDecompressorrJr3s r-rKzZstdDecoder.__init__s-//DIIIr0r!r"r#r$r%c|s |jsdS|jjr'|jj|z}t j|_|j||}t|}|g}|jjr|jjr|dks||kr|jj}|jjst j|_|j||dkr||z nd}t|x}r| |||z }n |jjrn$|jjr|jjr |dk||kd |S)Nr0rMrr!) r4rJrgrjrrr.ri needs_inputappendjoin)r,r"r$partlength data_partsrj part_lengths r-r.zZstdDecoder.decompresss  8 sy} 4y,t3 133 9'''DDDYYFJ  I)  !^^v ':':"i3 y,8 $ 5 7 7DIy++8BQ V 3 3B,#&d))+;%%d+++k)FFY*  I)  !^^v ':':88J'' 'r0r1cf|jjp |jj pt|jjSr()rJrrgr1rjr3s r-r4zZstdDecoder.has_unconsumed_tail s6 ->?4 %DD r0c<|jjstddS)NzZstandard data is incompleter0)rJrgrr3s r-r7zZstdDecoder.flush&s#9= B!"@AAA3r0NrWr8r9r:r;rXr@r0r-rrsv 0 0 0 0 ( ( ( ( (D             r0rFcHeZdZdZdZddZdd ZdddZeddZ dS) 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. modesstrr&rCcd|dD}t||jkr'tdt|d|jd|D|_dS)Nc6g|]}|Sr@strip).0ms r- z)MultiDecoder.__init__..:s 9991QWWYY999r0,z)Too many content encodings in the chain: z > c,g|]}t|Sr@) _get_decoder)res r-rz)MultiDecoder.__init__..@s===a,q//===r0)splitrimax_decode_linksr _decoders)r,r encodingss r-rKzMultiDecoder.__init__9s99 C(8(8999 y>>D1 1 1>y>>>>&*&;>> >=9===r0r#c@|jdSNr)rr7r3s r-r7zMultiDecoder.flushBs~a &&(((r0r!r"r$r%ch|dkr.t|jD]}||}|St} d}t|jD]-}|||t |z }|rd}.||z }|rt ||krt |Sd}p)NrTFrMr0)reversedrr.rfrir#)r,r"r$drkany_datas r-r.zMultiDecoder.decompressEs ??dn-- * *||D))Kkk Hdn-- $ $||DZ#c((5J|KK$#H 4KC "s3xx:55Szz!D r0r1c>td|jDS)Nc3$K|] }|jV dSr()r4)rrs r- z3MultiDecoder.has_unconsumed_tail..as%AAQ1(AAAAAAr0)anyrr3s r-r4z MultiDecoder.has_unconsumed_tail_s!AA$.AAAAAAr0N)rrr&rCr;r8r9r:) r<r=r>__doc__rrKr7r.r?r4r@r0r-rr,s>>>>))))4BBBXBBBr0rmoderr&cd|vrt|S|dvrtSt|dkrtStr|dkrt St S)Nr)gzipx-gzipbrr)rr`rsrpHAS_ZSTDrrB)rs r-rrdso d{{D!!! !!!}} ddllDFNN}}   r0c:eZdZdZddZddZdd Zdd Zdd Zd S)BytesQueueBufferaMemory-efficient bytes buffer To return decoded data in read() and still follow the BufferedIOBase API, we need a buffer to always return the correct amount of bytes. This buffer should be filled using calls to put() Our maximum memory usage is determined by the sum of the size of: * self.buffer, which contains the full data * the largest chunk that we will copy in get() r&rCcDtj|_d|_dSr) collectionsdequebuffer_sizer3s r-rKzBytesQueueBuffer.__init__s?J?P?R?R  r0r%c|jSr()rr3s r-__len__zBytesQueueBuffer.__len__s zr0r"r#ct|j||xjt|z c_dSr()rrrrir,r"s r-putzBytesQueueBuffer.puts2 4    c$ii r0nc0|dkrdS|jstd|dkrtdt|jd|krIt |jdt r)|xj|zc_|jSd}tj }||kr||z }|j}t|}||krct|}|d|||d}}| ||j ||xj|zc_n8| ||xj|zc_||z }|jsn||k| S)Nrr0zbuffer is emptyzn should be > 0)r RuntimeError ValueErrorri isinstancer#rpopleftioBytesIO memoryviewwrite appendleftgetvalue) r,rfetchedrk remainingchunk chunk_length left_chunk right_chunks r-getzBytesQueueBuffer.gets 663 0011 1 UU.// / t{1~  ! # # 4;q>5(I(I # JJ!OJJ;&&(( (jllkkG IK''))Eu::L<''"5))*/  *;U9::=NK  *%%% &&{333 i'  %    l* | #G; #kk&||~~r0c|js|jdksJdStdkr>}t |t r|}nbtj}| fdttD| }d|_|S)Nrr0rc3@K|]}VdSr()r)r_rs r-rz+BytesQueueBuffer.get_all..s-HH6>>++HHHHHHr0) rrripoprrtobytesrr writelinesranger)r,resultrkrs @r-get_allzBytesQueueBuffer.get_alls :????3 v;;!  ZZ\\F&*-- *))*,,C NNHHHHU3v;;5G5GHHH H H H\\^^F  r0NrWr&r%)r"r#r&rC)rr%r&r#r;) r<r=r>rrKrrrrr@r0r-rrvs      !!!!Fr0rceZdZUgdZeedgz Zeredgz ZgdZeej fZ de d<e e ej fz Z er e e j fz Z ddddFdZdGdZedHdZdIdZedJd ZejdKd"ZedLd$ZedMd%ZejdNd&Z dOdPd,Z dQdRd/Z dSdTd0Z dSdPd1ZdUd2ZdUd3ZdUd4ZdUd5ZdUd6Z dVdWd:Z dHd;Z!dXd>Z"dYd@Z#dVdZdCZ$dYdDZ%dJdEZ&dS)[BaseHTTPResponse)rrdeflateNrr)i-i.i/i3i4ztuple[type[Exception], ...]DECODER_ERROR_CLASSES)headersretriesr>typing.Mapping[str, str] | typing.Mapping[bytes, bytes] | Nonestatusr%versionversion_stringrreason str | Nonedecode_contentr1 request_urlr Retry | Noner&rCct|tr||_nt||_||_||_||_||_||_d|_||_ ||_ d|_ |j dd } d| dD} d| vrd|_ d|_|dS)NFztransfer-encodingc3>K|]}|VdSr(r)rencs r-rz,BaseHTTPResponse.__init__..s*>>SSYY[[>>>>>>r0rchunkedT)rr rrrrrr_has_decoded_content _request_urlrrrlowerr_decoder) r,rrrrrrrrtr_encrs r-rKzBaseHTTPResponse.__init__s g~ . . 3"DLL)'22DL  , ,$)!(3  !!"5r::@@BB>>FLL,=,=>>>  ! !DL/3  )))r0"str | None | typing.Literal[False]cV|j|jvr|jdSdS)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)rREDIRECT_STATUSESrrr3s r-get_redirect_locationz&BaseHTTPResponse.get_redirect_locations/ ;$0 0 0<##J// /ur0r#ctr(r)r3s r-r"zBaseHTTPResponse.datar5r0 typing.Anyc^|jd}tj|S)a Deserializes the body of the HTTP response as a Python object. The body of the HTTP response must be encoded using UTF-8, as per `RFC 8529 Section 8.1 `_. To use a custom JSON decoder pass the result of :attr:`HTTPResponse.data` to your custom decoder instead. If the body of the HTTP response is not decodable to UTF-8, a `UnicodeDecodeError` will be raised. If the body of the HTTP response is not a valid JSON document, a `json.JSONDecodeError` will be raised. Read more :ref:`here `. :returns: The body of the HTTP response as a Python object. zutf-8)r"decode_jsonloadsrs r-jsonzBaseHTTPResponse.jsons)$y(({4   r0ctr(r)r3s r-urlzBaseHTTPResponse.urlr5r0rctr(r)r,rs r-rzBaseHTTPResponse.urlr5r0BaseHTTPConnection | Nonectr(r)r3s r- connectionzBaseHTTPResponse.connection"r5r0c|jSr()_retriesr3s r-rzBaseHTTPResponse.retries&s }r0cT||jr|jdj|_||_dS)Nr!)historyredirect_locationrr)r,rs r-rzBaseHTTPResponse.retries*s-  7? r* "###r0ctr(r)rs r- read_chunkedzBaseHTTPResponse.read_chunkedErr0ctr(r)r3s r- release_connzBaseHTTPResponse.release_connLr/r0ctr(r)r3s r- drain_connzBaseHTTPResponse.drain_connOr/r0ctr(r)r3s r-shutdownzBaseHTTPResponse.shutdownRr/r0ctr(r)r3s r-closezBaseHTTPResponse.closeUr/r0c0jdd}j\|jvrt |_dSd|vr;fd|dD}|rt |_dSdSdSdS)z= Set-up the _decoder attribute if necessary. content-encodingrNrcng|]1}|jv|2Sr@)rCONTENT_DECODERS)rrr,s r-rz2BaseHTTPResponse._init_decoder..csAwwyyD$999GGII999r0)rrrrr-rr)r,content_encodingrs` r- _init_decoderzBaseHTTPResponse._init_decoderXs  <++,>CCIIKK = 4#888 ,-= > > (((-33C88 C$01A$B$BDMMM ! )( CCr0r" flush_decoderr$cv|s|jrtd|S||rd} |jr#|j||}d|_nS#|j$rF}|jdd}td|z||d}~wwxYw|r|| z }|S) zN Decode the data passed in and potentially flush the decoder. _Calling read(decode_content=False) is not supported after read(decode_content=True) was called.Nr!rMTr+rzEReceived response with content-encoding: %s, but failed to decode it.) rrrr.rrrrr_flush_decoder)r,r"rr0r$rr.s r-_decodezBaseHTTPResponse._decodeks  ( "<K   J } 1}///LL,0))   #|//0BBGGMMOO ')9:     * D'')) )D s*A BABBc||jr4|jd|jzSdS)zk Flushes the decoder. Should only be called if the decoder is actually being used. r0)rr.r7r3s r-r3zBaseHTTPResponse._flush_decoders= = I=++C004=3F3F3H3HH Hsr0bbytearray | memoryview[int]c|t|}t|dkrdS||dt|<t|Sr)rri)r,r6temps r-readintozBaseHTTPResponse.readintosLyyQ   t99>>1!AkD kNt99 r0r c|jSr(rr3s r- getheaderszBaseHTTPResponse.getheaders |r0namedefaultc8|j||Sr()rr)r,r?r@s r- getheaderzBaseHTTPResponse.getheaders|g...r0c|jSr(r<r3s r-infozBaseHTTPResponse.infor>r0c|jSr()rr3s r-geturlzBaseHTTPResponse.geturls xr0)rrrr%rr%rrrrrr1rrrrr&rC)r&rr;)r&rr&rrrr&rC)r&r )r&r)rrr&rCrN)rrrrr&rNNFrrrrrr1r&r#NNrrrrr&r#rWr() r"r#rrr0r1r$rr&r#)r6r7r&r%)r&r )r?rr@rr&r)'r<r=r>r-rsrrIOErrorrHrOr__annotations__r ZstdErrorrKrr?r"rrsetterr rrrrr!r#r%r'r)r/r4r3r:r=rBrDrFr@r0r-rrs=444 TF"%VH$111:A4:9NNNNN &,03$.!22 SW!%!*!*!*!*!*!*F    $$$X$!!!!*$$$X$ Z$$$Z$$$$X$X ^   ^ FJ$$$$$&*# $$$$$&*$$$$$&*$$$$$$$$$$$$$$$$$$$$$CCCC0"& #####J/////r0rceZdZdZ dOdPfd' ZdQd(ZdQd)ZedRd+ZedSd,Z dTd-Z dUd.Z dVd0Z e dWd2Z dXd3d4dYd7Z dXd3d4dYd8Z dZd[d;Z d\d]d<Z d^d_d?ZdTd@ZdQdAZdQdBZedTdCZdUdDZdQdEZdTdFZdQdGZd`dHZ d\d_dIZedadJZejdbdLZdcdNZ xZ!S)dra HTTP Response container. Backwards-compatible with :class:`http.client.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 :class:`http.client.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 :class:`http.client.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. rNrHTTP/?Tbodyr rrrr%rrrrrpreload_contentr1roriginal_response_HttplibHTTPResponse | NonepoolHTTPConnectionPool | Noner HTTPConnection | Nonemsg_HttplibHTTPMessage | Nonerrenforce_content_lengthrequest_methodr auto_close sock_shutdown#typing.Callable[[int], None] | Noner&rCc $t|||||||| ||_||_d|_d|_d|_| |_d|_| |_ |r#t|ttfr||_| |_ | |_t|dr||_||_d|_|||_t)|_|r$|js|||_dSdSdS)N)rrrrrrrrFrrr)superrKr]r__body_uncached_read_occurred_fp_original_response_fp_bytes_readr[rrr#_pool _connectionru_sock_shutdown chunk_left _init_lengthlength_remainingr_decoded_bufferr)r,rTrrrrrrUrrVrXr r[rr]r^rr_r` __class__s r-rKzHTTPResponse.__init__sG* ))#  '=#$ ',$04"3  Jtc5\22 DJ % 4  DH+'+!% 1 1. A A 011  B4: B.AADJJJ B B B Br0cr|jr|jsdS|j|jd|_dSr()rjrk _put_connr3s r-r#zHTTPResponse.release_connsBz !1 4 T-...r0c |n##ttttf$rYnwxYw|jrt |_d|_dSdS)z Read and discard any remaining HTTP response data in the response connection. Unread data in the HTTPResponse connection blocks the connection from being released back to the pool. N) _raw_readrOSErrorr rrrrprr3s r-r%zHTTPResponse.drain_connss   NN    7L-@    D   $ !$4#5#5D  DMMM  ! !s 77r#c\|jr|jS|jr|dSdS)NT)r)rergrr3s r-r"zHTTPResponse.data*s9 : :  8 1994900 0tr0c|jSr()rkr3s r-r zHTTPResponse.connection5s r0c*t|jSr()rrgr3s r-isclosedzHTTPResponse.isclosed9sDH%%%r0c|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). )rir3s r-tellzHTTPResponse.tell<s ""r0rc|jd}||jrtddS d|dD}t |dkrtd|z|}|dkrd}n#t$rd}YnwxYwd} t|j }n#t$rd}YnwxYw|d vsd |cxkrd ksn|d krd}|S) zM Set initial length value for Response content if available. zcontent-lengthNzReceived 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.c,h|]}t|Sr@)r%)rvals r- z,HTTPResponse._init_length.._sIII3s88IIIr0rrz8Content-Length contained multiple unmatching values (%s)r)i0dHEAD) rrrlogwarningrrirrrr%r)r,r^content_lengthlengthsrrs r-rnzHTTPResponse._init_lengthDsn &*\%5%56F%G%G  %|  t " JI~/C/CC/H/HIIIw<>#&&&tx~~?O?O O*-48==%%%dhmmoo Mr0c||jdSt|jdd}|5|s|||nd}|U|dkrO|sM|j|jr,|j%|jdkrt|j|jn;|r9|dkr|r|jt|kr|jdddn #1swxYwY|rA|xjt|z c_|j|xjt|zc_|S)z7 Reads `amt` of bytes from the socket. NclosedFrr0r) rggetattrrrr)r]rorriri)r,rr fp_closedr"s r-ruzHTTPResponse._raw_reads 8 4DHh66  " " ! !:CL4==E=222D3!88D8   / U-9-22))STTT !$4+@CII+M+M    = ! ! ! ! ! ! ! ! ! ! ! ! ! ! !@  3   3t99 ,  $0%%T2%% sB.C..C25C2rrc f|||j}|r |dkrd}n|d}|jrl|jjr`t |j|krH|d|d|t |jz }|j|t |j|kr|j|S| |}|sd|_ |dup|dko| }|s-t |jdkr|jr |jjs|S|v||||}|rKt |jdkr3|j||j }|r|j s||_ n |s|j rtd|S|||||t |jz }|j|t |j|kry|rw| |}|||||t |jz }|j|t |j|kr|w|j|}|S) aT Similar to :meth:`http.client.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.) NrFr0r0r$Tr2rM)r/rrr4rirpr4rrrurfrrerr)r,rrr decoded_datar"r0s r-rzHTTPResponse.read#s4   !!0N  5377CC _!M  7M5 7,--33#||""'"S)=%>%>> ,   $((6664'((C//+//444~~c"" 0+/D (t >q(=X  D())Q..]/'+}'H/K ;<<nmDDD 6#d&:";";a"?"?$((...+3355 "T%A "! " ,&@ <<T%9!:!:: (L  $ $\ 2 2 2d*++c11d1~~c**#||"!"S)=%>%>> ,   $((666d*++c11d1'++C00D r0c v||j}|r|dkrd}|jr|std|jrr|jjrf|t |j|krL|d|d||t |jz nd}|j|t |jdkr5||j S|j |S|dkrdS| |d}d|_ |r||S|  | }||||| }|j||s|rn| d d}S||j S|j |S) a Similar to ``http.client.HTTPResponse.read1`` and documented in :meth:`io.BufferedReader.read1`, but with an additional parameter: ``decode_content``. :param amt: How much of the content to read. :param decode_content: If True, will attempt to decode the body based on the 'content-encoding' header. NrzaCalling read1(decode_content=False) is not supported after read1(decode_content=True) was called.r0FrTrrMi )rrrrr4rirpr4rrrrurfr/)r,rrrr"r0s r-rzHTTPResponse.read1s"  !!0N  377C  $ 5! "=   7M5 7[C(<$=$=$C$C#||""';>?c$"67777PT ,   $((6664'((1,,;/77999+//444 !883~~c~..'+$ K  4 $HM<<nm(L  $ $\ 2 2 2 } >>$d>33D 4 ;'//11 1#'',,,r0rtyping.Generator[bytes]c#K|dkrdS|jr3|r|||Ed{VdSt|jr+t |jdks|jrj|jjr`| ||}|r|Vt|j1t |jdkI|jr|jj\dSdSdSdS)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. rNrc)rr) rsupports_chunked_readsr!rrgrirprr4r)r,rrr"s r-rzHTTPResponse.streams&$ !88 F < D7799 ((^(LL L L L L L L L L L!** t+,,q00M1&*m&G1yySyHHJJJ!** t+,,q00M1&*m&G100000000r0cdS)NTr@r3s r-readablezHTTPResponse.readablestr0c|jstd|jtd|tjdS)Nz8Cannot shutdown socket as self._sock_shutdown is not setzCCannot shutdown as connection has already been released to the pool)rlrrkrsocketSHUT_RDr3s r-r'zHTTPResponse.shutdownsY" YWXX X   #U  FN+++++r0cd|_|js |jr|j|jr|j|js!t j|dSdSr()rlrrgr)rkr_rIOBaser3s r-r)zHTTPResponse.closes}"{ tx  HNN      %   " " $ $ $ " IOOD ! ! ! ! ! " "r0c |js$tjj|S|jdSt |jdr|jSt |jdr |jjSdS)NTrzr)r_rrr__get__rgrurzr3s r-rzHTTPResponse.closeds} 9#++D11 1 X 4 TXz * * 8$$&& & TXx ( ( 8? "4r0c|jtdt|jdr|jStd)Nz-HTTPResponse has no file to get a fileno fromfilenozOThe file-like object this HTTPResponse is wrapped around has no file descriptor)rgrvrurr3s r-rzHTTPResponse.filenosV 8 IJJ J TXx ( ( 8??$$ $0 r0c|jDt|jdr1t|jdds|jSdSdSdS)Nr7rF)rgrurr7r3s r-r7zHTTPResponse.flush)s\ H '** !DHh66 !8>>## # ! r0c,t|jdS)a Checks if the underlying file-like object looks like a :class:`http.client.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)rurgr3s r-rz#HTTPResponse.supports_chunked_reads1stx&&&r0cB|jdS|jj}|ddd} t |d|_dS#t $r8||rt||dtddwxYw)N;rrrbzResponse ended prematurely) rmrgrreadlinerr%rr)rr)r,lines r-_update_chunk_lengthz!HTTPResponse._update_chunk_length:s ? &4x{##%%zz$""1% L!$mmDOOO L L L JJLLL L(t44$>$$@AAtK Ls AABc"d}|C|j|j}|}|jdd|_n|j7||jkr,|j|}|j|z |_|}n||jkr>|j|}|jdd|_|}n@|j|j}|jdd|_|S)Nr[)rg _safe_readrm)r,rreturned_chunkrvalues r- _handle_chunkzHTTPResponse._handle_chunkLs ;H''88E"N H   " " ""DOO _ (S4?-B-BH'',,E"o3DO"NN DO # #H'',,E H   " " ""DO"NN!X00AAN H   " " ""DOr0c#K||jstd|st d|5|jr;t|jr'|j ddddS|j j  ddddS|dkr ddddS|r|dkrd} |j r|j j rd}n<| d|_|jdkrn5||}|||d|}|r|Vr|r|}|r|V|j /|j j }|sn|d krn|j /|jr|jddddS#1swxYwYdS) 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.zkBody should be http.client.HTTPResponse like. It should have have an fp attribute which returns raw chunks.NrTr0F)rr0r$s )r/rrrrrrhrr)rgrrr4rrfrmrr4r3r)r,rrrdecodedrs r-r!zHTTPResponse.read_chunkedbs | $B **,, *P   " "8 08 0& +>t?V+W+W '--/// 8 08 08 08 08 08 08 08 0x{"8 08 08 08 08 08 08 08 0axx8 08 08 08 08 08 08 08 0 q "=4T]%F4EE--///37D0!++ ..s33E,,#1"'" ' "!MMM# "& "--//"!MMM(&x{++--7?? (&& 0'--///q8 08 08 08 08 08 08 08 08 08 08 08 08 08 08 08 08 08 0s%$6G' GGC/GGGc|jS)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. rr3s r-rzHTTPResponse.urls   r0rc||_dSr(rr s r-rzHTTPResponse.urlsr0rc#jKg}|dD]|}d|vra|d}d||dzdzV|ddD] }|dzV |dr |dg}dg}g||}|rd|VdSdS)NTrc r0rrr!)rrrr)r,rrchunksxs r-__iter__zHTTPResponse.__iter__s [[[55 % %E~~U++hhv&&2U::::"$$Ae)OOOO": $Rj\FFFF e$$$$  #((6"" " " " " " # #r0)rNrrrSNTTNNNNNTNNTN)&rTr rrrr%rr%rrrrrUr1rr1rVrWrXrYr rZr[r\rrr]r1r^rrrr_r1r`rar&rCrWr;)r&rZr:r)r^rr&r)r&rr()rrrr1r&r#rJrKrLrMrI)rrrrr&r)rrr&r#rGrH)r&r)"r<r=r>rrKr#r%r?r"r rzr|rnrrrrurrrrr'r)rrr7rrrr!rrQr __classcell__)rqs@r-rrshDRV&! $#9=*.,0*. $'+%)"&=A'?B?B?B?B?B?B?BB    !!!! X   X &&&&####6666p;$;$;$^;$~3N 3N3N3N3N3N3Nn2 222222l&*# jjjjj\&*E-E-E-E-E-PFJ     F,,,, " " " "   X     $$$$''''LLLL$.EIU0U0U0U0U0n!!!X! Z   Z ########r0r)rrr&r )J __future__rrrrrloggingrsystypingr|rH contextlibr http.clientr_HttplibHTTPMessager_HttplibHTTPResponserr TYPE_CHECKING_base_connectionr brotlicffirs ImportErrorrr r _collectionsr r r rr exceptionsrrrrrrrrrrr util.responserr util.retryrconnectionpoolr getLoggerr<rr rBrZr`rp version_info compressionr backportsrrrrrrrr@r0r-rs""""""   %%%%%%::::::<<<<<<++++++ 5444444#####   FFF((((((((((((CCCCCCCCCC                          =<<<<<<< 3222222g!! $ $ $ $ $ $ $ $8!8!8!8!8!^8!8!8!v =!=!=!=!=!.=!=!=!@ ((((((((V9 7""$$$$$$$""""""H/////n//// HHHn5B5B5B5B5B>5B5B5Bp$JJJJJJJJZkkkkkrykkk\d #d #d #d #d ##d #d #d #d #d #sBAA' A# A'"A##A''A10A1EEE