
    h              	         S SK Jr  S SKrS SKrS SKrS SKrS SKrS SKrS SK	r	S SK
r
S SKrS SKrS SKJr  S SKJr  S SKJr  S SKJr  \
R,                  (       a  SSKJr    S SKr S SKr\" \" \ \RB                  " S	\RD                  5      RG                  5       5      5      r$\$S
:  a  Sr%OSr% SSK(J)r)  SSKJ*r*  SSK+J,r,  SSK-J.r.J/r/J0r0  SSK1J2r2J3r3J4r4J5r5J6r6J7r7J8r8J9r9J:r:J;r;  SSK<J=r=J>r>  SSK?J@r@  \
R,                  (       a  SSKAJBrB  \R                  " \D5      rE " S S5      rF " S S\F5      rG " S S5      rH " S S\F5      rI\b   " S S\F5      rJ\%(       a   " S S \F5      rK " S! S"\F5      rLS*S# jrM " S$ S%5      rN " S& S'\R                  5      rP " S( S)\P5      rg! \ a    S SKr GNFf = f! \ a    Sr GNUf = f! \&\\'4 a    Sr% GNf = f)+    )annotationsN)contextmanager)HTTPMessage)HTTPResponse)timeout   )BaseHTTPConnectionz^([0-9]+)\.([0-9]+))r      FT)util)
_TYPE_BODY)HTTPHeaderDict)BaseSSLErrorHTTPConnectionHTTPException)
BodyNotHttplibCompatibleDecodeError	HTTPErrorIncompleteReadInvalidChunkLengthInvalidHeaderProtocolErrorReadTimeoutErrorResponseNotChunkedSSLError)is_fp_closedis_response_to_head)Retry)HTTPConnectionPoolc                  (    \ rS rSrSS jrSS jrSrg)ContentDecoderG   c                    [        5       eNNotImplementedErrorselfdatas     B/var/www/html/env/lib/python3.13/site-packages/urllib3/response.py
decompressContentDecoder.decompressH       !##    c                    [        5       er#   r$   r'   s    r)   flushContentDecoder.flushK   r,   r-    Nr(   bytesreturnr4   r5   r4   )__name__
__module____qualname____firstlineno__r*   r0   __static_attributes__r2   r-   r)   r    r    G   s    $$r-   r    c                  2    \ rS rSrSS jrSS jrS	S jrSrg)
DeflateDecoderO   c                T    SU l         SU l        [        R                  " 5       U l        g )NTr-   )
_first_try_datazlibdecompressobj_objr/   s    r)   __init__DeflateDecoder.__init__P   s     
&&(	r-   c                   U(       d  U$ U R                   (       d  U R                  R                  U5      $ U =R                  U-  sl         U R                  R                  U5      nU(       a  SU l         S U l        U$ ! [        R
                   ac    SU l         [        R                  " [        R                  * 5      U l         U R                  U R                  5      S U l        s $ ! S U l        f = ff = f)NF)r@   rD   r*   rA   rB   errorrC   	MAX_WBITS)r'   r(   decompresseds      r)   r*   DeflateDecoder.decompressU   s    K99''--

d
	"99//5L"'!
zz 	"#DO**DNN?;DI"tzz2!
T
	"s%   1A> >AC5C(C5(	C11C5c                6    U R                   R                  5       $ r#   rD   r0   r/   s    r)   r0   DeflateDecoder.flushk       yy  r-   )rA   r@   rD   Nr5   Noner3   r6   r7   r8   r9   r:   rE   r*   r0   r;   r2   r-   r)   r=   r=   O   s    )
",!r-   r=   c                       \ rS rSrSrSrSrSrg)GzipDecoderStateo   r   r      r2   N)r7   r8   r9   r:   FIRST_MEMBEROTHER_MEMBERSSWALLOW_DATAr;   r2   r-   r)   rT   rT   o   s    LMLr-   rT   c                  2    \ rS rSrSS jrSS jrS	S jrSrg)
GzipDecoderu   c                    [         R                  " S[         R                  -   5      U l        [        R
                  U l        g N   )rB   rC   rI   rD   rT   rW   _stater/   s    r)   rE   GzipDecoder.__init__v   s*    &&rDNN':;	&33r-   c                @   [        5       nU R                  [        R                  :X  d  U(       d  [	        U5      $   X R
                  R                  U5      -  nU R
                  R                  nU(       d  [	        U5      $ [        R                  U l        [        R                  " S[        R                  -   5      U l        M  ! [        R                   aD    U R                  n[        R                  U l        U[        R                  :X  a  [	        U5      s $ e f = fr^   )	bytearrayr`   rT   rY   r4   rD   r*   rB   rH   rX   unused_datarC   rI   )r'   r(   retprevious_states       r)   r*   GzipDecoder.decompressz   s    k;;*777t:	yy++D11 99((DSz!*88DK**2+>?DI  :: !%.;;!%5%C%CC :%s   C ADDc                6    U R                   R                  5       $ r#   rM   r/   s    r)   r0   GzipDecoder.flush   rO   r-   )rD   r`   NrP   r3   r6   rR   r2   r-   r)   r[   r[   u   s    4@*!r-   r[   c                  (    \ rS rSrSS jrSS jrSrg)BrotliDecoder   c                    [         R                  " 5       U l        [        U R                  S5      (       a"  [	        U SU R                  R
                  5        g [	        U SU R                  R                  5        g )Nr*   )brotliDecompressorrD   hasattrsetattrr*   processr/   s    r)   rE   BrotliDecoder.__init__   sO    ++-DItyy,//lDII,@,@AlDII,=,=>r-   c                n    [        U R                  S5      (       a  U R                  R                  5       $ g)Nr0   r-   )rp   rD   r0   r/   s    r)   r0   BrotliDecoder.flush   s'    tyy'**yy((r-   rD   NrP   r6   )r7   r8   r9   r:   rE   r0   r;   r2   r-   r)   rk   rk      s    	?	r-   rk   c                  2    \ rS rSrSS jrSS jrS	S jrSrg)
ZstdDecoder   c                T    [         R                  " 5       R                  5       U l        g r#   )zstdZstdDecompressorrC   rD   r/   s    r)   rE   ZstdDecoder.__init__   s    --/==?DIr-   c                   U(       d  gU R                   R                  U5      /nU R                   R                  (       a  U R                   R                  (       a  U R                   R                  n[        R
                  " 5       R                  5       U l         UR                  U R                   R                  U5      5        U R                   R                  (       a  U R                   R                  (       a  M  SR                  U5      $ )Nr-   )	rD   r*   eofrd   r{   r|   rC   appendjoin)r'   r(   
data_partsrd   s       r)   r*   ZstdDecoder.decompress   s    ))..t45J))--DII$9$9"ii33 113AAC	!!$))"6"6{"CD ))--DII$9$9$9 88J''r-   c                    U R                   R                  5       nU R                   R                  (       d  [        S5      eU$ )NzZstandard data is incomplete)rD   r0   r   r   )r'   re   s     r)   r0   ZstdDecoder.flush   s.    ))//#C99==!"@AAJr-   rv   NrP   r3   r6   rR   r2   r-   r)   rx   rx      s    	@	(	r-   rx   c                  6    \ rS rSrSrSS jrS	S jrS
S jrSrg)MultiDecoder   z
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.
c                    UR                  S5       Vs/ s H  n[        UR                  5       5      PM     snU l        g s  snf )N,)split_get_decoderstrip	_decoders)r'   modesms      r)   rE   MultiDecoder.__init__   s1    ;@;;s;KL;Ka,qwwy1;KLLs   #A c                <    U R                   S   R                  5       $ Nr   )r   r0   r/   s    r)   r0   MultiDecoder.flush   s    ~~a &&((r-   c                `    [        U R                  5       H  nUR                  U5      nM     U$ r#   )reversedr   r*   )r'   r(   ds      r)   r*   MultiDecoder.decompress   s(    $..)A<<%D *r-   )r   N)r   strr5   rQ   r6   r3   )	r7   r8   r9   r:   __doc__rE   r0   r*   r;   r2   r-   r)   r   r      s    M)r-   r   c                    SU ;   a  [        U 5      $ U S;   a
  [        5       $ [        b  U S:X  a
  [        5       $ [        (       a  U S:X  a
  [        5       $ [        5       $ )Nr   )gzipx-gzipbrr{   )r   r[   rn   rk   HAS_ZSTDrx   r=   )modes    r)   r   r      sW    
d{D!! !!}ddlxDFN}r-   c                  J    \ rS rSrSrS
S jrSS jrSS jrSS jrSS jr	Sr
g	)BytesQueueBuffer   a  Memory-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()

The worst case scenario is a single chunk, in which case we'll make a full copy of
the data inside get().
c                F    [         R                  " 5       U l        SU l        g r   )collectionsdequebuffer_sizer/   s    r)   rE   BytesQueueBuffer.__init__   s    +6+<+<+>
r-   c                    U R                   $ r#   )r   r/   s    r)   __len__BytesQueueBuffer.__len__   s    zzr-   c                v    U R                   R                  U5        U =R                  [        U5      -  sl        g r#   )r   r   r   lenr&   s     r)   putBytesQueueBuffer.put   s&    4 

c$i
r-   c                x   US:X  a  gU R                   (       d  [        S5      eUS:  a  [        S5      eSn[        R                  " 5       nX!:  a  X-
  nU R                   R                  5       n[        U5      nXF:  aZ  US U XTS  pUR                  U5        U R                   R                  U5        U =R                  U-  sl	         UR                  5       $ UR                  U5        U =R                  U-  sl	        X&-  nU R                   (       d   UR                  5       $ X!:  a  M  UR                  5       $ )Nr   r-   zbuffer is emptyzn should be > 0)r   RuntimeError
ValueErrorioBytesIOpopleftr   write
appendleftr   getvalue)	r'   nfetchedre   	remainingchunkchunk_length
left_chunkright_chunks	            r)   getBytesQueueBuffer.get   s   6011U.//jjlkIKK'')Eu:L'*/
*;U:=NK		*%&&{3

i'
 ||~ 		% 

l*
#G;;||~% k$ ||~r-   c                F  ^ U R                   mT(       d  U R                  S:X  d   eg[        T5      S:X  a  TR                  5       nOR[        R
                  " 5       nUR                  U4S j[        [        T5      5       5       5        UR                  5       nSU l        U$ )Nr   r-   r   c              3  D   >#    U  H  nTR                  5       v   M     g 7fr#   )r   ).0_r   s     r)   	<genexpr>+BytesQueueBuffer.get_all.<locals>.<genexpr>'  s     H5G6>>++5Gs    )	r   r   r   popr   r   
writelinesranger   )r'   resultre   r   s      @r)   get_allBytesQueueBuffer.get_all  sv    ::?"?v;!ZZ\F**,CNNHU3v;5GHH\\^F
r-   )r   r   NrP   r5   int)r(   r4   r5   rQ   )r   r   r5   r4   r6   )r7   r8   r9   r:   r   rE   r   r   r   r   r;   r2   r-   r)   r   r      s       <r-   r   c                     \ rS rSr% / SQr\b  \S/-  r\(       a  \S/-  r/ SQr\\	R                  4rS\S'   \b  \\R                  4-  r\(       a  \\R                  4-  rSSS	.                 S$S
 jjrS%S jr\S&S j5       rS'S jr\S(S j5       r\R*                  S)S j5       r\S*S j5       r\S+S j5       r\R*                  S,S j5       r S-     S.S jjr   S/       S0S jjr  S1     S2S jjr  S1     S.S jjrS3S jrS3S jrS3S jrS3S jrS3S jr         S4S jr!S&S jr"S5S jr#S6S jr$S7S8S  jjr%S6S! jr&S(S" jr'S#r(g)9BaseHTTPResponse-  )r   r   deflateNr   r{   )r   i.  i/  i3  i4  ztuple[type[Exception], ...]DECODER_ERROR_CLASSES)headersretriesc               |   [        U[        5      (       a  Xl        O[        U5      U l        X l        X0l        X@l        XPl        X`l        SU l        Xpl	        Xl
        SU l        U R                  R                  SS5      R                  5       n	S U	R                  S5       5       n
SU
;   a  SU l        S U l        U   g )NFztransfer-encoding c              3  @   #    U  H  oR                  5       v   M     g 7fr#   )r   )r   encs     r)   r   ,BaseHTTPResponse.__init__.<locals>.<genexpr>X  s     >,=SYY[[,=s   r   chunkedT)
isinstancer   r   statusversionversion_stringreasondecode_content_has_decoded_content_request_urlr   r   r   lowerr   _decoder)r'   r   r   r   r   r   r   request_urlr   tr_enc	encodingss              r)   rE   BaseHTTPResponse.__init__<  s     g~.."L)'2DL,,$)!(3!!"5r:@@B>FLL,=>		!DL/3r-   c                n    U R                   U R                  ;   a  U R                  R                  S5      $ g)z
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   r   r/   s    r)   get_redirect_location&BaseHTTPResponse.get_redirect_location_  s.     ;;$000<<##J//r-   c                    [        5       er#   r$   r/   s    r)   r(   BaseHTTPResponse.datak      !##r-   c                d    U R                   R                  S5      n[        R                  " U5      $ )al  
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 <https://www.rfc-editor.org/rfc/rfc8259#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 <json_content>`.

:returns: The body of the HTTP response as a Python object.
zutf-8)r(   decode_jsonloadsr&   s     r)   jsonBaseHTTPResponse.jsono  s'    $ yy({{4  r-   c                    [        5       er#   r$   r/   s    r)   urlBaseHTTPResponse.url  r   r-   c                    [        5       er#   r$   r'   r   s     r)   r   r     r   r-   c                    [        5       er#   r$   r/   s    r)   
connectionBaseHTTPResponse.connection  r   r-   c                    U R                   $ r#   )_retriesr/   s    r)   r   BaseHTTPResponse.retries  s    }}r-   c                t    Ub/  UR                   (       a  UR                   S   R                  U l        Xl        g )N)historyredirect_locationr   r  )r'   r   s     r)   r   r    s+     7??r*<<DHr-   c                    [        5       er#   r$   r'   amtr   s      r)   streamBaseHTTPResponse.stream  s     "##r-   c                    [        5       er#   r$   )r'   r  r   cache_contents       r)   readBaseHTTPResponse.read  s     "##r-   c                    [        5       er#   r$   r
  s      r)   read1BaseHTTPResponse.read1      
 "##r-   c                    [        5       er#   r$   r
  s      r)   read_chunkedBaseHTTPResponse.read_chunked  r  r-   c                    [        5       er#   r$   r/   s    r)   release_connBaseHTTPResponse.release_conn  r,   r-   c                    [        5       er#   r$   r/   s    r)   
drain_connBaseHTTPResponse.drain_conn  r,   r-   c                    [        5       er#   r$   r/   s    r)   shutdownBaseHTTPResponse.shutdown  r,   r-   c                    [        5       er#   r$   r/   s    r)   closeBaseHTTPResponse.close  r,   r-   c                   U R                   R                  SS5      R                  5       nU R                  c  XR                  ;   a  [        U5      U l        gSU;   ah  UR                  S5       Vs/ s H3  nUR                  5       U R                  ;   d  M#  UR                  5       PM5     nnU(       a  [        U5      U l        ggggs  snf )z-
Set-up the _decoder attribute if necessary.
content-encodingr   Nr   )r   r   r   r   CONTENT_DECODERSr   r   r   )r'   content_encodinger   s       r)   _init_decoderBaseHTTPResponse._init_decoder  s      <<++,>CIIK== #8#88 ,-= >(( .33C88wwyD$9$99 AGGI8  
 $01A$BDM  ) !s   1"CCc                   U(       d  U R                   (       a  [        S5      eU$  U R                  (       a"  U R                  R                  U5      nSU l         U(       a  XR                  5       -  nU$ ! U R                   a?  nU R
                  R                  SS5      R                  5       n[        SU-  U5      UeSnAff = f)z>
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.Tr&  r   zEReceived response with content-encoding: %s, but failed to decode it.N)
r   r   r   r*   r   r   r   r   r   _flush_decoder)r'   r(   r   flush_decoderr)  r(  s         r)   _decodeBaseHTTPResponse._decode  s     (("<  K
	}}}}//5,0) ''))D )) 	#||//0BBGMMO')9: 		s   3A5 5C:B??Cc                    U R                   (       a6  U R                   R                  S5      U R                   R                  5       -   $ g)zS
Flushes the decoder. Should only be called if the decoder is actually
being used.
r-   )r   r*   r0   r/   s    r)   r.  BaseHTTPResponse._flush_decoder  s5    
 ====++C04==3F3F3HHHr-   c                    U R                  [        U5      5      n[        U5      S:X  a  gX!S [        U5      & [        U5      $ r   )r  r   )r'   btemps      r)   readintoBaseHTTPResponse.readinto  s9    yyQ t9>!kD	Nt9r-   c                N    [         R                  " S[        SS9  U R                  $ )Nz|HTTPResponse.getheaders() is deprecated and will be removed in urllib3 v2.1.0. Instead access HTTPResponse.headers directly.rV   category
stacklevel)warningswarnDeprecationWarningr   r/   s    r)   
getheadersBaseHTTPResponse.getheaders  s&    O'		
 ||r-   c                l    [         R                  " S[        SS9  U R                  R	                  X5      $ )NzHTTPResponse.getheader() is deprecated and will be removed in urllib3 v2.1.0. Instead use HTTPResponse.headers.get(name, default).rV   r:  )r=  r>  r?  r   r   )r'   namedefaults      r)   	getheaderBaseHTTPResponse.getheader  s1    V'		
 ||..r-   c                    U R                   $ r#   )r   r/   s    r)   infoBaseHTTPResponse.info  s    ||r-   c                    U R                   $ r#   )r   r/   s    r)   geturlBaseHTTPResponse.geturl  s    xxr-   )r   r   r   r  r   r   r   r   r   r   r   r   r   )r   >typing.Mapping[str, str] | typing.Mapping[bytes, bytes] | Noner   r   r   r   r   r   r   
str | Noner   boolr   rN  r   Retry | Noner5   rQ   )r5   z"str | None | typing.Literal[False]r6   )r5   z
typing.Anyr5   rN  )r   rN  r5   rQ   )r5   zBaseHTTPConnection | None)r5   rP  )r   rP  r5   rQ   i   N)r  
int | Noner   bool | Noner5   typing.Iterator[bytes]NNFr  rS  r   rT  r  rO  r5   r4   NNr  rS  r   rT  r5   r4   rP   )r(   r4   r   rT  r/  rO  r5   r4   )r5  rc   r5   r   )r5   r   r#   )rC  r   rD  rN  r5   rN  ))r7   r8   r9   r:   r'  rn   r   r   IOErrorrB   rH   r   __annotations__r{   	ZstdErrorrE   r   propertyr(   r   r   setterr   r   r  r  r  r  r  r  r   r#  r*  r0  r.  r7  r@  rE  rH  rK  r;   r2   r-   r)   r   r   -  sr   4TF"VH$1:A4::9N6N&,,0$..!22
 SW !%!* P!* 	!*
 !* !* !* !*  !* !* 
!*F
 $ $!* $ $ 	ZZ$ $ $ $   ^^    FJ$$7B$	$ &*#	$$ $$ 	$
 
$ &*$$ $$ 
	$ &*$$ $$ 
 	$$$$$C&+6GK	</r-   r   c                  p  ^  \ rS rSrSr                  S!                                     S"U 4S jjjrS#S jrS#S jr\S$S j5       r	\S%S j5       r
S&S jrS'S	 jrS(S
 jr\S)S j5       r S*SS.     S+S jjjr S*SS.     S+S jjjr   S,       S-S jjr  S.     S/S jjr S0     S1S jjrS&S jrS#S jrS#S jr\S&S j5       rS'S jrS#S jrS&S jrS#S jrS2S jr S.     S1S jjr\S3S j5       r\R@                  S4S j5       rS5S jr!S r"U =r#$ )6r   i   a  
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.
c                  > [         TU ]  UUUUUUUUS9  Xl        UU l        S U l        S U l        Xl        SU l        Xl        U(       a!  [        U[        [        45      (       a  Xl        Xl        Xl        [        US5      (       a  Xl        UU l        S U l        U R#                  U5      U l        ['        5       U l        U(       a'  U R                  (       d  U R+                  US9U l        g g g )N)r   r   r   r   r   r   r   r   r   r  r   )superrE   enforce_content_length
auto_close_body_fp_original_response_fp_bytes_readmsgr   r   r4   _pool_connectionrp   _sock_shutdown
chunk_left_init_lengthlength_remainingr   _decoded_bufferr  )r'   bodyr   r   r   r   r   preload_contentr   original_responsepoolr   ri  r   rc  request_methodr   rd  sock_shutdown	__class__s                      r)   rE   HTTPResponse.__init__A  s    * 	))# 	 		
 '=#$
04"3Jtc5\22J
%4  H+ '+ !% 1 1. A  01 4::.ADJ $.?r-   c                    U R                   (       a  U R                  (       d  g U R                   R                  U R                  5        S U l        g r#   )rj  rk  	_put_connr/   s    r)   r  HTTPResponse.release_conn  s4    zz!1!1

T--.r-   c                f     U R                  5         g! [        [        [        [        4 a     gf = f)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)r  r   OSErrorr   r   r/   s    r)   r  HTTPResponse.drain_conn  s+    	IIK7L-@ 		s    00c                ~    U R                   (       a  U R                   $ U R                  (       a  U R                  SS9$ g )NT)r  )re  rf  r  r/   s    r)   r(   HTTPResponse.data  s0     ::::88994900r-   c                    U R                   $ r#   )rk  r/   s    r)   r   HTTPResponse.connection  s    r-   c                ,    [        U R                  5      $ r#   )r   rf  r/   s    r)   isclosedHTTPResponse.isclosed  s    DHH%%r-   c                    U R                   $ )z
Obtain the number of bytes pulled over the wire so far. May differ from
the amount of content returned by :meth:``urllib3.response.HTTPResponse.read``
if bytes are encoded on the wire (e.g, compressed).
)rh  r/   s    r)   tellHTTPResponse.tell  s     """r-   c                   U R                   R                  S5      nUb  U R                  (       a  [        R	                  S5        g UR                  S5       Vs1 s H  n[        U5      iM     nn[        U5      S:  a  [        SU-  5      eUR                  5       nUS:  a  SnOSn [        U R                  5      nUS;   d  S	Us=::  a  S
:  d  O  US:X  a  SnU$ s  snf ! [         a    Sn NHf = f! [         a    Sn NDf = f)z=
Set initial length value for Response content if available.
zcontent-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.r   r   z8Content-Length contained multiple unmatching values (%s)r   )   i0  d      HEAD)r   r   r   logwarningr   r   r   r   r   r   r   )r'   ru  content_lengthvallengthslengthr   s          r)   rn  HTTPResponse._init_length  s   
 &*\\%5%56F%G%||  " 0>/C/CC/HI/H3s8/HIw<!#'13AB  ! A:!F F	%F
 Z3&#63#6.F:RF7 J    	F	s6   C# C//C# *C5 C# #C21C25DDc              #  p  #    Sn  Sv   SnU(       dV  U R                  (       a  U R                  R                  5         U R                  (       a  U R                  R                  5         U R                  (       a1  U R                  R                  5       (       a  U R!                  5         ggg! [          a  n[        U R                  SS5      UeSnAf[         a8  nS[	        U5      ;  a  [        U5      Ue[        U R                  SS5      UeSnAf[         aO  nUR                  b+  UR                  b  UR                  UR                  * :X  a  SnOSU< 3n[        X25      UeSnAf[        [        4 a  n[        SU< 3U5      UeSnAff = f! U(       dV  U R                  (       a  U R                  R                  5         U R                  (       a  U R                  R                  5         U R                  (       a1  U R                  R                  5       (       a  U R!                  5         f f f = f7f)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.
FNzRead timed out.zread operation timed outz!Response may not contain content.zConnection broken: T)SocketTimeoutr   rj  r   r   r   r   expectedpartialr   r   r}  rg  r#  rk  r  r  )r'   
clean_exitr)  args       r)   _error_catcherHTTPResponse._error_catcher  s     
5	$K> J  **++113
 ##$$**, &&4+B+B+K+K+M+M!!# ,N&a ! S 'tzz49JKQRR S-SV;"1+1,&tzz49JKQRR! 	3JJ*		-

qyyj0=C/u5C#C+2!7+ K#&9!$?CJK  **++113
 ##$$**, &&4+B+B+K+K+M+M!!# ,N&s_   H6B- F B H6-
F7CF3DFA
E&&F9F

FF B!H33H6Fr  c               @   U R                   (       d   eSnU(       a  X:  d%  UGc  U R                  (       a  U R                  U:  a  [        R                  (       d  [        R
                  S:  a  U(       a  U R                   R                  U5      $ [        R                  " 5       nSnUb  US:w  ag  Ub  [        X5      nX-  nOUnU R                   R                  U5      nU(       d   UR                  5       $ UR                  U5        AUc  M_  US:w  a  Mg  UR                  5       $ U(       a8  Ub  U R                   R                  U5      $ U R                   R                  5       $ Ub  U R                   R                  U5      $ U R                   R                  5       $ )a   
Read a response with the thought that reading the number of bytes
larger than can fit in a 32-bit int at a time via SSL in some
known cases leads to an overflow error that has to be prevented
if `amt` or `self.length_remaining` indicate that a problem may
happen.

The known cases:
  * CPython < 3.9.7 because of a bug
    https://github.com/urllib3/urllib3/issues/2513#issuecomment-1152559900.
  * urllib3 injected with pyOpenSSL-backed SSL-support.
  * CPython < 3.10 only when `amt` does not fit 32-bit int.
i)   
   i   r   )rf  ro  r   IS_PYOPENSSLsysversion_infor  r   r   minr  r   r   )r'   r  r  	c_int_maxr   max_chunk_amt	chunk_amtr(   s           r)   _fp_readHTTPResponse._fp_read'  sB   & xxx	S_))))I5  C$4$4w$>xx~~i00ZZ\F "M+? #C 7I$C -Ixx}}Y/ ??$$ T" + ??$$*-/488>>#&Otxx~~?OO *-488==%MdhhmmoMr-   c                  U R                   c  g[        U R                   SS5      nU R                  5          U(       d  U R                  XS9OSnUbv  US:w  ap  U(       di  U R                   R	                  5         U R
                  (       a=  U R                  b0  U R                  S:w  a   [        U R                  U R                  5      eOGU(       a@  US:w  a  U(       a  U R                  [        U5      :X  a  U R                   R	                  5         SSS5        W(       aI  U =R                  [        U5      -  sl        U R                  b  U =R                  [        U5      -  sl        U$ ! , (       d  f       N`= f)z'
Reads `amt` of bytes from the socket.
NclosedFr  r-   r   )
rf  getattrr  r  r#  rc  ro  r   rh  r   )r'   r  r  	fp_closedr(   s        r)   	_raw_readHTTPResponse._raw_read`  s    88DHHh6	  ":C4===2D3!8D  //--9--2 ))<)<d>S>STT$4+@+@CI+M  = #@ 3t9,$$0%%T2%I #"s   CE))
E7c                   U R                  5         Uc  U R                  nU(       a	  US:  a  SnO9Ub6  Sn[        U R                  5      U:  a  U R                  R	                  U5      $ U R                  U5      nUSL =(       d    US:g  =(       a    U(       + nU(       d  [        U R                  5      S:X  a  U$ Uc!  U R                  XBU5      nU(       a  X@l        U$ U(       d  U R                  (       a  [        S5      eU$ U R                  XBU5      nU R                  R                  U5        [        U R                  5      U:  ag  U(       a`  U R                  U5      nU R                  XBU5      nU R                  R                  U5        [        U R                  5      U:  a	  U(       a  M`  U R                  R	                  U5      nU$ )a  
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.)
Nr   Fr-  )r*  r   r   rp  r   r  r0  re  r   r   r   )r'   r  r   r  r(   r/  decoded_datas          r)   r  HTTPResponse.read  s   4 	!!00N37C_!M4''(C/++//44~~c"t>q(=XD001Q6K;<<mDD!
. ) ",,&@  <<mLL  $$\2d**+c1d ~~c*#||D-P$$((6 d**+c1dd ''++C0Dr-   c                   Uc  U R                   nU(       a  US:  a  SnU R                  (       ac  U(       d  [        S5      e[        U R                  5      S:  a8  Uc  U R                  R                  5       $ U R                  R                  U5      $ US:X  a  gU R                  USS9nU(       a  Uc  U$ U R                  5          U(       + nU R                  X2U5      nU R                  R                  U5        U(       d  U(       a  OU R                  SSS9nMU  Uc  U R                  R                  5       $ U R                  R                  U5      $ )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.
Nr   zaCalling read1(decode_content=False) is not supported after read1(decode_content=True) was called.r-   Tr  i    )r   r   r   r   rp  r   r   r  r*  r0  r   )r'   r  r   r(   r/  r  s         r)   r  HTTPResponse.read1  s=   " !!00N37C$$!"=  4''(1,;//7799++//44!8 ~~c~.K $HM<<mLL  $$\2}>>$d>3D  ;''//11##'',,r-   c              #    #    U R                   (       a-  U R                  5       (       a  U R                  XS9 Sh  vN   g[        U R                  5      (       a  [        U R                  5      S:  aR  U R                  XS9nU(       a  Uv   [        U R                  5      (       d  M6  [        U R                  5      S:  a  MQ  gg N7f)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.
ra  Nr   )r  r   )r   supports_chunked_readsr  r   rf  r   rp  r  )r'   r  r   r(   s       r)   r  HTTPResponse.stream  s     $ <<D7799(((LLL"488,,D4H4H0IA0MyySyHJ	 #488,,D4H4H0IA0M Ms   9C	CA,C	*C	C	c                    g)NTr2   r/   s    r)   readableHTTPResponse.readable0  s    r-   c                z    U R                   (       d  [        S5      eU R                  [        R                  5        g )Nz8Cannot shutdown socket as self._sock_shutdown is not set)rl  r   socketSHUT_RDr/   s    r)   r   HTTPResponse.shutdown3  s)    ""WXXFNN+r-   c                B   S U l         U R                  (       d+  U R                  (       a  U R                  R                  5         U R                  (       a  U R                  R                  5         U R
                  (       d   [        R                  R                  U 5        g g r#   )rl  r  rf  r#  rk  rd  r   IOBaser/   s    r)   r#  HTTPResponse.close8  s\    "{{txxHHNN""$IIOOD! r-   c                `   U R                   (       d)  [        R                  R                  R	                  U 5      $ U R
                  c  g[        U R
                  S5      (       a  U R
                  R                  5       $ [        U R
                  S5      (       a  U R
                  R                  $ g)NTr  r  )rd  r   r  r  __get__rf  rp   r  r/   s    r)   r  HTTPResponse.closedD  sw    99##++D11XXTXXz**88$$&&TXXx((88??"r-   c                    U R                   c  [        S5      e[        U R                   S5      (       a  U R                   R                  5       $ [        S5      e)Nz-HTTPResponse has no file to get a fileno fromfilenozOThe file-like object this HTTPResponse is wrapped around has no file descriptor)rf  r}  rp   r  r/   s    r)   r  HTTPResponse.filenoQ  sL    88IJJTXXx((88??$$0 r-   c                    U R                   bS  [        U R                   S5      (       a7  [        U R                   SS5      (       d  U R                   R                  5       $ g g g )Nr0   r  F)rf  rp   r  r0   r/   s    r)   r0   HTTPResponse.flush\  sP    HH '**DHHh6688>>## 7 + !r-   c                .    [        U R                  S5      $ )z
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)rp   rf  r/   s    r)   r  #HTTPResponse.supports_chunked_readsd  s     txx&&r-   c                0   U R                   b  g U R                  R                  R                  5       nUR	                  SS5      S   n [        US5      U l         g ! [         a0    U R                  5         U(       a  [        X5      S e[        S5      S ef = f)N   ;r   r   r_   zResponse ended prematurely)
rm  rf  r  readliner   r   r   r#  r   r   )r'   lines     r)   _update_chunk_length!HTTPResponse._update_chunk_lengthm  s     ??&xx{{##%zz$"1%		L!$mDO 	LJJL(4$> $$@AtK	Ls   	A :Bc                r   S nUcK  U R                   R                  U R                  5      nUnU R                   R                  S5        S U l        U$ U R                  bB  XR                  :  a3  U R                   R                  U5      nU R                  U-
  U l        UnU$ XR                  :X  aA  U R                   R                  U5      nU R                   R                  S5        S U l        UnU$ U R                   R                  U R                  5      nU R                   R                  S5        S U l        U$ )NrV   )rf  
_safe_readrm  )r'   r  returned_chunkr   values        r)   _handle_chunkHTTPResponse._handle_chunk  s   ;HH''8E"NHH""DO  __(S??-BHH'',E"oo3DO"N  OO#HH'',EHH""DO"N
  "XX00ANHH""DOr-   c              #    #    U R                  5         U R                  (       d  [        S5      eU R                  5       (       d  [	        S5      eU R                  5          U R                  (       a>  [        U R                  5      (       a$  U R                  R                  5          SSS5        gU R                  R                  c
   SSS5        gU(       a  US:  a  Sn U R                  5         U R                  S:X  a  O.U R                  U5      nU R                  X2SS9nU(       a  Uv   MO  U(       a  U R                  5       nU(       a  Uv   U R                  bB  U R                  R                  R!                  5       nU(       d  OUS:X  a  OU R                  b  MB  U R                  (       a  U R                  R                  5         SSS5        g! , (       d  f       g= f7f)av  
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.Nr   F)r   r/  s   
)r*  r   r   r  r   r  rg  r   r#  rf  r  r  rm  r  r0  r.  r  )r'   r  r   r   decodedr  s         r)   r  HTTPResponse.read_chunked  s      	||$B  **,,*P 
   "&&+>t?V?V+W+W''--/	 #" xx{{" #" sQw ))+??a'**3/,, '  !M   --/!M ((&xx{{++-7? ((& &&''--/] #""s>   AG%AG&	G%/G	G%CG +G	G%
G"G%c                    U R                   $ )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.
r   r/   s    r)   r   HTTPResponse.url  s        r-   c                    Xl         g r#   r  r   s     r)   r   r    s    r-   c              #  L  #    / nU R                  SS9 Hp  nSU;   aV  UR                  S5      nSR                  U5      US   -   S-   v   USS  H
  nUS-   v   M     US   (       a  US   /nM[  / nM_  UR                  U5        Mr     U(       a  SR                  U5      v   g g 7f)NTra     
r-   r   r   r  )r  r   r   r   )r'   r   r   chunksxs        r)   __iter__HTTPResponse.__iter__  s      [[[5E~U+hhv&2U::"Ae)O &":$Rj\FFe$ 6 ((6"" s   B"B$)re  rk  rp  rf  rh  rg  rj  r   rl  rd  rm  rc  ro  ri  )r   Nr   r   zHTTP/?NTTNNNNNTNNTN)&rq  r   r   rM  r   r   r   r   r   r   r   rN  rr  rO  r   rO  rs  z_HttplibHTTPResponse | Nonert  zHTTPConnectionPool | Noner   HTTPConnection | Noneri  z_HttplibHTTPMessage | Noner   rP  rc  rO  ru  rN  r   rN  rd  rO  rv  z#typing.Callable[[int], None] | Noner5   rQ   rP   r6   )r5   r  )r5   rO  r   )ru  rN  r5   rS  )r5   ztyping.Generator[None]r#   )r  rS  r  rO  r5   r4   rV  rW  rX  rY  rR  )r  rS  r   rT  r5   ztyping.Generator[bytes])r  rS  r5   r4   rQ  )r   r   r5   rQ   )r5   rU  )$r7   r8   r9   r:   r   rE   r  r  r]  r(   r   r  r  rn  r   r  r  r  r  r  r  r  r   r#  r  r  r0   r  r  r  r  r   r^  r  r;   __classcell__)rw  s   @r)   r   r      s   D RV&! $#9=*.,0*. $'+%)"&=A'>B>B P>B 	>B
 >B >B >B >B >B 7>B (>B *>B (>B >B !%>B  #!>B"  #>B$ %>B& ;'>B( 
)>B >B@ 	      &#6p ?$ ?$F 7N 	7N7N 	7N
 
7Nv 2 	22 	2
 
2l &*#	HH $H 	H
 
HX &*4-4- $4- 
	4-n FJ7B	 8,

" 
 
	$'L$. EIK0K06AK0	 K0Z ! ! 	ZZ   # #r-   r   )r   r   r5   r    )Q
__future__r   r   r   r   r   loggingrer  r  typingr=  rB   
contextlibr   http.clientr   _HttplibHTTPMessager   _HttplibHTTPResponser   r  TYPE_CHECKING_base_connectionr	   
brotlicffirn   ImportError	zstandardr{   tuplemapr   search__version__groups_zstd_versionr   AttributeErrorr   r   r   r   _collectionsr   r   r   r   r   
exceptionsr   r   r   r   r   r   r   r   r   r   util.responser   r   
util.retryr   connectionpoolr   	getLoggerr7   r  r    r=   rT   r[   rk   rx   r   r   r   r  r   r2   r-   r)   <module>r     s   "  	   	  
    % : < +	4# C143C3CDKKMNM w  ( ( C C   = 	2!$ $!^ !@ !. !< 
 " n *> *$F FRpryy pf^## ^#Q   F
 	Z0 Hs<    F %F= 
F+'F. *F++F. .F:9F:=GG