HEX
Server: Apache
System: Linux vps35971 6.8.0-79-generic #79~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Aug 15 16:54:53 UTC 2 x86_64
User: haitiopendh (6209306)
PHP: 8.1.32
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/botocore/__pycache__/response.cpython-310.pyc
o

<&�aE�@s�ddlZddlmZddlmZmZmZddlmZddlm	Z
ddlmZddlm
Z
ddlmZdd	lmZe�e�ZGd
d�de�Zdd
�ZdS)�N)�set_socket_timeout)�IncompleteReadError�ReadTimeoutError�ResponseStreamingError)r)�
ProtocolError)�parsers)�ScalarTypes)�
XMLParseError)�first_non_none_responsec@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)�self�
raw_stream�content_length�r�3/usr/lib/python3/dist-packages/botocore/response.py�__init__0s
zStreamingBody.__init__cCs2z	t|j|�WdStytjddd��w)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)r�timeoutrrrr5s��z StreamingBody.set_socket_timeoutNc
Cs�z|j�|�}Wn#ty}zt|j|d��d}~wty+}zt|d��d}~ww|jt|�7_|dus?|sC|dkrC|�	�|S)zhRead at most amt bytes from the stream.

        If the amt argument is omitted, read all data.
        )�endpoint_urlrN)rr)
r
�read�URLLib3ReadTimeoutErrorr�url�URLLib3ProtocolErrorrr�len�_verify_content_length)r�amt�chunk�errrrLs�
��zStreamingBody.readcCs|�|j�S)zCReturn an iterator to yield 1k chunks from the raw stream.
        )�iter_chunks�_DEFAULT_CHUNK_SIZE�rrrr�__iter__`szStreamingBody.__iter__cCs|�|j�}|r
|St��)z6Return the next 1k chunk from the raw stream.
        )rr&�
StopIteration)r�
current_chunkrrr�__next__eszStreamingBody.__next__Fccsj�d}|�|�D]}||�d�}|dd�D]
}|�|�dVq|d}q|r3|�|�dVdSdS)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%�
splitlines)r�
chunk_size�keepends�pendingr#�lines�linerrr�
iter_linesos�
�zStreamingBody.iter_linesccs"�	|�|�}|dkr
dS|Vq)z\Return an iterator to yield chunks of chunk_size bytes from the raw
        stream.
        Tr,N)r)rr/r*rrrr%~s�
�zStreamingBody.iter_chunkscCs6|jdur|jt|j�krt|jt|j�d��dSdS)N)�actual_bytes�expected_bytes)rr�intrr'rrrr!�s
��z$StreamingBody._verify_content_lengthcCs|j��dS)z*Close the underlying http response stream.N)r
�closer'rrrr8�szStreamingBody.close)N)rF)�__name__�
__module__�__qualname__�__doc__r&rrrr(r+�nextr4r%r!r8rrrrr"s



rcCsx|jd}|j|jd�}|ddkr|j|d<n|jr)t|j|d�d��|d<n|j|d<t�	|�}||�
||j�fS)N�protocol)�headers�status_coder@i,�bodyr?zcontent-length)�metadatar?r@�content�has_streaming_outputr�raw�getr�
create_parser�parse�output_shape)�operation_model�
http_responser>�
response_dict�parserrrr�get_response�s
�
�

�rN)�logging�botocore.compatr�botocore.exceptionsrrr�urllib3.exceptionsrrr�botocorerrr	�botocore.hooksr
�	getLoggerr9r�objectrrNrrrr�<module>s
u