
    YMjv                        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m	Z	 d dl
mZ d dl
mZ dZ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 m!Z! ddl"m#Z# ddl$m%Z%m&Z&  ejN                  e(      Z) G d de*      Z+ G d de*      Z, G d de*      Z-e G d de*      Z. G d de*      Z/d Z0 G d de*      Z1 G d dejd                        Z3y)    )absolute_importN)contextmanager)error)timeout   )util)HTTPHeaderDict)BaseSSLErrorHTTPException)
BodyNotHttplibCompatibleDecodeError	HTTPErrorIncompleteReadInvalidChunkLengthInvalidHeaderProtocolErrorReadTimeoutErrorResponseNotChunkedSSLError)six)is_fp_closedis_response_to_headc                   0    e Zd Zd Zd ZddZed        Zy)DeflateDecoderc                 `    d| _         d| _        d| _        t        j                         | _        y )NT    )
_first_try_data_unfed_datazlibdecompressobj_objselfs    O/var/www/html/venv/lib/python3.12/site-packages/pip/_vendor/urllib3/response.py__init__zDeflateDecoder.__init__%   s(    
&&(	r   c                 .    t        | j                  |      S Ngetattrr"   r$   names     r%   __getattr__zDeflateDecoder.__getattr__+       tyy$''r   c                    | j                   |z   }d| _         |s| j                  j                  s|S |}|dk  rd}n|dk(  r|| _         y| j                  s3| j                  j	                  | j                  j                  |z   |      S | xj
                  |z  c_        	 | j                  j	                  ||      }|rd| _        d | _        |S # t        j                  $ rc d| _        t        j                  t        j                         | _        	 | j	                  | j
                  |      d | _        cY S # d | _        w xY ww xY w)Nr   r   F)
r   r"   unconsumed_tailr   
decompressr   r    r   r!   	MAX_WBITS)r$   data
max_lengthoriginal_max_lengthdecompresseds        r%   r1   zDeflateDecoder.decompress.   s%    $&DII55K("J A%#D 99''		))D0*  	

d
	"99//jAL"'!
zz 	"#DO**DNN?;DI"tzz3FG!
T
	"s%   -C AED4*E4	D==Ec                     t        | j                        xs. t        | j                  j                        xr | j                   S r(   )boolr   r"   r0   r   r#   s    r%   has_unconsumed_tailz"DeflateDecoder.has_unconsumed_tailW   s:    
 D$$% 
**+CDOO0C	
r   N__name__
__module____qualname__r&   r-   r1   propertyr9    r   r%   r   r   $   s&    )('"R 
 
r   r   c                       e Zd ZdZdZdZy)GzipDecoderStater   r      N)r=   r>   r?   FIRST_MEMBEROTHER_MEMBERSSWALLOW_DATArA   r   r%   rC   rC   a   s    LMLr   rC   c                   0    e Zd Zd Zd ZddZed        Zy)GzipDecoderc                     t        j                  dt         j                  z         | _        t        j
                  | _        d| _        y )N   r   )r    r!   r2   r"   rC   rE   _state_unconsumed_tailr#   s    r%   r&   zGzipDecoder.__init__i   s2    &&rDNN':;	&33 #r   c                 .    t        | j                  |      S r(   r)   r+   s     r%   r-   zGzipDecoder.__getattr__n   r.   r   c           
         t               }| j                  t        j                  k(  rt	        |      S |dk(  r| xj
                  |z  c_        y| j
                  |z   }|s!| j                  j                  rt	        |      S 	 	 || j                  j                  |t        |t        |      z
  d            z  }| j                  j                  xs | j                  j                  x| _        }|dkD  rt        |      |k\  r	 t	        |      S |st	        |      S | j                  j                  r@t        j                  | _        t        j                   dt        j"                  z         | _        # t        j                  $ rJ | j                  }t        j                  | _        d| _        |t        j                  k(  rt	        |      cY S  w xY w)Nr   r   rK   )	bytearrayrL   rC   rG   bytesrM   r"   eofr1   maxlenr    r   rF   r0   unused_datar!   r2   )r$   r3   r4   retprevious_states        r%   r1   zGzipDecoder.decompressq   s    k;;*777:?!!T)! $$t+		: tyy++D#j3s86KQ2OPP 		))BTYY-B-BD!D A~#c(j"8 Sz Sz! yy}}.<< ..rDNN/BC	7 
 :: !%.;;(+%!%5%C%CC :%s   5E/ /AG
Gc                 ,    t        | j                        S r(   )r8   rM   r#   s    r%   r9   zGzipDecoder.has_unconsumed_tail   s     D))**r   Nr:   r<   rA   r   r%   rI   rI   h   s&    $
(2h + +r   rI   c                   0    e Zd Zd ZddZed        Zd Zy)BrotliDecoderc                     t         j                         | _        t        | j                  d      r| j                  j                  | _        y | j                  j                  | _        y )Nr1   )brotliDecompressorr"   hasattrr1   _decompressprocessr#   s    r%   r&   zBrotliDecoder.__init__   sD    ++-DItyy,/#'99#7#7 #'99#4#4 r   c                 $    | j                  |      S r(   )r_   )r$   r3   r4   s      r%   r1   zBrotliDecoder.decompress   s     ##D))r   c                      y)NFrA   r#   s    r%   r9   z!BrotliDecoder.has_unconsumed_tail   s    r   c                 d    t        | j                  d      r| j                  j                         S y)Nflushr   )r^   r"   rd   r#   s    r%   rd   zBrotliDecoder.flush   s$    tyy'*yy((r   Nr:   )r=   r>   r?   r&   r1   r@   r9   rd   rA   r   r%   rZ   rZ      s%    	5	* 
	 
		r   rZ   c                   8    e Zd ZdZdZd Zd ZddZed        Z	y)	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.
       c                 "   |j                  d      D cg c]  }|j                          }}t        |      | j                  kD  r#t	        dt        |      | j                  fz        |D cg c]  }t        |       c}| _        y c c}w c c}w )N,z0Too many content encodings in the chain: %d > %d)splitstriprT   max_decode_linksr   _get_decoder	_decoders)r$   modesm	encodingses        r%   r&   zMultiDecoder.__init__   s    (-C(891QWWY9	9y>D111 ^T-B-BCD  4==a,q/= : >s   B,Bc                 <    | j                   d   j                         S Nr   )rn   rd   r#   s    r%   rd   zMultiDecoder.flush   s    ~~a &&((r   c                 @   |dk  r-t        | j                        D ]  }|j                  |      } |S t               }	 d}t        | j                        D ]%  }|j                  ||t	        |      z
        }|s$d}' ||z  }|rt	        |      |k\  rt        |      S d}b)Nr   TFr   )reversedrn   r1   rP   rT   rQ   )r$   r3   r4   drV   any_datas         r%   r1   zMultiDecoder.decompress   s    
 ?dnn- *||D)*KkHdnn- $||D*s3x*?@#H$ 4KCs3x:5Sz!D r   c                 :    t        d | j                  D              S )Nc              3   4   K   | ]  }|j                     y wr(   )r9   ).0rw   s     r%   	<genexpr>z3MultiDecoder.has_unconsumed_tail.<locals>.<genexpr>   s     AQ1((As   )anyrn   r#   s    r%   r9   z MultiDecoder.has_unconsumed_tail   s    A$..AAAr   Nr:   )
r=   r>   r?   __doc__rl   r&   rd   r1   r@   r9   rA   r   r%   rf   rf      s4     >)0 B Br   rf   c                 |    d| v rt        |       S | dk(  r
t               S t        | dk(  r
t               S t	               S )Nri   gzipbr)rf   rI   r\   rZ   r   )modes    r%   rm   rm      s@    
d{D!!v~}ddlr   c                   .    e Zd ZdZd Zd Zd Zd Zd Zy)BytesQueueBufferaH  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().

    Backported from urllib3 2.x for the CVE-2025-66471 fix.
    c                 D    t        j                         | _        d| _        y rt   )collectionsdequebuffer_sizer#   s    r%   r&   zBytesQueueBuffer.__init__  s    !'')
r   c                     | j                   S r(   )r   r#   s    r%   __len__zBytesQueueBuffer.__len__#  s    zzr   c                 v    | j                   j                  |       | xj                  t        |      z  c_        y r(   )r   appendr   rT   )r$   r3   s     r%   putzBytesQueueBuffer.put&  s&    4 

c$i
r   c                 d   |dk(  ry| j                   st        d      |dk  rt        d      d}t        j                         }||k  r||z
  }| j                   j                         }t        |      }||k  r\|d | ||d  }}|j                  |       | j                   j                  |       | xj                  |z  c_	        	 |j                         S |j                  |       | xj                  |z  c_	        ||z  }| j                   s	 |j                         S ||k  r|j                         S )Nr   r   zbuffer is emptyzn should be > 0)r   RuntimeError
ValueErrorioBytesIOpopleftrT   write
appendleftr   getvalue)	r$   nfetchedrV   	remainingchunkchunk_length
left_chunkright_chunks	            r%   getzBytesQueueBuffer.get*  s   6011U.//jjlkGIKK'')Eu:L<'*/
*;U9:=NK
		*%&&{3

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

l*
|#G;;||~% k$ ||~r   c                 4   | j                   s| j                  dk(  sJ yt              dk(  rj                         }nPt	        j
                         }|j                  fdt        t                    D               |j                         }d| _        |S )Nr   r   r   c              3   >   K   | ]  }j                           y wr(   )r   )r{   _r   s     r%   r|   z+BytesQueueBuffer.get_all.<locals>.<genexpr>Q  s     H6>>+Hs   )	r   r   rT   popr   r   
writelinesranger   )r$   resultrV   r   s      @r%   get_allzBytesQueueBuffer.get_allH  sv    ::?"?v;!ZZ\F**,CNNHU3v;5GHH\\^F
r   N)	r=   r>   r?   r~   r&   r   r   r   r   rA   r   r%   r   r     s     $ <r   r   c                      e Zd ZdZddgZeedgz  Zg dZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d(dZd Zd	 Z	d
 Z
ed        Zed        Zd Zd Zd Zd Zeej(                  fZeeej(                  fz  Zd)dZd Zed        Zd Zd)dZd*dZd+dZed        Zd Z d)dZ!d Z"d Z#ed        Z$d Z%d Z&d  Z'd! Z(d" Z)d# Z*d$ Z+d,d%Z,d& Z-d' Z.y)-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   )i-  i.  i/  i3  i4  c                    t        |t              r|| _        nt        |      | _        || _        || _        || _        || _        || _        || _        || _	        || _
        d | _        t               | _        d | _        d | _        |	| _        d| _        || _        || _        |r't        |t(        j*                  t,        f      r|| _        |
| _        || _        t3        |d      r|| _        d| _        d | _        | j                  j9                  dd      j;                         }d |j=                  d      D        }d|v rd	| _        | j?                  |      | _         |r%| j                  s| jC                  |
      | _        y y y )Nr   readFztransfer-encoding c              3   <   K   | ]  }|j                           y wr(   )rk   )r{   encs     r%   r|   z(HTTPResponse.__init__.<locals>.<genexpr>  s     >SSYY[>s   ri   chunkedTdecode_content)"
isinstancer	   headersstatusversionreasonstrictr   retriesenforce_content_length
auto_close_decoderr   _decoded_buffer_body_fp_original_response_fp_bytes_readmsg_request_urlr   string_typesrQ   _pool_connectionr^   r   
chunk_leftr   lowerrj   _init_lengthlength_remainingr   )r$   bodyr   r   r   r   r   preload_contentr   original_responsepool
connectionr   r   r   request_methodrequest_urlr   tr_encrq   s                       r%   r&   zHTTPResponse.__init__}  se   * g~."DL)'2DL,&<#$  01
"3'Jtc&6&6%>?DJ
%4 DH !!"5r:@@B>FLL,=>		!DL !% 1 1. A 4::.ADJ $.?r   c                 j    | j                   | j                  v r| j                  j                  d      S y)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   r#   s    r%   get_redirect_locationz"HTTPResponse.get_redirect_location  s.     ;;$000<<##J//r   c                     | j                   r| j                  sy | j                   j                  | j                         d | _        y r(   )r   r   	_put_connr#   s    r%   release_connzHTTPResponse.release_conn  s4    zz!1!1

T--.r   c                 d    	 | j                          y# t        t        t        t        f$ r Y y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   SocketErrorr
   r   r#   s    r%   
drain_connzHTTPResponse.drain_conn  s+    	IIK;mD 		s    //c                 p    | j                   r| j                   S | j                  r| j                  d      S y )NT)cache_content)r   r   r   r#   s    r%   r3   zHTTPResponse.data  s2     ::::88994900 r   c                     | j                   S r(   )r   r#   s    r%   r   zHTTPResponse.connection  s    r   c                 ,    t        | j                        S r(   )r   r   r#   s    r%   isclosedzHTTPResponse.isclosed  s    DHH%%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   r#   s    r%   tellzHTTPResponse.tell  s     """r   c                    | j                   j                  d      }|| j                  rt        j	                  d       y	 t        |j                  d      D cg c]  }t        |       c}      }t        |      dkD  rt        d|z        |j                         }|dk  rd}	 	 t        | j                        }|dv sd	|cxk  rd
k  sn |dk(  rd}|S c c}w # t        $ r d}Y Bw xY w# t        $ r d}Y =w xY w)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.ri   r   z8Content-Length contained multiple unmatching values (%s)r   )   i0  d      HEAD)r   r   r   logwarningsetrj   intrT   r   r   r   r   )r$   r   lengthvallengthsr   s         r%   r   zHTTPResponse._init_length  s    !!"23||  " 6<<3DECs3xEFw<!#'139:  ! A:!F	%F
 Z3&#63#6.F:RF1 F    	F	s6   C C+3C 'C, C C)(C),C:9C:c                    | j                   j                  dd      j                         }| j                  || j                  v rt        |      | _        yd|v re|j                  d      D cg c].  }|j                         | j                  v r|j                         0 }}t        |      rt        |      | _        yyyyc c}w )z=
        Set-up the _decoder attribute if necessary.
        content-encodingr   Nri   )	r   r   r   r   CONTENT_DECODERSrm   rj   rk   rT   )r$   content_encodingrr   rq   s       r%   _init_decoderzHTTPResponse._init_decoder/  s      <<++,>CIIK== 4#8#88 ,-= >(( .33C8wwyD$9$99 GGI	 
 y>$01A$BDM " ) !s   -3Cc                 6   |s|S ||rd}	 | j                   r| j                   j                  ||      }|r|| j                         z  }|S # | j                  $ r>}| j                  j	                  dd      j                         }t        d|z  |      d}~ww xY w)a:  
        Decode the data passed in and potentially flush the decoder.

        ``max_length`` (CVE-2025-66471) bounds how many decoded bytes a single
        call may emit: ``None`` (or a flush) means no limit; ``0`` means decode
        nothing now and retain the input; a positive value caps the output.
        Nr;   r   r   zEReceived response with content-encoding: %s, but failed to decode it.)r   r1   DECODER_ERROR_CLASSESr   r   r   r   _flush_decoder)r$   r3   r   flush_decoderr4   rr   r   s          r%   _decodezHTTPResponse._decodeF  s     KJ		}}}}//jA D''))D )) 	#||//0BBGMMO')9: 	s   (A B9BBc                     | j                   r8| j                   j                  d      }|| j                   j                         z   S y)zk
        Flushes the decoder. Should only be called if the decoder is actually
        being used.
        r   )r   r1   rd   )r$   bufs     r%   r   zHTTPResponse._flush_decoderc  s:    
 ==--**3/C,,...r   c              #   B  K   d}	 	 d d}|sL| j                  r| j                  j                          | j                  r| j                  j                          | j                  r,| j                  j                         r| j                          yyy# t         $ r t        | j                  dd      t        $ r4}dt	        |      vrt        |      t        | j                  dd      d}~wt        t        f$ r}t        d|z  |      d}~ww xY w# |sL| j                  r| j                  j                          | j                  r| j                  j                          | j                  r,| j                  j                         r| j                          w w w xY w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: %rT)SocketTimeoutr   r   r
   strr   r   r   r   r   closer   r   r   )r$   
clean_exitrr   s      r%   _error_catcherzHTTPResponse._error_catchern  s     
+	$D* J  **++113
 ##$$**, &&4+B+B+K+K+M!!# ,N&M ! L 'tzz49JKK L-SV;"1+%&tzz49JKK!;/ D#$;a$?CCD  **++113
 ##$$**, &&4+B+B+K+K+M!!# ,N&sF   FB D BF(D</C++D=DDD BFFc                 R   | j                   sJ d}|r||kD  s| j                  r| j                  |kD  rt        j                  st        j                  st
        j                  dk  rt        j                         }d}||dk7  r_|t        ||      }||z  }n|}| j                   j                  |      }|s	 |j                         S |j                  |       ~|Y|dk7  r_|j                         S || j                   j                  |      S | j                   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   r   )r   r   r   IS_SECURETRANSPORTIS_PYOPENSSLsysversion_infor   r   minr   r   r   )r$   amt	c_int_maxr   max_chunk_amt	chunk_amtr3   s          r%   _fp_readzHTTPResponse._fp_read  s    xxx	 y))d.C.Ci.O++""c&6&6&@ZZ\F $M+? #C 7I9$C -Ixx}}Y/ ??$$ T" + ??$$ *-488==%MdhhmmoMr   c                    | j                   yt        | j                   dd      }| j                         5  |s| j                  |      nd}|[|dk7  rV|sT| j                   j	                          | j
                  r.| j                  dvr t        | j                  | j                        ddd       rH| xj                  t        |      z  c_        | j                  | xj                  t        |      z  c_        |S # 1 sw Y   UxY w)a
  
        Read ``amt`` bytes of the *raw* (still-encoded) response body off the
        socket, taking care of length bookkeeping and closing the connection
        once the body is exhausted. Returns ``None`` if there is no file
        object to read from.
        NclosedFr   r   )r   N)
r   r*   r  r  r   r   r   r   r   rT   )r$   r
  	fp_closedr3   s       r%   	_raw_readzHTTPResponse._raw_read  s     88DHHh6	  " 	U-64==%CD3!8D  ..43H3H Q 4 ))<)<d>S>STT+	U. 3t9,$$0%%T2%9	U 	Us   A3C<<Dc           	         | j                          || j                  }|r|dk  rd}|d}| j                  \| j                  j                  rF| j	                  d|d|t        | j                        z
        }| j                  j                  |       t        | j                        |k\  r| j                  j                  |      S | j                  |      }|du xs
 |dk7  xr | }|s<t        | j                        dk(  r$| j                  | j                  j                  s|S || j	                  |||      }|r|| _
        |S | j	                  ||||t        | j                        z
        }| j                  j                  |       t        | j                        |k  rt|rr| j                  |      }| j	                  ||||t        | j                        z
        }| j                  j                  |       t        | j                        |k  r|rrt        | j                        dk(  ry| j                  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.)
        Nr   Fr   )r   r4   )r4   )r   r   r   r9   r   rT   r   r   r   r  r   )r$   r
  r   r   decoded_datar3   r   s          r%   r   zHTTPResponse.read   s;   * 	!!00N37C?!M }}(T]]-N-N#||""'"S)=)=%>>	  ,   $$((64''(C/++//44~~c"t>q(=X D(()Q.]].4==3T3TK;<<nmDD!
: 1  <<T%9%9!::	 ( L   $$\2d**+c1d~~c*#||"!"S)=)=%>>	  ,   $$((6 d**+c1d 4''(A-''++C0Dr   c              #     K   | j                   r-| j                         r| j                  ||      D ]  }|  yt        | j                        r:t        | j                        dkD  s"| j                  | j                  j                  rm| j                  ||      }|r| t        | j                        s/t        | j                        dkD  rH| j                  | j                  j                  rkyyyyw)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.
        r   r   N)r
  r   )
r   supports_chunked_readsread_chunkedr   r   rT   r   r   r9   r   )r$   r
  r   liner3   s        r%   streamzHTTPResponse.stream\  s       <<D779))#n)M 
 !*t++,q0MM-$--2S2SyySyHJ !*t++,q0MM-$--2S2S-2S-s   B7C::C:"C:6C:c                 2   |j                   }t        |t              s?t        j                  rt        j
                  |      }nt        |j                               }t        |dd      } | d|||j                  |j                  |j                  ||d|}|S )a  
        Given an :class:`http.client.HTTPResponse` instance ``r``, return a
        corresponding :class:`urllib3.response.HTTPResponse` object.

        Remaining parameters are passed to the HTTPResponse constructor, along
        with ``original_response=r``.
        r   r   )r   r   r   r   r   r   r   rA   )r   r   r	   r   PY2from_httplibitemsr*   r   r   r   )ResponseClsrresponse_kwr   r   resps         r%   r  zHTTPResponse.from_httplib  s     %%'>2ww(55g>(9 Ha( 	
88II88	
 	
 r   c                 R    t        j                  dt        d       | j                  S )Nz|HTTPResponse.getheaders() is deprecated and will be removed in urllib3 v2.1.0. Instead access HTTPResponse.headers directly.rD   category
stacklevel)warningswarnDeprecationWarningr   r#   s    r%   
getheaderszHTTPResponse.getheaders  s&    O'		
 ||r   c                 r    t        j                  dt        d       | j                  j	                  ||      S )NzHTTPResponse.getheader() is deprecated and will be removed in urllib3 v2.1.0. Instead use HTTPResponse.headers.get(name, default).rD   r#  )r&  r'  r(  r   r   )r$   r,   defaults      r%   	getheaderzHTTPResponse.getheader  s3    V'		
 ||g..r   c                     | j                   S r(   )r   r#   s    r%   infozHTTPResponse.info  s    ||r   c                     | j                   s| j                  j                          | j                  r| j                  j                          | j                  s t
        j                  j                  |        y y r(   )r  r   r   r   r   r   IOBaser#   s    r%   r   zHTTPResponse.close  sN    {{HHNN""$IIOOD! r   c                 @   | j                   s)t        j                  j                  j	                  |       S | j
                  yt        | j
                  d      r| j
                  j                         S t        | j
                  d      r| j
                  j                  S y)NTr   r  )r   r   r0  r  __get__r   r^   r   r#   s    r%   r  zHTTPResponse.closed  sq    99##++D11XXTXXz*88$$&&TXXx(88??"r   c                     | j                   t        d      t        | j                   d      r| j                   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   IOErrorr^   r4  r#   s    r%   r4  zHTTPResponse.fileno  sI    88IJJTXXx(88??$$0 r   c                     | j                   It        | j                   d      r2t        | j                   dd      s| j                   j                         S y y y )Nrd   r  F)r   r^   r*   rd   r#   s    r%   rd   zHTTPResponse.flush  sJ    HH '*DHHh688>>## 7 + !r   c                      y)NTrA   r#   s    r%   readablezHTTPResponse.readable  s    r   c                     | j                  t        |            }t        |      dk(  ry||d t        |       t        |      S rt   )r   rT   )r$   btemps      r%   readintozHTTPResponse.readinto  s;    yyQ t9>!AkD	Nt9r   c                 .    t        | j                  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().
        fp)r^   r   r#   s    r%   r  z#HTTPResponse.supports_chunked_reads  s     txx&&r   c                    | j                   y | j                  j                  j                         }|j	                  dd      d   }	 t        |d      | _         y # t        $ r | j                          t        | |      w xY w)N   ;r   r   rK   )	r   r   r>  readlinerj   r   r   r   r   )r$   r  s     r%   _update_chunk_lengthz!HTTPResponse._update_chunk_length  ss     ??&xx{{##%zz$"1%	1!$mDO 	1JJL$T400	1s   A &B c                 V   d }|K| j                   j                  | j                        }|}| j                   j                  d       d | _        |S || j                  k  r3| j                   j                  |      }| j                  |z
  | _        |}|S || j                  k(  rA| j                   j                  |      }| j                   j                  d       d | _        |}|S | j                   j                  | j                        }| j                   j                  d       d | _        |S )NrD   )r   
_safe_readr   )r$   r
  returned_chunkr   values        r%   _handle_chunkzHTTPResponse._handle_chunk  s
   ;HH''8E"NHH""DO  4??"HH'',E"oo3DO"N  DOO#HH'',EHH""DO"N
  "XX00ANHH""DOr   c              #     K   | j                          | j                  st        d      | j                         st	        d      | j                         5  | j                  r9t        | j                        r$| j                  j                          	 ddd       y| j                  j                  
	 ddd       y	 | j                          | j                  dk(  rn| j                  |      }| j                  ||d|      }|r| |rc| j                  W| j                  j                   rA| j                  d|d|      }|sn)| |r#| j                  | j                  j                   rA|r| j#                         }|r| 	 | j                  j                  j%                         }|sn|dk(  rn.| j                  r| j                  j                          ddd       y# 1 sw Y   yxY ww)	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.Nr   F)r   r   r4   r   s   
)r   r   r   r  r   r  r   r   r   r   r>  rB  r   rG  r   r   r9   r   rA  )r$   r
  r   r   decodedr  s         r%   r  zHTTPResponse.read_chunked  s     	||$B  **,*P 
   " =	0&&+>t?V?V+W''--/	=	0 =	0 xx{{"=	0 =	0 ))+??a'**3/,,#1"'"	 '  !M
 #199"ll'5&+#&	 + G #!M #199' >  --/!M xx{{++-7?  &&''--/{=	0 =	0 =	0s>   AG0=G$	G0G$2	G0;B1G$-A.G$	G0$G-)G0c                     | j                   Bt        | j                   j                        r#| j                   j                  d   j                  S | 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;   )r   rT   historyredirect_locationr   r#   s    r%   geturlzHTTPResponse.geturlu  sF     <<#DLL,@,@(A<<''+===$$$r   c              #   .  K   g }| j                  d      D ]d  }d|v rM|j                  d      }dj                  |      |d   z   dz    |dd D ]	  }|dz     |d   r|d   g}Qg }T|j                  |       f |rdj                  |       y y w)NTr      
r   r   r   r;   )r  rj   joinr   )r$   r   r   xs       r%   __iter__zHTTPResponse.__iter__  s     [[[5 	%E~E*hhv&q1E99q $Ae)O$9#Bi[FFe$	% ((6"" s   BB)r   Nr   r   Nr   TTNNNNNFNNTr(   )NNF)i   N)NN)/r=   r>   r?   r~   r   r\   r   r&   r   r   r   r@   r3   r   r   r   r   r   r5  r    r   r   r   r   r   r  r  r  r   r  classmethodr  r)  r,  r.  r   r  r4  rd   r8  r<  r  rB  rG  r  rM  rR  rA   r   r%   r   r   W  s   @ 	*TF"1 $%EBN 	 1 1    &#2hC& %djj1&,,0:	 5$ 5$n.N`(TZx!F  @/" 
 
	$'1,X0t	%#r   r   )4
__future__r   r   r   loggingr  r&  r    
contextlibr   socketr   r   r   r   r\   r   r   _collectionsr	   r   r
   r   
exceptionsr   r   r   r   r   r   r   r   r   r   packagesr   util.responser   r   	getLoggerr=   r   objectr   rC   rI   rZ   rf   rm   r   r0  r   rA   r   r%   <module>r^     s    &  	  
   % ' +	  ( 3    <g!:
V :
zv A+& A+H 
 63B6 3Bl
Hv HVx#299 x#r   