| Server IP : 104.21.21.239 / Your IP : 216.73.216.55 Web Server : Apache/2.4.68 (Amazon Linux) OpenSSL/3.5.7 System : Linux ip-172-31-69-123.ec2.internal 6.1.177-224.371.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Jul 27 20:28:29 UTC 2026 x86_64 User : ec2-user ( 1000) PHP Version : 8.4.24 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /lib/python3.9/site-packages/awscli/botocore/__pycache__/ |
Upload File : |
a
wA�i\ � @ s� d dl Z d dlZd dlmZmZ d dlmZmZmZ d dl m
Z
mZ d dlm
Z
d dlmZ e �e�ZG dd� d�Zd d
� ZdS )� N)�ScalarTypes�parsers)�
XMLParseError�json�set_socket_timeout)�IncompleteReadError�ReadTimeoutError)�first_non_none_response)r c @ sh e Zd ZdZdZdd� Zdd� Zddd �Zd
d� Zdd
� Z e Z
ddd�Zefdd�Zdd� Z
dd� ZdS )�
StreamingBodyae Wrapper 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.
� c C s || _ || _d| _d S )Nr )�_raw_stream�_content_length�_amount_read)�selfZ
raw_streamZcontent_length� r �</usr/lib/python3.9/site-packages/awscli/botocore/response.py�__init__1 s zStreamingBody.__init__c C s8 zt | j|� W n" ty2 tjddd� � Y n0 dS )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)r r �AttributeError�logger�error)r Ztimeoutr r r r 6 s �z StreamingBody.set_socket_timeoutNc
C sv z| j �|�}W n2 tyB } zt|j|d��W Y d}~n
d}~0 0 | jt|�7 _|du sj|sr|dkrr| �� |S )zhRead at most amt bytes from the stream.
If the amt argument is omitted, read all data.
)Zendpoint_urlr Nr )r �read�URLLib3ReadTimeoutErrorr �urlr �len�_verify_content_length)r Zamt�chunk�er r r r P s $zStreamingBody.readc C s | � | j�S )z:Return an iterator to yield 1k chunks from the raw stream.)�iter_chunks�_DEFAULT_CHUNK_SIZE�r r r r �__iter__b s zStreamingBody.__iter__c C s | � | j�}|r|S t� �dS )z-Return the next 1k chunk from the raw stream.N)r r �
StopIteration)r �
current_chunkr r r �__next__f s zStreamingBody.__next__Fc c sd d}| � |�D ]<}|| �d�}|dd� D ]}|�|�d V q,|d }q|r`|�|�d V dS )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�keependsZpendingr �lines�liner r r �
iter_lineso s
zStreamingBody.iter_linesc c s | � |�}|dkrq|V q dS )z\Return an iterator to yield chunks of chunk_size bytes from the raw
stream.
r% N)r )r r( r# r r r r ~ s
zStreamingBody.iter_chunksc C s2 | j d ur.| jt| j �kr.t| jt| j �d��d S )N)Zactual_bytesZexpected_bytes)r
r �intr r r r r r � s ��z$StreamingBody._verify_content_lengthc C s | j �� dS )z*Close the underlying http response stream.N)r �closer r r r r. � s zStreamingBody.close)N)r F)�__name__�
__module__�__qualname__�__doc__r r r r r! r$ �nextr, r r r. r r r r r
"