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: //lib/python3.6/site-packages/botocore/__pycache__/response.cpython-36.pyc
3

�T_�@s�ddlZddlZddlmZddlmZddlmZmZm	Z	ddl
mZmZddl
mZddlmZeje�ZGdd	�d	e�Zd
d�ZdS)�N)�ScalarTypes)�first_non_none_response)�json�set_socket_timeout�
XMLParseError)�IncompleteReadError�ReadTimeoutError)r)�parsersc@sheZdZdZdZdd�Zdd�Zddd	�Zd
d�Zdd
�Z	e	Z
ddd�Zefdd�Zdd�Z
dd�ZdS)�
StreamingBodyaeWrapper class for an http response body.

    This provides a few additional conveniences that do not exist
    in the urllib3 model:

        * Set the timeout on the socket (i.e read() timeouts)
        * Auto validation of content length, if the amount of bytes
          we read does not match the content length, an exception
          is raised.

    �cCs||_||_d|_dS)Nr)�_raw_stream�_content_length�_amount_read)�selfZ
raw_streamZcontent_length�r�/usr/lib/python3.6/response.py�__init__+szStreamingBody.__init__cCs:yt|j|�Wn$tk
r4tjddd��YnXdS)z&Set the timeout seconds on the socket.zbCannot access the socket object of a streaming response.  It's possible the interface has changed.T)�exc_infoN)rr�AttributeError�logger�error)rZtimeoutrrrr0sz StreamingBody.set_socket_timeoutNcCsvy|jj|�}Wn0tk
r@}zt|j|d��WYdd}~XnX|jt|�7_|dksj|rr|dkrr|j�|S)zhRead at most amt bytes from the stream.

        If the amt argument is omitted, read all data.
        )Zendpoint_urlrNr)r�read�URLLib3ReadTimeoutErrorrZurlr�len�_verify_content_length)rZamt�chunk�errrrGs zStreamingBody.readcCs|j|j�S)zCReturn an iterator to yield 1k chunks from the raw stream.
        )�iter_chunks�_DEFAULT_CHUNK_SIZE)rrrr�__iter__YszStreamingBody.__iter__cCs|j|j�}|r|St��dS)z6Return the next 1k chunk from the raw stream.
        N)rr�
StopIteration)r�
current_chunkrrr�__next__^szStreamingBody.__next__ccshd}xL|j|�D]>}||jd�}x"|dd�D]}|j�dVq0W|d}qW|rd|j�dVdS)z�Return an iterator to yield lines from the raw stream.

        This is achieved by reading chunk of bytes (of size chunk_size) at a
        time from the raw stream, and then yielding lines from there.
        �TN�r���r%)r�
splitlines)r�
chunk_size�pendingr�lines�linerrr�
iter_lineshszStreamingBody.iter_linesccs$x|j|�}|dkrP|VqWdS)z\Return an iterator to yield chunks of chunk_size bytes from the raw
        stream.
        r#N)r)rr'r!rrrrws

zStreamingBody.iter_chunkscCs2|jdk	r.|jt|j�kr.t|jt|j�d��dS)N)Zactual_bytesZexpected_bytes)r
r�intr)rrrrr�s

z$StreamingBody._verify_content_lengthcCs|jj�dS)z*Close the underlying http response stream.N)r�close)rrrrr-�szStreamingBody.close)N)r)�__name__�
__module__�__qualname__�__doc__rrrrrr"�nextr+rrr-rrrrr
s



r
cCsx|jd}|j|jd�}|ddkr0|j|d<n,|jrRt|j|djd��|d<n
|j|d<tj	|�}||j
||j�fS)N�protocol)�headers�status_coder5i,Zbodyr4zcontent-length)Zmetadatar4r5ZcontentZhas_streaming_outputr
�raw�getr	Z
create_parser�parseZoutput_shape)Zoperation_modelZ
http_responser3Z
response_dict�parserrrr�get_response�s



r:)�sysZloggingZbotocorerZbotocore.hooksrZbotocore.compatrrrZbotocore.exceptionsrrZurllib3.exceptionsrr	Z	getLoggerr.r�objectr
r:rrrr�<module>s
s