
    pgeD/                         d dl Z d dlmZmZmZmZmZmZmZm	Z	m
Z
mZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d Z G d	 d
e          Z G d de          ZdS )    N)
DEFAULT_TIMEOUTMAX_POOL_CONNECTIONSEndpointEndpointCreatorHTTPClientErrorcreate_request_objecthistory_recorderis_valid_endpoint_urlis_valid_ipv6_endpoint_urllogger)first_non_none_response)HTTPHeaderDict)handle_checksum_body)AIOHTTPSession)StreamingBodyc                 d  K   t          d | j        j        D                       | j        d|j        id}|d         dk    r| j         d{V |d<   n]|j        r| j        |d<   nK|j        r4|d                             d	          }t          | j        |          |d<   n| j         d{V |d<   |S )
a  Convert an HTTP response object to a request dict.

    This converts the requests library's HTTP response object to
    a dictionary.

    :type http_response: botocore.vendored.requests.model.Response
    :param http_response: The HTTP response from an AWS service request.

    :rtype: dict
    :return: A response dictionary which will contain the following keys:
        * headers (dict)
        * status_code (int)
        * body (string or file-like object)

    c                     i | ]@\  }}|                     d                                           |                     d           AS )zutf-8)decodelower).0kvs      4lib/python3.11/site-packages/aiobotocore/endpoint.py
<dictcomp>z,convert_to_response_dict.<locals>.<dictcomp>-   sR       Aq !!''))188G+<+<      operation_name)headersstatus_codecontextr   ,  Nbodyr   zcontent-length)
r   rawraw_headersr   namecontenthas_event_stream_outputhas_streaming_outputgetr   )http_responseoperation_modelresponse_dictlengths       r   convert_to_response_dictr-      s
     * " )-9  
 
 %0o2
 M  ]#s**&3&; ; ; ; ; ; ;f		0 < - 1f		- <y)--.>?? -m.? H Hf&3&; ; ; ; ; ; ;fr   c                   F    e Zd Zd Zd
dZd Zd Zd Zd Z	 	 ddZ	d	 Z
dS )AioEndpointc                 H   K   | j                                          d {V  d S N)http_sessionclose)selfs    r   r3   zAioEndpoint.closeD   s3      %%'''''''''''r   Nc                 Z  K   t          |          }|rt          |j        |j        g          |_        |j        j                                        }d                    ||j	                  }| j
                            |||j	                   d {V  |                     |          }|S )Nz&request-created.{service_id}.{op_name})
service_idop_name)requestr   )r   anyr'   r&   stream_outputservice_modelr6   	hyphenizeformatr$   _event_emitteremitprepare_request)r4   paramsr*   r8   r6   
event_nameprepared_requests          r   create_requestzAioEndpoint.create_requestG   s      '// 	$'#8#;% %G! )6AKKMMJAHH%/C I  J %**.3 +         
  //88r   c                 b  K   d}|d         }|                      ||           |                     ||           d {V }|                     |||           d {V \  }}|                     |||||           d {V r|dz  }|                      |||           |                                 |                     ||           d {V }|                     |||           d {V \  }}|                     |||||           d {V | d|d         v r|dz
  }||d         d         d<   |||S )N   r   ResponseMetadataRetryAttempts)_update_retries_contextrD   _get_response_needs_retryreset_stream)	r4   request_dictr*   attemptsr   r8   success_response	exceptiontotal_retriess	            r   _send_requestzAioEndpoint._send_request\   s     y)$$Wh777++L/JJJJJJJJ,0,>,>_g-
 -
 '
 '
 '
 '
 '
 '
#) %%
 
 
 
 
 
 
 
 	 MH(((<LMMM
   """ //oNNNNNNNNG040B0B'1 1 + + + + + +'i! %%
 
 
 
 
 
 
 
 	( ("&6q&999 %qLM  Q 23  O##r   c                 *  K   |                      |||           d {V \  }}d d ||d}|#|\  }}||d<   t          ||           d {V |d<   |j        j                                        }	 | j        j        d|	 d|j         fi | d {V  ||fS )N)r+   parsed_responser   rP   rT   r+   zresponse-received..)_do_get_responser-   r;   r6   r<   r>   r?   r$   )
r4   r8   r*   r   rO   rP   kwargs_to_emitr)   rT   r6   s
             r   rJ   zAioEndpoint._get_response   s7      -1,A,A_g-
 -
 '
 '
 '
 '
 '
 '
#) "#"	
 
 '-=*M?0?N,-4L5 5 / / / / / /N?+ %2=GGII
&d!&DDDo.BDD
 

 
 	
 	
 	
 	
 	
 	
 	
  **r   c           	      `  K   	 t          j        d|           t          j        d|j        |j        |j        |j        |j        d           |j	        j
                                        }d| d|j         }| j                            ||           d {V }t          |          }||                     |           d {V }nG# t"          $ r}d |fcY d }~S d }~wt$          $ r$}t          j        dd	           d |fcY d }~S d }~ww xY wt'          ||           d {V }	t)          ||	||           d {V  |	                                }
|j        |
d
<   t          j        d|
           |j        d         }| j                            |          }t5          j        |j                  r"|                    |	|j                   d {V }n|                    |	|j                  }|j        dk    r|                     |	|||           d {V  t          j        d|           ||fd fS )NzSending http request: %sHTTP_REQUEST)methodr   	streamingurlr!   zbefore-send.rU   )r8   z-Exception received when sending HTTP request.T)exc_infor[   HTTP_RESPONSEprotocolr    PARSED_RESPONSE) r   debugr	   recordrZ   r   has_streaming_inputr\   r!   r;   r6   r<   r$   r>   r?   r   _sendr   	Exceptionr-   r   copyr'   metadata_response_parser_factorycreate_parserasyncioiscoroutinefunctionparseoutput_shaper   _add_modeled_error_fields)r4   r8   r*   r   r6   rB   	responsesr)   er+   http_response_record_dictr_   parserrT   s                 r   rV   zAioEndpoint._do_get_response   sD     	L3W===#%n&!0!D";#L 	 	 	 )6AKKMMJK
KK_5IKKJ"166G 7        I 4I>>M$&*jj&9&9 9 9 9 9 9 9 	 	 	!9 	 	 	L?$    !9		 7?
 
 
 
 
 
 
 
 #	
 
 	
 	
 	
 	
 	
 	
 	
 %2$6$6$8$8! 0 	"	
 	1JKKK"+J7.<<XFF&v|44 	$*LL;% %      OO %ll; O $++00	         	 1?CCC/55s0   CC 
DCDD'D DDc                 f  K   |                     di                                d          }|d S |j        }|                    |          }|d S t          j        |j                  r|                    ||           d {V }n|                    ||          }|                    |           d S )NErrorCode)r(   r;   shape_for_error_coderj   rk   rl   update)	r4   r+   rT   r*   rr   
error_coder;   error_shapemodeled_parses	            r   rn   z%AioEndpoint._add_modeled_error_fields   s       %(("5599&AA
F'5#88DDF&v|44 	E"(,,}k"J"JJJJJJJMM"LLDDM}-----r   c           	      2  K   |j         j                                        }d| d|j         }| j                            ||| ||||           d {V }t          |          }	|	dS t          j        d|	           t          j
        |	           d {V  dS )Nzneeds-retry.rU   )responseendpoint	operationrN   caught_exceptionrM   Fz3Response received to retry, sleeping for %s secondsT)r;   r6   r<   r$   r>   r?   r   r   ra   rj   sleep)
r4   rN   r*   rM   r|   r   r6   rB   ro   handler_responses
             r   rK   zAioEndpoint._needs_retry   s       %2=GGII
GJGG1EGG
-22%-% 3 
 
 
 
 
 
 
 
	 39==#5 LE    - 01111111114r   c                 F   K   | j                             |           d {V S r1   )r2   send)r4   r8   s     r   rd   zAioEndpoint._send  s/      &++G444444444r   r1   )NN)__name__
__module____qualname__r3   rD   rR   rJ   rV   rn   rK   rd    r   r   r/   r/   C   s        ( ( (       *'$ '$ '$R+ + +8B6 B6 B6H. . .8    @5 5 5 5 5r   r/   c            
       *    e Zd Zddeeedddddf
dZdS )AioEndpointCreatorNc           
      H   t          |          s!t          |          st          d|z            |	|                     |          }	|j        }t          j        d||            |||	|                     |          ||
|||          }t          ||| j	        ||          S )NzInvalid endpoint: %szSetting %s timeout as %s)timeoutproxiesverifymax_pool_connectionssocket_optionsclient_certproxies_configconnector_args)endpoint_prefixevent_emitterresponse_parser_factoryr2   )
r
   r   
ValueError_get_proxiesr   r   ra   _get_verify_valuer/   r>   )r4   r;   region_nameendpoint_urlr   r   r   r   http_session_clsr   r   r   r   r   r   r2   s                   r   create_endpointz"AioEndpointCreator.create_endpoint!  s      %
 
 	D,\::	D 3lBCCC?''55G'7/'JJJ''))&11!5)#))	
 	
 	
 +-$;%
 
 
 	
r   )r   r   r   r   r   r   r   r   r   r   r   r      sH          $1'+
 +
 +
 +
 +
 +
r   r   )rj   botocore.endpointr   r   r   r   r   r   r	   r
   r   r   botocore.hooksr   urllib3.responser   aiobotocore.httpchecksumr   aiobotocore.httpsessionr   aiobotocore.responser   r-   r/   r   r   r   r   <module>r      sY                           3 2 2 2 2 2 + + + + + + 9 9 9 9 9 9 2 2 2 2 2 2 . . . . . .) ) )XZ5 Z5 Z5 Z5 Z5( Z5 Z5 Z5z,
 ,
 ,
 ,
 ,
 ,
 ,
 ,
 ,
 ,
r   