
    vKg;                         S SK r S SKJr  S SKJr  S SKJr  S SKJ	r	  S SK
Jr  S SKJrJrJr  S SKJr  S S	K
Jr  S S
KJr  \ R&                  " \5      r " S S\5      rS rg)    N)IOBase)ProtocolError)ReadTimeoutError)parsers)set_socket_timeout)IncompleteReadErrorr   ResponseStreamingError)ScalarTypes)XMLParseError)first_non_none_responsec                       \ rS rSrSrSrS rS rS rS r	SS	 jr
S
 rS rS rS rS r\r\S4S jr\4S jrS rS rS rSrg)StreamingBody&   aI  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.

i   c                 *    Xl         X l        SU l        g )Nr   )_raw_stream_content_length_amount_read)self
raw_streamcontent_lengths      Q/var/www/highfloat_scraper/venv/lib/python3.13/site-packages/botocore/response.py__init__StreamingBody.__init__5   s    %-    c                     g N r   s    r   __del__StreamingBody.__del__:   s     	r   c                 x     [        U R                  U5        g! [         a    [        R	                  SSS9  e f = f)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   timeouts     r   r    StreamingBody.set_socket_timeout@   sF    		t//9 	LL- 	   	s     9c                 X     U R                   R                  5       $ ! [         a     gf = f)NF)r   readabler#   r   s    r   r)   StreamingBody.readableW   s.    	##,,.. 		s    
))Nc                 2    U R                   R                  U5      nU =R                  [        U5      -  sl        Ub  U(       d  US:  a  U R                  5         U$ ! [         a  n[        UR                  US9eSnAf[
         a  n[        US9eSnAff = f)zXRead at most amt bytes from the stream.

If the amt argument is omitted, read all data.
)endpoint_urlr%   N)r%   r   )
r   readURLLib3ReadTimeoutErrorr   urlURLLib3ProtocolErrorr	   r   len_verify_content_length)r   amtchunkes       r   r-   StreamingBody.read]   s    
	2$$))#.E 	SZ';uq '') ' 	@"Q??# 	2(q11	2s#   A 
B'A;;B	BBc                 6    U R                   R                  5       $ r   )r   	readlinesr   s    r   r8   StreamingBody.readlinesq   s    ))++r   c                 8    U R                  U R                  5      $ )z:Return an iterator to yield 1k chunks from the raw stream.)iter_chunks_DEFAULT_CHUNK_SIZEr   s    r   __iter__StreamingBody.__iter__t   s     8 899r   c                 ^    U R                  U R                  5      nU(       a  U$ [        5       e)z-Return the next 1k chunk from the raw stream.)r-   r<   StopIteration)r   current_chunks     r   __next__StreamingBody.__next__x   s'    		$":":;  or   c                     U R                   $ r   )r   r   s    r   	__enter__StreamingBody.__enter__   s    r   c                 8    U R                   R                  5         g r   r   close)r   typevalue	tracebacks       r   __exit__StreamingBody.__exit__   s     r   Fc              #      #    SnU R                  U5       H=  nX4-   R                  S5      nUSS  H  nUR                  U5      S   v   M     US   nM?     U(       a  UR                  U5      S   v   gg7f)zReturn 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.
r   TNr   )r;   
splitlines)r   
chunk_sizekeependspendingr4   lineslines          r   
iter_linesStreamingBody.iter_lines   s      %%j1E_006Ecr
ooh/22 #BiG	 2
 $$X.q11 s   A4A6c              #   H   #     U R                  U5      nUS:X  a  gUv   M  7f)zLReturn an iterator to yield chunks of chunk_size bytes from the raw
stream.
r   N)r-   )r   rR   rA   s      r   r;   StreamingBody.iter_chunks   s.       IIj1M#	 s    "c                     U R                   bK  U R                  [        U R                   5      :w  a'  [        U R                  [        U R                   5      S9eg g )N)actual_bytesexpected_bytes)r   r   intr   r   s    r   r2   $StreamingBody._verify_content_length   s\     +0A0AS  F
 1
 &!.."4#7#78 1
+r   c                 6    U R                   R                  5       $ r   )r   tellr   s    r   ra   StreamingBody.tell   s    $$&&r   c                 8    U R                   R                  5         g)z*Close the underlying http response stream.NrH   r   s    r   rI   StreamingBody.close   s     r   )r   r   r   r   )__name__
__module____qualname____firstlineno____doc__r<   r   r   r   r)   r-   r8   r=   rB   rE   rM   nextrW   r;   r2   ra   rI   __static_attributes__r   r   r   r   r   &   sk    
 
.(,: ! D$7% 2 &9  
'!r   r   c                    U R                   S   nUR                  UR                  S.nUS   S:  a  UR                  US'   OLU R                  (       a,  [        UR                  US   R                  S5      5      US'   OUR                  US'   [        R                  " U5      nXR                  X0R                  5      4$ )Nprotocol)headersstatus_codero   i,  bodyrn   zcontent-length)metadatarn   ro   contenthas_streaming_outputr   rawgetr   create_parserparseoutput_shape)operation_modelhttp_responserm   response_dictparsers        r   get_responser}      s    ''
3H (($00M ]#s* - 5 5f		-	- -}Y7;;<LM!
f !. 5 5f""8,F,,33  r   )loggingior   urllib3.exceptionsr   r0   r   r.   botocorer   botocore.compatr   botocore.exceptionsr   r	   r
   r   botocore.hooksr   	getLoggerre   r$   r   r}   r   r   r   <module>r      sT      D J  .  ! ) 2 
		8	$K!F K!\r   