HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/urllib3/__pycache__/response.cpython-310.pyc
o

;j���@svddlmZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZddlmZddlmZe	jrKddlmZzzddlZWn
ey_ddlZYnwWneyldZYnwdd	lmZdd
lmZddlmZddl m!Z!m"Z"m#Z#dd
l$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/ddl0m1Z1m2Z2ddl3m4Z4e	jr�ddl5m6Z6e�7e8�Z9Gdd�d�Z:Gdd�de:�Z;Gdd�d�Z<Gdd�de:�Z=edur�Gdd�de:�Z>zej?dkr�ddl@mAZAnddlBmAZAWne�y	dZCYnwdZCGdd �d e:�ZDGd!d"�d"e:�ZEd.d&d'�ZFGd(d)�d)�ZGGd*d+�d+ejH�ZIGd,d-�d-eI�ZdS)/�)�annotationsN)�contextmanager)�HTTPMessage)�HTTPResponse)�timeout�)�BaseHTTPConnection)�util)�
_TYPE_BODY)�HTTPHeaderDict)�BaseSSLError�HTTPConnection�
HTTPException)�BodyNotHttplibCompatible�DecodeError�DependencyWarning�	HTTPError�IncompleteRead�InvalidChunkLength�
InvalidHeader�
ProtocolError�ReadTimeoutError�ResponseNotChunked�SSLError)�is_fp_closed�is_response_to_head)�Retry)�HTTPConnectionPoolc@s0eZdZdddd�Zedd
d��Zddd
�ZdS)�ContentDecoder����data�bytes�
max_length�int�returncC�t���N��NotImplementedError��selfr r"�r+�D/opt/saltstack/salt/lib/python3.10/site-packages/urllib3/response.py�
decompress7�zContentDecoder.decompress�boolcCr%r&r'�r*r+r+r,�has_unconsumed_tail:�z"ContentDecoder.has_unconsumed_tailcCr%r&r'r0r+r+r,�flush>r.zContentDecoder.flushN�r�r r!r"r#r$r!�r$r/�r$r!)�__name__�
__module__�__qualname__r-�propertyr1r3r+r+r+r,r6s
rc@�:eZdZddd�Zddd
d�Zedd
d��Zddd�ZdS)�DeflateDecoderr$�NonecCs d|_d|_d|_t��|_dS)NT�)�
_first_try�_first_try_data�_unfed_data�zlib�
decompressobj�_objr0r+r+r,�__init__CszDeflateDecoder.__init__rr r!r"r#cCs�|j|}d|_|s|jjs|S|}|dkrd}n	|dkr"||_dS|js1|jj|jj||d�S|j|7_z|jj||d�}|rId|_d|_|WStjyqd|_t�tj	�|_z|j|j|d�Wd|_YSd|_ww)Nr?r�r"F)
rBrE�unconsumed_tailr@r-rArC�errorrD�	MAX_WBITS)r*r r"Zoriginal_max_lengthZdecompressedr+r+r,r-Is<
���zDeflateDecoder.decompressr/cCst|j�pt|jj�o|jSr&)r/rBrErHr@r0r+r+r,r1ss
�z"DeflateDecoder.has_unconsumed_tailcC�
|j��Sr&�rEr3r0r+r+r,r3y�
zDeflateDecoder.flushN�r$r>r4r5r6r7�r8r9r:rFr-r;r1r3r+r+r+r,r=Bs
*r=c@seZdZdZdZdZdS)�GzipDecoderStaterr�N)r8r9r:�FIRST_MEMBER�
OTHER_MEMBERS�SWALLOW_DATAr+r+r+r,rP}srPc@r<)�GzipDecoderr$r>cCs$t�dtj�|_tj|_d|_dS)N�r?)rCrDrJrErPrR�_state�_unconsumed_tailr0r+r+r,rF�s
zGzipDecoder.__init__rr r!r"r#cCst�}|jtjkr
t|�S|dkr|j|7_dS|j|}|s)|jjr)t|�S	z||jj|t	|t
|�d�d�7}Wntjy[|j}tj|_d|_|tj
krZt|�YS�w|jjpc|jj|_}|dkrvt
|�|krv	t|�S|s|t|�S|jjr�tj
|_t�dtj�|_q*)Nrr?TrGrV)�	bytearrayrWrPrTr!rXrE�eofr-�max�lenrCrIrSrH�unused_datarDrJ)r*r r"�retZprevious_stater+r+r,r-�sB
�
��
��zGzipDecoder.decompressr/cC�
t|j�Sr&)r/rXr0r+r+r,r1��
zGzipDecoder.has_unconsumed_tailcCrKr&rLr0r+r+r,r3�rMzGzipDecoder.flushNrNr4r5r6r7rOr+r+r+r,rU�s
2rUc@sFeZdZddd�Zddd
d�Zddd
d�Zeddd��Zddd�ZdS)�
BrotliDecoderr$r>cCs>t��|_t|jd�rt|d|jj�dSt|d|jj�dS)Nr-�_decompress)�brotliZDecompressorrE�hasattr�setattrr-�processr0r+r+r,rF�s
zBrotliDecoder.__init__rr r!�output_buffer_limitr#cCr%r&r')r*r rgr+r+r,rb�r.zBrotliDecoder._decompressr"cCsNz|dkr
|j||d�WS|�|�WSty&t�dt�|�|�YSw)Nr)rgz;Brotli >= 1.2.0 is required to prevent decompression bombs.)rb�	TypeError�warnings�warnrr)r+r+r,r-�s��zBrotliDecoder.decompressr/cCs$z|j��WStyYdSw)NF)rEZcan_accept_more_data�AttributeErrorr0r+r+r,r1�s
�z!BrotliDecoder.has_unconsumed_tailcCst|jd�r|j��SdS)Nr3r?)rdrEr3r0r+r+r,r3�s
zBrotliDecoder.flushNrNr4)r r!rgr#r$r!r5r6r7)	r8r9r:rFrbr-r;r1r3r+r+r+r,ra�s
ra)��)�zstdFTc@r<)�ZstdDecoderr$r>cCst��|_dSr&)rn�ZstdDecompressorrEr0r+r+r,rF��zZstdDecoder.__init__rr r!r"r#cCs�|s|jsdS|jjr|jj|}t��|_|jj||d�}t|�}|g}|jjrw|jjrw|dks5||krw|jj}|jjsBt��|_|jj||dkrN||ndd�}t|�}rb|�	|�||7}n|jjrgn|jjrw|jjrw|dks5||ks5d�
|�S)Nr?rGrr)r1rErZr]rnrpr-r\�needs_input�append�join)r*r r"�part�lengthZ
data_partsr]Zpart_lengthr+r+r,r-�s>

��
�

���
zZstdDecoder.decompressr/cCs|jjp|jjpt|jj�Sr&)rErrrZr/r]r0r+r+r,r1 s�zZstdDecoder.has_unconsumed_tailcCs|jjstd��dS)NzZstandard data is incompleter?)rErZrr0r+r+r,r3&szZstdDecoder.flushNrNr4r5r6r7rOr+r+r+r,ro�s
"roc@sBeZdZdZdZddd�Zdd
d�Zdddd�Zeddd��Z	dS)�MultiDecodera
    From RFC7231:
        If one or more encodings have been applied to a representation, the
        sender that applied the encodings MUST generate a Content-Encoding
        header field that lists the content codings in the order in which
        they were applied.
    ��modes�strr$r>cCsPdd�|�d�D�}t|�|jkrtdt|��d|j����dd�|D�|_dS)NcSsg|]}|���qSr+��strip)�.0�mr+r+r,�
<listcomp>:�z)MultiDecoder.__init__.<locals>.<listcomp>�,z)Too many content encodings in the chain: z > cSsg|]}t|��qSr+)�_get_decoder�r}�er+r+r,r@r�)�splitr\�max_decode_linksr�	_decoders)r*ry�	encodingsr+r+r,rF9s���zMultiDecoder.__init__r!cCs|jd��S�Nr)r�r3r0r+r+r,r3BrqzMultiDecoder.flushrr r"r#cCs�|dkrt|j�D]}|�|�}q	|St�}	d}t|j�D]}|j||t|�d�}|r/d}q||7}|r<t|�|kr@t|�Sd}q)NrTFrGr?)�reversedr�r-rYr\r!)r*r r"�dr^Zany_datar+r+r,r-Es"��zMultiDecoder.decompressr/cCstdd�|jD��S)Ncss�|]}|jVqdSr&)r1)r}r�r+r+r,�	<genexpr>as�z3MultiDecoder.has_unconsumed_tail.<locals>.<genexpr>)�anyr�r0r+r+r,r1_sz MultiDecoder.has_unconsumed_tailN)ryrzr$r>r7r4r5r6)
r8r9r:�__doc__r�rFr3r-r;r1r+r+r+r,rw,s


	rw�moderzr$cCsLd|vrt|�S|dvrt�Stdur|dkrt�Str#|dkr#t�St�S)Nr�)�gzip�x-gzip�brrn)rwrUrcra�HAS_ZSTDror=)r�r+r+r,r�dsr�c@sBeZdZdZddd�Zddd�Zddd�Zddd�Zddd�ZdS)�BytesQueueBuffera�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()
    r$r>cCst��|_d|_dSr�)�collections�deque�buffer�_sizer0r+r+r,rF�s

zBytesQueueBuffer.__init__r#cC�|jSr&)r�r0r+r+r,�__len__�r.zBytesQueueBuffer.__len__r r!cCs"|j�|�|jt|�7_dSr&)r�rsr�r\�r*r r+r+r,�put�szBytesQueueBuffer.put�nc	Cs*|dkrdS|js
td��|dkrtd��t|jd�|kr2t|jdt�r2|j|8_|j��Sd}t�	�}||kr�||}|j��}t|�}||krut
|�}|d|�||d�}}|�|�|j�|�|j|8_	|�
�S|�|�|j|8_||7}|js�	|�
�S||ks<|�
�S)Nrr?zbuffer is emptyzn should be > 0)r��RuntimeError�
ValueErrorr\�
isinstancer!r��popleft�io�BytesIO�
memoryview�write�
appendleft�getvalue)	r*r�Zfetchedr^�	remaining�chunkZchunk_lengthZ
left_chunkZright_chunkr+r+r,�get�s>"


	
��zBytesQueueBuffer.getcs~|j��s|jdksJ�dSt��dkr"���}t|t�r!|��}nt��}|�	�fdd�t
t���D��|��}d|_|S)Nrr?rc3s�|]}���VqdSr&)r�)r}�_�r�r+r,r����z+BytesQueueBuffer.get_all.<locals>.<genexpr>)r�r�r\�popr�r��tobytesr�r��
writelines�ranger�)r*�resultr^r+r�r,�get_all�s
� zBytesQueueBuffer.get_allNrN�r$r#)r r!r$r>)r�r#r$r!r7)	r8r9r:r�rFr�r�r�r�r+r+r+r,r�vs



#r�c@s�eZdZUgd�Zeduredg7Zeredg7Zgd�Zeej	fZ
ded<edur0e
ej	f7Z
er8e
ej
f7Z
ddd�d]dd�Zd^dd�Zed_dd ��Zd`d"d#�Zedad$d%��Zejdbd'd%��Zedcd)d*��Zeddd+d,��Zejded-d,��Z	dfdgd3d4�Z			5dhdid7d8�Z		djdkd9d:�Z		djdgd;d<�Zdld=d>�Zdld?d@�ZdldAdB�ZdldCdD�ZdldEdF�Z	dmdndJdK�Z d_dLdM�Z!dodPdQ�Z"dpdSdT�Z#dmdqdWdX�Z$dpdYdZ�Z%dad[d\�Z&dS)r�BaseHTTPResponse)r�r�ZdeflateNr�rn)i-i.i/i3i4ztuple[type[Exception], ...]�DECODER_ERROR_CLASSES)�headers�retriesr��>typing.Mapping[str, str] | typing.Mapping[bytes, bytes] | None�statusr#�version�version_stringrz�reason�
str | None�decode_contentr/�request_urlr��Retry | Noner$r>cCs�t|t�r	||_nt|�|_||_||_||_||_||_d|_||_	||_
d|_|j�dd��
�}	dd�|	�d�D�}
d|
vrCd|_d|_|dS)	NFztransfer-encoding�css�|]}|��VqdSr&r{)r}�encr+r+r,r��r�z,BaseHTTPResponse.__init__.<locals>.<genexpr>r��chunkedT)r�rr�r�r�r�r�r��_has_decoded_content�_request_urlr�r�r��lowerr��_decoder)r*r�r�r�r�r�r�r�r��tr_encr�r+r+r,rF�s$

zBaseHTTPResponse.__init__�"str | None | typing.Literal[False]cCs|j|jvr|j�d�SdS)a
        Should we redirect and where to?

        :returns: Truthy redirect location string if we got a redirect status
            code and valid location. ``None`` if redirect status and no
            location. ``False`` if not a redirect status code.
        �locationF)r��REDIRECT_STATUSESr�r�r0r+r+r,�get_redirect_location�sz&BaseHTTPResponse.get_redirect_locationr!cCr%r&r'r0r+r+r,r r2zBaseHTTPResponse.data�
typing.AnycCs|j�d�}t�|�S)a�
        Deserializes the body of the HTTP response as a Python object.

        The body of the HTTP response must be encoded using UTF-8, as per
        `RFC 8529 Section 8.1 <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.
        zutf-8)r �decode�_json�loadsr�r+r+r,�jsons
zBaseHTTPResponse.jsoncCr%r&r'r0r+r+r,�urlr2zBaseHTTPResponse.urlr�cCr%r&r'�r*r�r+r+r,r�r2�BaseHTTPConnection | NonecCr%r&r'r0r+r+r,�
connection"r2zBaseHTTPResponse.connectioncCr�r&)�_retriesr0r+r+r,r�&r2zBaseHTTPResponse.retriescCs&|dur|jr|jdj|_||_dS)Nr)�historyZredirect_locationr�r�)r*r�r+r+r,r�*s
��amt�
int | None�bool | None�typing.Iterator[bytes]cCr%r&r'�r*r�r�r+r+r,�stream1szBaseHTTPResponse.streamF�
cache_contentcCr%r&r')r*r�r�r�r+r+r,�read6�zBaseHTTPResponse.readcCr%r&r'r�r+r+r,�read1>�zBaseHTTPResponse.read1cCr%r&r'r�r+r+r,�read_chunkedEr�zBaseHTTPResponse.read_chunkedcCr%r&r'r0r+r+r,�release_connLr.zBaseHTTPResponse.release_conncCr%r&r'r0r+r+r,�
drain_connOr.zBaseHTTPResponse.drain_conncCr%r&r'r0r+r+r,�shutdownRr.zBaseHTTPResponse.shutdowncCr%r&r'r0r+r+r,�closeUr.zBaseHTTPResponse.closecsr�j�dd���}�jdur3|�jvrt|��_dSd|vr5�fdd�|�d�D�}|r7t|��_dSdSdSdS)z=
        Set-up the _decoder attribute if necessary.
        �content-encodingr�Nr�cs"g|]
}|���jvr|���qSr+)r|�CONTENT_DECODERSr�r0r+r,rcs
�z2BaseHTTPResponse._init_decoder.<locals>.<listcomp>)r�r�r�r�r�r�r�)r*�content_encodingr�r+r0r,�
_init_decoderXs


��zBaseHTTPResponse._init_decoderr �
flush_decoderr"c
Cs�|s|jr	td��|S|dus|rd}z|jr"|jj||d�}d|_Wn|jyA}z|j�dd���}td||�|�d}~ww|rJ||�	�7}|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.NrrGTr�r�zEReceived response with content-encoding: %s, but failed to decode it.)
r�r�r�r-r�r�r�r�r�_flush_decoder)r*r r�r�r"r�r�r+r+r,�_decodeks8
�������zBaseHTTPResponse._decodecCs |jr|j�d�|j��SdS)zk
        Flushes the decoder. Should only be called if the decoder is actually
        being used.
        r?)r�r-r3r0r+r+r,r��szBaseHTTPResponse._flush_decoder�b�bytearray | memoryview[int]cCs6|�t|��}t|�dkrdS||dt|��<t|�Sr�)r�r\)r*r�Ztempr+r+r,�readinto�s
zBaseHTTPResponse.readintorcCr�r&�r�r0r+r+r,�
getheaders�r.zBaseHTTPResponse.getheaders�name�defaultcCs|j�||�Sr&)r�r�)r*r�r�r+r+r,�	getheader�rqzBaseHTTPResponse.getheadercCr�r&r�r0r+r+r,�info�r.zBaseHTTPResponse.infocCr�r&)r�r0r+r+r,�geturl�r.zBaseHTTPResponse.geturl)r�r�r�r#r�r#r�rzr�r�r�r/r�r�r�r�r$r>)r$r�r7)r$r��r$r��r�r�r$r>)r$r�)r$r�)r�r�r$r>�r�N)r�r�r�r�r$r��NNF�r�r�r�r�r�r/r$r!�NN�r�r�r�r�r$r!rNr&)
r r!r�r�r�r/r"r�r$r!)r�r�r$r#)r$r)r�rzr�r�r$r�)'r8r9r:r�rcr�r��IOErrorrCrIr��__annotations__rnZ	ZstdErrorrFr�r;r r�r��setterr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r+r+r+r,r��sl


�
#
��
�	�




�
%


	
r�cs�eZdZdZ																		didj�fd'd(�
Zdkd)d*�Zdkd+d,�Zedld.d/��Zedmd0d1��Z	dnd2d3�Z
dod4d5�Zdpd7d8�Ze
dqd:d;��Z	drd<d=�dsd@dA�Z	drd<d=�dsdBdC�Z			<dtdudFdG�Z		dvdwdHdI�Z	dxdydLdM�ZdndNdO�ZdkdPdQ�ZdkdRdS�ZedndTdU��ZdodVdW�ZdkdXdY�ZdndZd[�Zdkd\d]�Zdzd^d_�Z	dvdyd`da�Zed{dbdc��Zejd|dedc��Zd}dgdh�Z �Z!S)~ra�
    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�Nr�HTTP/?T�bodyr
r�r�r�r#r�r�rzr�r��preload_contentr/r��original_response�_HttplibHTTPResponse | None�pool�HTTPConnectionPool | Noner��HTTPConnection | None�msg�_HttplibHTTPMessage | Noner�r��enforce_content_length�request_methodr��
auto_close�
sock_shutdown�#typing.Callable[[int], None] | Noner$r>c
s�t�j||||||||
d�||_||_d|_d|_d|_|	|_d|_||_	|r2t
|ttf�r2||_|
|_
||_t|d�r@||_||_d|_|�|�|_t�|_|r^|js`|j|d�|_dSdSdS)N)r�r�r�r�r�r�r�r�Frr��r�)�superrFrr�_body�_uncached_read_occurred�_fp�_original_response�_fp_bytes_readrr�rzr!�_pool�_connectionrd�_sock_shutdown�
chunk_left�_init_length�length_remainingr��_decoded_bufferr�)r*rr�r�r�r�r�rr�r	rr�rr�rrr�rr��	__class__r+r,rF�s>�

�zHTTPResponse.__init__cCs(|jr|jsdS|j�|j�d|_dSr&)rrZ	_put_connr0r+r+r,r�s
zHTTPResponse.release_conncCsDz|��Wn
ttttfyYnw|jr t�|_d|_dSdS)z�
        Read and discard any remaining HTTP response data in the response connection.

        Unread data in the HTTPResponse connection blocks the connection from being released back to the pool.
        N)	�	_raw_readr�OSErrorrrr�r�r"r�r0r+r+r,r�s�
�zHTTPResponse.drain_connr!cCs"|jr|jS|jr|jdd�SdS)NT)r�)rrr�r0r+r+r,r *s
zHTTPResponse.datacCr�r&)rr0r+r+r,r�5r2zHTTPResponse.connectioncCr_r&)rrr0r+r+r,�isclosed9rMzHTTPResponse.isclosedcCr�)z�
        Obtain the number of bytes pulled over the wire so far. May differ from
        the amount of content returned by :meth:`HTTPResponse.read`
        if bytes are encoded on the wire (e.g, compressed).
        )rr0r+r+r,�tell<r�zHTTPResponse.tellr�cCs�|j�d�}|durC|jrt�d�dSzdd�|�d�D�}t|�dkr+td|��|��}Wnt	y;d}Yn
w|d	krBd}nd}zt
|j�}Wnt	yWd	}Ynw|d
vskd|krfdkskn|d
krmd	}|S)zM
        Set initial length value for Response content if available.
        zcontent-lengthNz�Received response with both Content-Length and Transfer-Encoding set. This is expressly forbidden by RFC 7230 sec 3.3.2. Ignoring Content-Length and attempting to process response as Transfer-Encoding: chunked.cSsh|]}t|��qSr+)r#)r}�valr+r+r,�	<setcomp>_r�z,HTTPResponse._init_length.<locals>.<setcomp>r�rz8Content-Length contained multiple unmatching values (%s)r)��i0�d���HEAD)r�r�r��log�warningr�r\rr�r�r#r�)r*r�content_lengthZlengthsrvr�r+r+r,r Ds>������&zHTTPResponse._init_length�typing.Generator[None]c
csl�d}z�zdVWndty}zt|jdd�|�d}~wty-}zt|�|�d}~wtyW}z|jdurH|jdurH|j|jkrHd}nd|��}t||�|�d}~wt	t
fym}z	td|��|�|�d}~wwd}W|s�|jr{|j��|j
r�|j
��|jr�|j��r�|��dSdSdS|s�|jr�|j��|j
r�|j
��|jr�|j��r�|��www)z�
        Catch low-level python exceptions, instead re-raising urllib3
        variants, so that low-level exceptions are not leaked in the
        high-level api.

        On exit, release the connection back to the pool.
        FNzRead timed out.z!Response may not contain content.zConnection broken: T)�
SocketTimeoutrrrrr�expected�partialrrr&rr�rr'r�)r*Z
clean_exitr��argr+r+r,�_error_catcher|sP�	
�
�


���

��


�zHTTPResponse._error_catcherF�r�r�r�cCs|jsJ�d}|r
||ks|dura|jra|j|kratjra|r$|j�|�St��}d}|dus2|dkr]|dur@t||�}||8}n|}|j�|�}|sO	|�
�S|�	|�~|dus2|dks2|�
�S|rr|durm|j�|�S|j��S|dur||j�|�S|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.

        This happens to urllib3 injected with pyOpenSSL-backed SSL-support.
        i���Nir)rr!r	ZIS_PYOPENSSLr�r�r��minr�r�r�)r*r�r�Z	c_int_maxr�Z
max_chunk_amtZ	chunk_amtr r+r+r,�_fp_read�s>
��
�


��zHTTPResponse._fp_readcCs|jdurdSt|jdd�}|���K|s|j||d�nd}|durB|dkrB|sB|j��|jrA|jdurA|jdkrAt|j|j��n|rV|dkrJ|rQ|jt	|�krV|j��Wd�n1s`wY|r~|jt	|�7_|jdur~|jt	|�8_|S)z7
        Reads `amt` of bytes from the socket.
        N�closedFr8r?r)
r�getattrr7r:r�rr!rrr\)r*r�r�Z	fp_closedr r+r+r,r%�s.
	

	�

�
�� 
zHTTPResponse._raw_readr�r�cCs�|��|dur|j}|r|dkrd}n5|durId}|jr<|jjr<t|j�|kr<|jd|d|t|j�d�}|j�|�t|j�|krI|j�|�S|�	|�}|sSd|_
|dup]|dko]|}|spt|j�dkrp|jrn|jjsp|S|dur�|�|||�}|r�t|j�dkr�|j�|�|j��}|r�|j
s�||_|S|s�|j
r�td��|S|j||||t|j�d�}|j�|�t|j�|kr�|r�|�	|�}|j||||t|j�d�}|j�|�t|j�|kr�|s�|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.)
        NrFr?�r�r"Tr�rG)r�r�r�r1r\r"r�r�r�r%rr�rr�r�)r*r�r�r��decoded_datar r�r+r+r,r�#s����
���

!���
��zHTTPResponse.readcCsJ|dur|j}|r|dkrd}|jrZ|std��|jrD|jjrD|dus*t|j�|krD|jd|d|dur:|t|j�ndd�}|j�|�t|j�dkrZ|durT|j�	�S|j�
|�S|dkr`dS|j|dd�}d|_|rp|durr|S|�
�	|}|j||||d	�}|j�|�|s�|r�n|jd
dd�}qw|dur�|j�	�S|j�
|�S)a�
        Similar to ``http.client.HTTPResponse.read1`` and documented
        in :meth:`io.BufferedReader.read1`, but with an additional parameter:
        ``decode_content``.

        :param amt:
            How much of the content to read.

        :param decode_content:
            If True, will attempt to decode the body based on the
            'content-encoding' header.
        NrzaCalling read1(decode_content=False) is not supported after read1(decode_content=True) was called.r?Fr=Tr8rGi )r�r�r�r�r1r\r"r�r�r�r�r%rr�)r*r�r�r>r r�r+r+r,r��sZ����
��

zHTTPResponse.read1r��typing.Generator[bytes]ccs��|dkrdS|jr|��r|j||d�EdHdSt|j�r-t|j�dks-|jrN|jjrP|j	||d�}|r9|Vt|j�r-t|j�dks-|jrR|jjs-dSdSdSdS)a_
        A generator wrapper for the read() method. A call will block until
        ``amt`` bytes have been read from the connection or until the
        connection is closed.

        :param amt:
            How much of the content to read. The generator will return up to
            much data per iteration, but may return less. This is particularly
            likely when using compressed data. However, the empty string will
            never be returned.

        :param decode_content:
            If True, will attempt to decode the body based on the
            'content-encoding' header.
        rNr)r�r�)
r��supports_chunked_readsr�rrr\r"r�r1r�)r*r�r�r r+r+r,r��s,��������zHTTPResponse.streamcCsdS)NTr+r0r+r+r,�readable�szHTTPResponse.readablecCs0|jstd��|jdurtd��|�tj�dS)Nz8Cannot shutdown socket as self._sock_shutdown is not setzCCannot shutdown as connection has already been released to the pool)rr�rr��socket�SHUT_RDr0r+r+r,r��s
�zHTTPResponse.shutdowncCsFd|_|js|jr|j��|jr|j��|js!tj�|�dSdSr&)rr;rr�rrr��IOBaser0r+r+r,r�s

�zHTTPResponse.closecCsP|js
tjj�|�S|jdurdSt|jd�r|j��St|jd�r&|jjSdS)NTr'r;)rr�rDr;�__get__rrdr'r0r+r+r,r;s

zHTTPResponse.closedcCs0|jdur	td��t|jd�r|j��Std��)Nz-HTTPResponse has no file to get a fileno from�filenozOThe file-like object this HTTPResponse is wrapped around has no file descriptor)rr&rdrFr0r+r+r,rFs

�zHTTPResponse.filenocCs:|jdurt|jd�rt|jdd�s|j��SdSdSdS)Nr3r;F)rrdr<r3r0r+r+r,r3)s

��
�zHTTPResponse.flushcCst|jd�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)rdrr0r+r+r,r@1sz#HTTPResponse.supports_chunked_readscCsn|jdurdS|jj��}|�dd�d}z	t|d�|_WdSty6|��|r1t||�d�t	d�d�w)N�;rrrVzResponse ended prematurely)
rrrG�readliner�r#r�r�rr)r*�liner+r+r,�_update_chunk_length:s

�z!HTTPResponse._update_chunk_lengthcCs�d}|dur|j�|j�}|}|j�d�d|_|S|jdur4||jkr4|j�|�}|j||_|}|S||jkrL|j�|�}|j�d�d|_|}|S|j�|j�}|j�d�d|_|S)NrQ)r�
_safe_readr)r*r�Zreturned_chunkr��valuer+r+r,�
_handle_chunkLs,�

��zHTTPResponse._handle_chunkccs��|��|jstd��|��std��|����|jr/t|j�r/|j��	Wd�dS|j	j
dur>	Wd�dS|dkrK	Wd�dS|rS|dkrSd}	|jr^|jjr^d}n|�
�d|_|jdkrkn|�|�}|j||d|d�}|r~|VqT|r�|��}|r�|V|j	dur�|j	j
��}|s�n
|d	kr�n|j	dus�|jr�|j��Wd�dSWd�dS1s�wYdS)
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.NrTr?F)r�r�r"s
)r�r�rr@rr7rrr�rrGr�r1rKrrrNr�r�rI)r*r�r�r��decodedrJr+r+r,r�bsp���

���


��

�	�7"�zHTTPResponse.read_chunkedcCr�)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�r0r+r+r,r��szHTTPResponse.urlr�cCs
||_dSr&rPr�r+r+r,r��r`r�ccs��g}|jdd�D]7}d|vr;|�d�}d�|�|ddV|dd�D]}|dVq&|dr8|dg}q	g}q	|�|�q	|rKd�|�VdSdS)NTr�
r?rrr)r�r�rtrs)r*r�r��chunks�xr+r+r,�__iter__�s�
�zHTTPResponse.__iter__)r�NrrrNTTNNNNNTNNTN)&rr
r�r�r�r#r�r#r�rzr�r�rr/r�r/r	r
rrr�r
rrr�r�rr/rr�r�r�rr/rrr$r>rNr7)r$r
r6r�)rr�r$r�)r$r2r&)r�r�r�r/r$r!r�rrrr�)r�r�r�r�r$r?)r�r�r$r!r�r�)r$r�)"r8r9r:r�rFr�r�r;r r�r'r(r rr7r:r%r�r�r�rAr�r�r;rFr3r@rKrNr�r�rrT�
__classcell__r+r+r#r,r�s�"�
A




8?��7��6�n�H�
#

	



	
�Wr)r�rzr$r)J�
__future__rr�r�r�r��loggingrB�sys�typingrirC�
contextlibr�http.clientrZ_HttplibHTTPMessagerZ_HttplibHTTPResponserr3�
TYPE_CHECKINGZ_base_connectionrZ
brotlicffirc�ImportErrorr�r	r
�_collectionsrr�rr
r�
exceptionsrrrrrrrrrrrZ
util.responserrZ
util.retryrZconnectionpoolr�	getLoggerr8r/rr=rPrUra�version_info�compressionrnZ	backportsr�rorwr�r�rDr�r+r+r+r,�<module>st���4

;@+
��2
8Mo