
    nbi              	         d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
Z
d dlmZ d dlmZ 	 	 d dlZn# e$ r d dlZY nw xY wn# e$ r dZY nw xY w	 d dlZ e ee ej        dej                                                                      Zedk     rdZn## eeef$ r 	 d dlmZ n# e$ r dZY nw xY wY nw xY wdd	lm Z  dd
l!m"Z" ddl#m$Z$m%Z% ddl&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0 ddl1m2Z2m3Z3 ddl4m5Z5 ej6        r$d dl7m8Z8 d dl9m:Z: ddl;m<Z< ddl=m>Z> ddl?m@Z@ ddlAmBZB  ejC        eD          ZE G d d          ZF G d deF          ZG G d d          ZH G d deF          ZIe G d deF          ZJe  eKejL        d           ZM G d  d!eF          ZN G d" d#eF          ZOd*d'ZP G d( d)ejQ                  ZReRZSdS )+    )annotationsN)contextmanager)timeoutz^([0-9]+)\.([0-9]+))r      )zstd   )HTTPHeaderDict)
_TYPE_BODY)LowLevelResponseResponsePromise)
BaseSSLErrorDecodeError	HTTPErrorIncompleteReadInvalidHeaderProtocolErrorReadTimeoutErrorResponseNotReadySSLErrorMustRedialError)is_fp_closedBytesQueueBuffer)Retry)Message)Literal)HTTPConnection)HTTPConnectionPool)ExtensionFromHTTP)TrafficPolicec                      e Zd ZddZddZdS )	ContentDecoderdatabytesreturnc                    t                      NNotImplementedErrorselfr"   s     g/var/www/html/mdtn/previsions/meteo_cartes/venv/lib/python3.11/site-packages/urllib3_future/response.py
decompresszContentDecoder.decompressI       !###    c                    t                      r&   r'   r*   s    r+   flushzContentDecoder.flushL   r-   r.   Nr"   r#   r$   r#   r$   r#   )__name__
__module____qualname__r,   r1    r.   r+   r!   r!   H   s<        $ $ $ $$ $ $ $ $ $r.   r!   c                  &    e Zd Zd	dZd
dZddZdS )DeflateDecoderr$   Nonec                R    d| _         d| _        t          j                    | _        d S )NTr.   )
_first_try_datazlibdecompressobj_objr0   s    r+   __init__zDeflateDecoder.__init__Q   s$    
&((			r.   r"   r#   c                   |s|S | j         s| j                            |          S | xj        |z  c_        	 | j                            |          }|rd| _         d | _        |S # t          j        $ r\ d| _         t	          j        t          j                   | _        	 |                     | j                  d | _        cY S # d | _        w xY ww xY wNF)r<   r@   r,   r=   r>   errorr?   	MAX_WBITS)r*   r"   decompresseds      r+   r,   zDeflateDecoder.decompressV   s     	K 	.9''---

d

	"9//55L ""'!
z 	" 	" 	"#DO*DN?;;DI"tz22!



T
!!!!	"s#   +A# #:CC7C	C

Cc                4    | j                                         S r&   r@   r1   r0   s    r+   r1   zDeflateDecoder.flushl       y   r.   Nr$   r:   r2   r3   r4   r5   r6   rA   r,   r1   r7   r.   r+   r9   r9   P   sP        ) ) ) )
" " " ",! ! ! ! ! !r.   r9   c                      e Zd ZdZdZdZdS )GzipDecoderStater   r      N)r4   r5   r6   FIRST_MEMBEROTHER_MEMBERSSWALLOW_DATAr7   r.   r+   rM   rM   p   s        LMLLLr.   rM   c                  &    e Zd Zd	dZd
dZddZdS )GzipDecoderr$   r:   c                t    t          j        dt           j        z             | _        t          j        | _        d S )N   )r>   r?   rE   r@   rM   rO   _stater0   s    r+   rA   zGzipDecoder.__init__w   s)    &rDN':;;	&3r.   r"   r#   c                   t                      }| j        t          j        k    s|st	          |          S 	 	 || j                            |          z  }nM# t          j        $ r; | j        }t          j        | _        |t          j	        k    rt	          |          cY S  w xY w| j        j
        }|st	          |          S t          j	        | _        t          j        dt          j        z             | _        )NTrU   )	bytearrayrV   rM   rQ   r#   r@   r,   r>   rD   rP   unused_datar?   rE   )r*   r"   retprevious_states       r+   r,   zGzipDecoder.decompress{   s    kk;*777t7::	@	ty++D111:   !%.;!%5%CCC ::%%% 9(D "Szz!*8DK*2+>??DI	@s   A ABBc                4    | j                                         S r&   rH   r0   s    r+   r1   zGzipDecoder.flush   rI   r.   NrJ   r2   r3   rK   r7   r.   r+   rS   rS   v   sT        4 4 4 4@ @ @ @*! ! ! ! ! !r.   rS   c                      e Zd ZddZddZdS )	BrotliDecoderr$   r:   c                    t          j                    | _        t          | j        d          rt	          | d| j        j                   d S t	          | d| j        j                   d S )Nr,   )brotliDecompressorr@   hasattrsetattrr,   processr0   s    r+   rA   zBrotliDecoder.__init__   s`    +--DIty,// ?lDI,@AAAAAlDI,=>>>>>r.   r#   c                b    t          | j        d          r| j                                        S dS )Nr1   r.   )rb   r@   r1   r0   s    r+   r1   zBrotliDecoder.flush   s-    ty'** )y(((3r.   NrJ   r3   )r4   r5   r6   rA   r1   r7   r.   r+   r^   r^      s<        	? 	? 	? 	?	 	 	 	 	 	r.   r^   r?   c                  &    e Zd Zd	dZd
dZddZdS )ZstdDecoderr$   r:   c                    t           s%t          j                                                    nt          j                    | _        d S r&   )_zstd_nativer   ZstdDecompressorr?   r@   r0   s    r+   rA   zZstdDecoder.__init__   s=     $-%''55777*,, IIIr.   r"   r#   c                   |sdS | j                             |          g}| j         j        r| j         j        r| j         j        }t          s%t          j                                                    nt          j                    | _         |                    | j                             |                     | j         j        r| j         j        d	                    |          S )Nr.   )
r@   r,   eofrY   ri   r   rj   r?   appendjoin)r*   r"   
data_partsrY   s       r+   r,   zZstdDecoder.decompress   s     s)..t445J)- EDI$9 E"i3 (1D)++99;;;.00 	
 !!$)"6"6{"C"CDDD )- EDI$9 E 88J'''r.   c                n    | j                                         }| j         j        st          d          |S )NzZstandard data is incomplete)r@   r1   rl   r   )r*   rZ   s     r+   r1   zZstdDecoder.flush   s4    )//##C9= B!"@AAAJr.   NrJ   r2   r3   rK   r7   r.   r+   rg   rg      sP        	 	 	 		( 	( 	( 	(	 	 	 	 	 	r.   rg   c                  .    e Zd ZdZdZddZdd	ZddZdS )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.
       modesstrr$   r:   c                    d |                     d          D             }t          |          | j        k    r't          dt          |           d| j                   d |D             | _        d S )Nc                6    g | ]}|                                 S r7   strip).0ms     r+   
<listcomp>z)MultiDecoder.__init__.<locals>.<listcomp>   s     9991QWWYY999r.   ,z)Too many content encodings in the chain: z > c                ,    g | ]}t          |          S r7   )_get_decoder)rz   es     r+   r|   z)MultiDecoder.__init__.<locals>.<listcomp>   s    ===a,q//===r.   )splitlenmax_decode_linksr   	_decoders)r*   rt   	encodingss      r+   rA   zMultiDecoder.__init__   s    99C(8(8999	y>>D111>y>>> >&*&;> >  
 >=9===r.   r#   c                @    | j         d                                         S Nr   )r   r1   r0   s    r+   r1   zMultiDecoder.flush   s    ~a &&(((r.   r"   c                ^    t          | j                  D ]}|                    |          }|S r&   )reversedr   r,   )r*   r"   ds      r+   r,   zMultiDecoder.decompress   s3    $.)) 	& 	&A<<%%DDr.   N)rt   ru   r$   r:   r3   r2   )r4   r5   r6   __doc__r   rA   r1   r,   r7   r.   r+   rr   rr      sb          	> 	> 	> 	>) ) ) )     r.   rr   moderu   r$   c                    d| v rt          |           S | dk    rt                      S t          | dk    rt                      S t          | dk    rt                      S t                      S )Nr}   gzipbrr   )rr   rS   r`   r^   r   rg   r9   )r   s    r+   r   r      sh    
d{{D!!!v~~}}ddllDFNN}}r.   c                     e Zd ZU dZddgZeedgz  Zeedgz  Zg dZee	j
        fZded	<   eeej
        fz  Zeeej        fz  Z	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dndod+Zdpd.Zdqd0Zedrd2            Zedsd4            Zdtd7Zdud9Zedvd:            Zej        dwd;            Zdxd<ZdydAZdzdBZd{dEZd|dGZd}dHZdxdIZdxdJZedzdK            Z ed~dL            Z!ddMZ"ddNZ#ddPZ$e%ddR            Z&dddTZ'	 dddUZ(	 	 dddVZ)	 	 	 dddYZ*	 ddd\Z+dd]Z,dxd^Z-edd_            Z.dd`Z/dxdaZ0ddbZ1ed}dc            Z2e2j        ddf            Z2d|dgZ3dddjZ4ddlZ5dxdmZ6dS )HTTPResponsea  
    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.
    r   deflateNr   r   )i-  i.  i/  i3  i4  ztuple[type[Exception], ...]DECODER_ERROR_CLASSES r   Tbodyr
   headers>typing.Mapping[str, str] | typing.Mapping[bytes, bytes] | Nonestatusintversionreason
str | Nonepreload_contentbooldecode_contentoriginal_responseLowLevelResponse | NonepoolHTTPConnectionPool | None
connectionHTTPConnection | NonemsgMessage | NoneretriesRetry | Noneenforce_content_lengthrequest_methodrequest_url
auto_closepolice_officer$TrafficPolice[HTTPConnection] | Noner$   r:   c                   t          |t                    r|| _        nt          |          | _        	 t          |          | _        n# t
          $ r
 d| _        Y nw xY w|r|dk    rd}|| _        || _        || _        d| _	        || _
        d | _        d | _        || _        d| _        d| j        v rW| j                            dd                                          }d |                    d          D             }d|v rd	| _        d | _        || _        || _        d | _        d | _        || _        d| _        || _        |r#t          |t4          t6          f          r|| _        |	| _        |
| _        t=          |d
          r|| _        d | _        || _         | !                    | j                   | _"        tG                      | _$        || _%        | j%        Q| j%        &                    | | j                   | j%        j'        %| j%        j'        &                    | | j                   || _(        |r$| j        s| )                    |          | _        d S d S d S )Nr   e   Fztransfer-encodingr   c              3  >   K   | ]}|                                 V  d S r&   rx   )rz   encs     r+   	<genexpr>z(HTTPResponse.__init__.<locals>.<genexpr>Y  s*      BBBBBBBBr.   r}   chunkedTreadr   )*
isinstancer	   r   r   r   
ValueErrorr   r   r   _has_decoded_content_request_url_retries
_extensionr   r   getlowerr   _decoderr   r   _body_fp_original_response_fp_bytes_readr   ru   r#   _pool_connectionrb   
chunk_left_request_method_init_lengthlength_remainingr   _decoded_buffer_police_officermemorizeparent_preloaded_contentr   )r*   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   tr_encr   s                       r+   rA   zHTTPResponse.__init__(  s   ( g~.. 	3"DLL)'22DL	f++DKK 	 	 	DKKK	  	$v}}#O,$)!(3&*48$,..\%%&92>>DDFFFBBS0A0ABBBII%%#/3&<#$
DH"3 	Jtc5\22 	DJ
%4   	DH '+ ,:,0,=,=d>R,S,S  011ES+ ))$0@AAA#*6$+44T4:FFF"1  	B4: 	B.AADJJJ	B 	B 	B 	Bs   A AApromiser   c                ^    | j         duo$t          | j         d          o| j         j        |k    S )zE
        Determine if this response came from given promise.
        Nfrom_promise)r   rb   r   )r*   r   s     r+   is_from_promisezHTTPResponse.is_from_promise  s9    
 HD  1.111%0	
r.   str | None | Literal[False]c                V    | j         | j        v r| j                            d          S dS )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   r   r0   s    r+   get_redirect_locationz"HTTPResponse.get_redirect_location  s/     ;$000<##J///ur.   HTTPHeaderDict | Nonec                Z    | j         dS t          | j         d          r| j         j        S dS )z
        Retrieve post-response (trailing headers) if any.
        This WILL return None if no HTTP Trailer Headers have been received.
        Ntrailers)r   rb   r   r0   s    r+   r   zHTTPResponse.trailers  s5     8448Z(( 	%8$$tr.   ExtensionFromHTTP | Nonec                    | j         S r&   )r   r0   s    r+   	extensionzHTTPResponse.extension  s
    r.   itemr   c                    | j         t          d          t          | j        d          st	                      |                    |            || _         d S )Nzextension already plugged in_dsa)r   OSErrorrb   r   r   start)r*   r   s     r+   start_extensionzHTTPResponse.start_extension  sV    ?&8999tx(( 	%"$$$

4r.   
typing.Anyc                ^    | j                             d          }t          j        |          S )a  
        Parses the body of the HTTP response as JSON.

        To use a custom JSON decoder pass the result of :attr:`HTTPResponse.data` to the decoder.

        This method can raise either `UnicodeDecodeError` or `json.JSONDecodeError`.

        Read more :ref:`here <json>`.
        zutf-8)r"   decode_jsonloadsr)   s     r+   jsonzHTTPResponse.json  s)     y(({4   r.   c                    | j         S r&   )r   r0   s    r+   r   zHTTPResponse.retries  s
    }r.   c                T    ||j         r|j         d         j        | _        || _        d S )N)historyredirect_locationurlr   )r*   r   s     r+   r   zHTTPResponse.retries  s-     7?r*<DHr.   c                F    d j         vrdS  j                             dd                                          } j        \| j        v rt          |           _        dS d|v r; fd|                    d          D             }|rt          |           _        dS dS dS dS )z=
        Set-up the _decoder attribute if necessary.
        content-encodingNr   r}   c                n    g | ]1}|                                 j        v |                                 2S r7   )ry   CONTENT_DECODERS)rz   r   r*   s     r+   r|   z.HTTPResponse._init_decoder.<locals>.<listcomp>  sA       wwyyD$999 GGII999r.   )r   r   r   r   r   r   r   )r*   content_encodingr   s   `  r+   _init_decoderzHTTPResponse._init_decoder  s     T\11F<++,>CCIIKK= 4#888 ,-= > >(((   -33C88  	
  C$01A$B$BDMMM !  )(C Cr.   r"   r#   bool | Noneflush_decoderc                f   |s| j         rt          d          |S 	 | j        r!| j                            |          }d| _         nS# | j        $ rF}| j                            dd                                          }t          d|z  |          |d}~ww xY w|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.Tr   r   zEReceived response with content-encoding: %s, but failed to decode it.N)
r   RuntimeErrorr   r,   r   r   r   r   r   _flush_decoder)r*   r"   r   r   r   r   s         r+   _decodezHTTPResponse._decode  s      	( "<   K
	} 1}//55,0)) 	 	 	#|//0BBGGMMOO')9:  		  	*D'')))Ds   (A 
BABBc                |    | j         r4| j                             d          | j                                         z   S dS )zk
        Flushes the decoder. Should only be called if the decoder is actually
        being used.
        r.   )r   r,   r1   r0   s    r+   r   zHTTPResponse._flush_decoder  s=    
 = 	I=++C004=3F3F3H3HHHsr.   brX   c                    |                      t          |                    }t          |          dk    rdS ||d t          |          <   t          |          S r   )r   r   )r*   r   temps      r+   readintozHTTPResponse.readinto  sL    yyQ  t99>>1!AkD		kNt99r.   r	   c                    | j         S r&   )r   r0   s    r+   infozHTTPResponse.info  s
    |r.   c                    | j         S r&   )r   r0   s    r+   geturlzHTTPResponse.geturl  s	    xr.   c                    | j         sd S | j        :| j                            | j                   du r| j                                         d | _         d S NT)r   r   is_heldreleaser0   s    r+   release_connzHTTPResponse.release_conn!  s_     	4  ,$,,T-=>>$FF ((***r.   c                l    	 |                                   dS # t          t          t          f$ r Y dS w xY w)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   r   r   r0   s    r+   
drain_connzHTTPResponse.drain_conn-  sA    	IIKKKKK7L1 	 	 	DD	s    33c                \    | j         r| j         S | j        r|                     d          S d S )NT)cache_content)r   r   r   r0   s    r+   r"   zHTTPResponse.data8  s9     : 	:8 	19949000tr.   c                    | j         S r&   )r   r0   s    r+   r   zHTTPResponse.connectionC  s    r.   c                *    t          | j                  S r&   )r   r   r0   s    r+   isclosedzHTTPResponse.isclosedG  s    DH%%%r.   c                    | j         S )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).
        )r   r0   s    r+   tellzHTTPResponse.tellJ  s     ""r.   
int | Nonec                   | j                             d          }|| j        rt                              d           dS 	 d|v rYd |                    d          D             }t          |          dk    rt          d|z            |                                }nt          |          }|dk     rd}n# t          $ r d}Y nw xY wd}| j        d	v sd
| j        cxk    rdk     sn |dk    rd}|S )zM
        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}   c                ,    h | ]}t          |          S r7   )r   )rz   vals     r+   	<setcomp>z,HTTPResponse._init_length.<locals>.<setcomp>n  s    MMMCs3xxMMMr.   r   z8Content-Length contained multiple unmatching values (%s)r   )   i0  d      HEAD)r   r   r   logwarningr   r   r   popr   r   r   )r*   r   content_lengthlengthslengths        r+   r   zHTTPResponse._init_lengthR  sS   
 &*\%5%56F%G%G%|     t" .((MM>3G3G3L3LMMMG7||a''+57EF   %[[]]FF 00F A::!F	     F K:%%dk''''C''''''Fs   A,B6 6CC"typing.Generator[None, None, None]c              #  :  K   d}	 	 dV  n# t           $ r}t          | j        dd          |d}~wt          $ r=}dt	          |          vrt          |          |t          | j        dd          |d}~wt          t          f$ r}t          d||          |d}~ww xY wd}|s@| j	        r| j	        
                                 | j        r| j        
                                 | j	        r/| j	                                        r|                                  dS dS dS # |s@| j	        r| j	        
                                 | j        r| j        
                                 | j	        r.| j	                                        r|                                  w w w xY w)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Connection broken: T)SocketTimeoutr   r   r   ru   r   r   r   r   r   closer   r  r  )r*   
clean_exitr   s      r+   _error_catcherzHTTPResponse._error_catcher  s!      
+	$K  S S S 'tz49JKKQRR S S S-SVV;;"1++1,&tz49JKKQRR_- K K K#$?!$?$?CCJK J  - * 4+11333
 # -$**,,, & $4+B+K+K+M+M $!!#####$ $ $ $  - * 4+11333
 # -$**,,, & $4+B+K+K+M+M $!!####$ $s;    D  
B-B8A22BBBD   A:Famtc                   | j         sJ d}|r||k    s| j        r| j        |k    rt          j        dk     rt	          j                    }d}||dk    rg|t          ||          }||z  }n|}	 | j                             |          }n# t          $ r Y n%w xY w|sn|	                    |           ~|a|dk    g|
                                S || j                             |          n| j                                         S )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:
          * 3.8 <= 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   Nr   )r   r   sysversion_infoioBytesIOminr   r   writegetvalue)r*   r+  	c_int_maxbuffermax_chunk_amt	chunk_amtr"   s          r+   _fp_readzHTTPResponse._fp_read  s5    x		N9__% %*.*?)*K*K((Z\\F "M+? #C 7 7I9$CC -I8==33DD!   E T""" + ??$$$ *-48==%%%dhmmooMs   .B	 	
BBc                   | j         dS t          | j         dd          }|                                 5  |s|                     |          nd}|du ot          | j         dd          du }||dk    r|r|r|rA| xj        t          |          z  c_        | j        | xj        t          |          z  c_        | j                                          | j        r,| j        %| j        dk    rt          | j        | j                  ddd           n# 1 swxY w Y   |rC|sA| xj        t          |          z  c_        | j        | xj        t          |          z  c_        |S )z7
        Reads `amt` of bytes from the socket.
        NclosedFr.   r   )
r   getattrr*  r:  r   r   r   r(  r   r   )r*   r+  	fp_closedr"   is_foreign_fp_uncloseds        r+   	_raw_readzHTTPResponse._raw_read  s    84DHh66	  "" "	U "	U-6?4==%%%CD tK(E B Be K # C1HHTH>TH) ;''3t994'',8--T:--    /
U-9-22 ))<d>STTTE"	U "	U "	U "	U "	U "	U "	U "	U "	U "	U "	U "	U "	U "	U "	UH  	3. 	33t99,$0%%T2%%s   CDDDc                    |                      |pd|          }|Gt          |          |k    r4| j                            |           | j                            |          S |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.
        r   r+  r   )r   r   r   putr   r*   r+  r   r"   s       r+   read1zHTTPResponse.read1(  sn    $ yy	r)  
 

 ?s4yy3 $$T***'++C000r.   Fr  c                R   	 |                                   || j        }|d}|dk     rt          | j                  r| j                            t          | j                            t          | j        d          ri| j        j        r^| j        Xt          | j        d          r| j        j	        | j        j	        j
        du r%| j                            |            d| _        S S S S S d|cxk     rt          | j                  k    rn n| j                            |          t          | j        d          ri| j        j        r^| j        Xt          | j        d          r| j        j	        | j        j	        j
        du r%| j                            |            d| _        S S S S S | j        H| j                            |           5  |                     |          }ddd           n# 1 swxY w Y   n|                     |          }|r|dk     rt          |          }d}|d}n
|dk    r|sd}|st          | j                  dk    r|t          | j        d          ri| j        j        r^| j        Xt          | j        d          r| j        j	        | j        j	        j
        du r%| j                            |            d| _        S S S S S |"|                     |||          }|r|| _        n|s| j        rt#          d          |t          | j        d          ri| j        j        r^| j        Xt          | j        d          r| j        j	        | j        j	        j
        du r%| j                            |            d| _        S S S S S |                     |||          }| j                            |           t          | j                  |k     r|r| j        H| j                            |           5  |                     |          }ddd           n# 1 swxY w Y   n|                     |          }|                     |||          }| j                            |           t          | j                  |k     r|| j                            |          }|t          | j        d          ri| j        j        r^| j        Xt          | j        d          r| j        j	        | j        j	        j
        du r%| j                            |            d| _        S S S S S # t          | j        d          rh| j        j        r\| j        Ut          | j        d          r| j        j	        | j        j	        j
        du r!| j                            |            d| _        w xY w)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.)
        NFr   _eotr   Tr   )r   r   r   r   r   rb   r   rG  r   r   r<  forgetborrowr@  r   r   r   r   rC  )r*   r+  r   r  r"   r   decoded_datas          r+   r   zHTTPResponse.readE  s   4M	0   %!%!4 %77s4#7887/33C8L4M4MNNr &))0HM0 (4  &110x},x}+t33(//555+/D((0 0 5 4 s7777c$"67777777/33C88l &))0HM0 (4  &110x},x}+t33(//555+/D((0 0 5 4y #/)0066 / />>#..D/ / / / / / / / / / / / / / / ~~c**  sQww$ii!M{ $$ $ C 455::H &))0HM0 (4  &110x},x}+t33(//555+/D((0 0 5 4U {||D.-HH  &!%DJ &  0 *D    , &))0HM0 (4  &110x},x}+t33(//555+/D((0 0 5 49  $||D.-PP$((666$.//#55$5 +7!188>> 7 7#'>>##6#6D7 7 7 7 7 7 7 7 7 7 7 7 7 7 7  $~~c22#'<<nm#T#TL(,,\::: $.//#55$5 +//44 &))0HM0 (4  &110x},x}+t33(//555+/D((0 0 5 4 &))0HM0 (4  &110x},x}+t33(//555+/D(////sp   A'T' +;T' (!T' 	G+T' +G//T' 2G/3AT' =T' A,T' <PT' P""T' %P"&A?T' 'A?V&   #typing.Generator[bytes, None, None]c              #  
  K   | j         dS t          | j                   rt          | j                  dk    rK|                     ||          }|r|V  t          | j                   1t          | j                  dk    IdS dS )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. Setting -1 will output chunks as soon as they
            arrive.

        :param decode_content:
            If True, will attempt to decode the body based on the
            'content-encoding' header.
        Nr   rB  )r   r   r   r   r   rD  s       r+   streamzHTTPResponse.stream  s      & 8Ftx(( 	C0D,E,E,I,I99^9DDD 


	 tx(( 	C0D,E,E,I,I,I,I,I,Ir.   c                    dS r	  r7   r0   s    r+   readablezHTTPResponse.readable  s    tr.   c                @   | j         '| j         j        du r| j                                          | j        s | j        r| j                                         | j        r| j                                         | j        s!t          j                            |            d S d S rC   )r   r<  r(  r   r   r   r1  IOBaser0   s    r+   r(  zHTTPResponse.close  s    >%$.*?5*H*HN  """{ 	tx 	HNN 	%""$$$ 	"IOOD!!!!!	" 	"r.   c                   | j         s$t          j        j                            |           S | j        dS t          | j        d          r| j                                        S t          | j        d          r| j        j        S dS )NTr  r<  )r   r1  rR  r<  __get__r   rb   r  r0   s    r+   r<  zHTTPResponse.closed  s}     		9#++D111X4TXz** 	8$$&&&TXx(( 	8?"4r.   c                    | j         t          d          t          | j         d          r| j                                         S t          d          )Nz-HTTPResponse has no file to get a fileno fromfilenozOThe file-like object this HTTPResponse is wrapped around has no file descriptor)r   r   rb   rV  r0   s    r+   rV  zHTTPResponse.fileno  sV    8IJJJTXx(( 	8??$$$0  r.   c                    | j         Dt          | j         d          r1t          | j         dd          s| j                                         S d S d S d S )Nr1   r<  F)r   rb   r=  r1   r0   s    r+   r1   zHTTPResponse.flush  s\    H '** !DHh66 ! 8>>###	 !     r.   c                    dS )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().
        Fr7   r0   s    r+   supports_chunked_readsz#HTTPResponse.supports_chunked_reads  s	     ur.   c                    | j         S )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   r0   s    r+   r   zHTTPResponse.url  s       r.   r   ru   c                    || _         d S r&   r[  )r*   r   s     r+   r   zHTTPResponse.url  s    r.   c                H    t          j        dt          d           | j        S )NzHTTPResponse.getheaders() is deprecated and will be removed in a future version of urllib3(-future). Instead access HTTPResponse.headers directly.rN   category
stacklevel)warningswarnDeprecationWarningr   r0   s    r+   
getheaderszHTTPResponse.getheaders  s1    e'		
 	
 	
 	
 |r.   namedefaultc                p    t          j        dt          d           | j                            ||          S )NzHTTPResponse.getheader() is deprecated and will be removed in a future version of urllib3(-future). Instead use HTTPResponse.headers.get(name, default).rN   r^  )ra  rb  rc  r   r   )r*   re  rf  s      r+   	getheaderzHTTPResponse.getheader  sA    l'		
 	
 	
 	
 |g...r.   typing.Iterator[bytes]c              #  l  K   g }|                      dd          D ]|}d|v ra|                    d          }d                    |          |d         z   dz   V  |dd         D ]	}|dz   V  
|d         r
|d         g}dg }g|                    |           }|rd                    |          V  d S d S )Nr   Tr      
r.   r   r   )rN  r   rn   rm   )r*   r7  chunkchunksxs        r+   __iter__zHTTPResponse.__iter__#  s       [[D[99 	% 	%E~~U++hhv&&2U::::" $ $Ae)OOOO":  $Rj\FFFFe$$$$ 	#((6"""""""	# 	#r.   c                    dS )a-  urllib3 implemented this method in version 2.3 to palliate for a
        thread safety issue[...] using another thread safety issue[...]
        fortunately, we don't need that hack with urllib3-future thanks to
        our extensive safety with TrafficPolice. You may safely remove that
        call.Nr7   r0   s    r+   shutdownzHTTPResponse.shutdown4  s	     	r.   )r   Nr   r   NTTNNNNNTNNTN)$r   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r$   r:   )r   r   r$   r   )r$   r   )r$   r   )r$   r   )r   r   r$   r:   )r$   r   )r$   r   )r   r   r$   r:   rJ   )r"   r#   r   r   r   r   r$   r#   r3   )r   rX   r$   r   )r$   r	   )r$   r   )r$   r   )r$   r   )r$   r   )r   r   r$   r  )r$   r%  r&   )r+  r  r$   r#   )NN)r+  r  r   r   r$   r#   )NNF)r+  r  r   r   r  r   r$   r#   )rK  N)r+  r  r   r   r$   rL  )r   ru   r$   r:   )re  ru   rf  r   r$   r   )r$   ri  )7r4   r5   r6   r   r   r`   r   r   IOErrorr>   rD   r   __annotations__	ZstdErrorrA   r   r   propertyr   r   r   r   r   setterr   r   r   r  r  r  r  r  r"   r   r  r  r   r   r*  r:  r@  rE  r   rN  rP  r(  r<  rV  r1   rY  r   rd  rh  ro  rq  r7   r.   r+   r   r      s         @ 	*TF"VH$111:A4:9NNNNN&,0$.!22 RV! $#59*.,0" $'+%)"&?C%`B `B `B `B `BD
 
 
 

 
 
 
    X    X	 	 	 	! ! ! !    X ^      ^ C C C C*   <            
  
  
  
 	 	 	 	    X       X & & & &# # # #6 6 6 6p 5$ 5$ 5$ ^5$n-N -N -N -N -Nb 5 5 5 5 5r &*    > &*#	g0 g0 g0 g0 g0T FJ    8   " " " " 
 
 
 X
	 	 	 	$ $ $ $    ! ! ! X! 	Z      Z    / / / / /# # # #"     r.   r   )r   ru   r$   r!   )T
__future__r   r1  r   r   loggingrer/  typingra  r>   
contextlibr   socketr   r'  
brotlicffir`   ImportError	zstandardr   tuplemapr   search__version__groups_zstd_versionAttributeErrorr   compression_collectionsr	   _typingr
   backendr   r   
exceptionsr   r   r   r   r   r   r   r   r   r   util.responser   r   
util.retryr   TYPE_CHECKINGemail.messager   typing_extensionsr   r   r   connectionpoolr   contrib.webextensionsr   util.traffic_policer   	getLoggerr4   r  r!   r9   rM   rS   r^   rb   rj   ri   rg   rr   r   rR  r   BaseHTTPResponser7   r.   r+   <module>r     s   " " " " " " 				      				 



    % % % % % % + + + + + +#####      FFF EC143CDDKKMMNN M wZ0   $$$$$$$    ) ( ( ( ( (       6 6 6 6 6 6 6 6                        : 9 9 9 9 9 9 9      	 3%%%%%%))))))******222222888888222222g!!$ $ $ $ $ $ $ $! ! ! ! !^ ! ! !@       ! ! ! ! !. ! ! !< 
       " wt4oFFFL    n   :    >   B    A A A A A29 A A AJ     sc   : A
 	AA
 AA
 
AAAB   C )B0/C 0B:7C 9B::C ?C 