
    pge$                         d dl Z d dlZd dlZd dlZd dlmZmZ d dlZd dlmZm	Z	m
Z
mZmZmZmZ d dlmZ d dlmZmZmZmZmZmZmZmZmZ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'Z(d dl)m*Z*m+Z+  G d d	          Z,dS )
    N)DictOptional)ClientConnectionErrorClientConnectorErrorClientHttpProxyErrorClientProxyConnectionErrorClientSSLErrorServerDisconnectedErrorServerTimeoutError)URL)MAX_POOL_CONNECTIONSConnectionClosedErrorConnectTimeoutErrorEndpointConnectionErrorHTTPClientErrorInvalidProxiesConfigErrorLocationParseErrorProxyConfigurationProxyConnectionErrorReadTimeoutErrorSSLError_is_ipaddresscreate_urllib3_contextensure_booleanget_cert_pathloggermask_proxy_url	parse_urlurlparse)CIMultiDict)_IOBaseWrapper_textc            	       l    e Zd Zdddeddddfdedeeef         dedefdZ	d Z
d	 Zd
 Zd Zd Zd ZdS )AIOHTTPSessionTNverifyproxiestimeoutmax_pool_connectionsc	                     d  _          _        t          ||           _        t	          |t
          t          f          r|\  }	}
n|x}	}
t          j        |	|
          }d  _	        d  _
        t	          |t                    r| _	        n$t	          |t                    r|\   _	         _
        | _        | _         j        t          d           _         _        | _        |g  _        d t#                    r`|r" j        j        }                     |          n<                                 t+                    }|r                    |d d             fd _        d  _        d S )N)r&   proxies_settings)sock_connect	sock_read   )keepalive_timeoutc                  R    t          j        d t                    dj        S )N)limit
verify_sslssl )aiohttpTCPConnectorbool_connector_args)r(   selfssl_contextr%   s   7lib/python3.11/site-packages/aiobotocore/httpsession.py<lambda>z)AIOHTTPSession.__init__.<locals>.<lambda>o   s:    )= *
&F||*
 *
 "	*
 *
     )_session_verifyr   _proxy_config
isinstancelisttupler4   ClientTimeout
_cert_file	_key_filestr_timeoutr7   dict_max_pool_connections_socket_optionsr6   settings_setup_proxy_ssl_context_get_ssl_contextr   load_verify_locations_create_connector
_connector)r8   r%   r&   r'   r(   socket_optionsclient_certproxies_configconnector_argsconn_timeoutread_timeoutr*   ca_certsr9   s   ``  `        @r:   __init__zAIOHTTPSession.__init__.   s    :>/n
 
 
 ge}-- 	2)0&L,,*11L<'%
 
 
 k3'' 	:)DOOU++ 	:.9+DOT^-' $("#=#=#=D %9"-!#%D  << 	L L#'#5#> ";;<LMM #3355 )00 L55hdKKK"
 "
 "
 "
 "
 "
 "
 r<   c                    K   | j         s| j        rJ |                                 | _        t          j        | j        | j        dhd          | _         | S )NzCONTENT-TYPEF)	connectorr'   skip_auto_headersauto_decompress)r=   rP   rO   r4   ClientSessionrG   r8   s    r:   
__aenter__zAIOHTTPSession.__aenter__w   sa      =88880022-oM-.!	
 
 
 r<   c                 |   K   | j         r2| j                             |||           d {V  d | _         d | _        d S d S N)r=   	__aexit__rP   )r8   exc_typeexc_valexc_tbs       r:   rb   zAIOHTTPSession.__aexit__   sX      = 	#-))(GVDDDDDDDDD DM"DOOO	# 	#r<   c                 p    t                      }| j        r |                    | j        | j                   |S ra   )r   rD   load_cert_chainrE   )r8   r9   s     r:   rM   zAIOHTTPSession._get_ssl_context   s8    ,..? 	I''HHHr<   c                 D   | j         j        }|                    d          }|                    d          }||d S |                                 }	 t	          |          }t          |j                  sd|_        ||                    |           t          |t                    r$|                    |d         |d                    n*t          |t                    r|                    |           |S # t          t          f$ r}t          |          d }~ww xY w)	Nproxy_ca_bundleproxy_client_certT)cafiler      )keyfileerror)r?   rK   getrM   r   r   hostcheck_hostnamerN   r@   rB   rg   rF   OSErrorr   r   )r8   	proxy_urlr*   ri   
proxy_certcontexturles           r:   rL   z'AIOHTTPSession._setup_proxy_ssl_context   s9   -6*../@AA%))*=>>
"z'94''))	5I&&C !** .)-&*--_-EEE*e,, 4''
1z!}'MMMMJ,, 4''
333N+, 	5 	5 	5+!4444	5s   B&C9 9D
DDc                 D   K   |                      d d d            d {V  d S ra   )rb   r^   s    r:   closezAIOHTTPSession.close   s4      nnT4...........r<   c           	        K   	 | j                             |j                  }| j                             |j                  }|j        }|j        }|j        }t          t          j        	                    dd                    rt          |j                  j        }||d<   t          d |                                D                       }d|d<   d }	|	                    dd                                          dk    r|                    dd           d	}	t!          |t"          j                  rt'          |          }t)          |d	
          }| j                            |j        ||	||||           d {V }
t0          j                            t7          |
j                  |
j        |
j        |
          }|j        s|j         d {V  |S # t>          $ r}tA          |j        |          d }~wtB          tD          f$ r#}tG          tI          |          |          d }~wtJ          tL          j'        tL          j(        j)        f$ r}tU          |||j                  d }~wtV          $ re}t7          |                                          ,                    d          rt[          |j        |          t]          |j        |          d }~wt^          t`          tb          j2        f$ r}tg          |j        |          d }~wth          j5        $ r}t]          |j        |          d }~wtl          $ r-}d}to          j8        |d	           ts          |          d }~ww xY w)N(BOTO_EXPERIMENTAL__ADD_PROXY_HOST_HEADER rq   c              3   T   K   | ]#}|d          t          |d         d          fV  $dS )r   rl   zutf-8)encodingN)r"   ).0zs     r:   	<genexpr>z&AIOHTTPSession.send.<locals>.<genexpr>   sM       # #:;1uQqTG4445# # # # # #r<   identityzAccept-EncodingzTransfer-EncodingchunkedT)encoded)rw   r   headersdataproxyproxy_headers)endpoint_urlro   )rt   ro   )ro   requestr   connectz4Exception received when sending urllib3 HTTP request)exc_inforn   ):r?   proxy_url_forrw   proxy_headers_forr   bodyr   osenvironrp   r   hostnamer    itemslowerpopr@   ioIOBaser!   r   r=   r   methodaiobotocore
awsrequestAioAWSResponserF   statusstream_outputcontentr	   r   r   r   r   r   r
   r4   ClientPayloadErrorhttp_exceptionsBadStatusLiner   r   
startswithr   r   r   r   socketgaierrorr   asyncioTimeoutError	Exceptionr   debugr   )r8   r   rt   r   rw   r   r   rq   headers_r   responsehttp_responserx   messages                 r:   sendzAIOHTTPSession.send   s     U	+*88EEI .@@MMM+CoG<D
I2NN  -  ,,5(,f%" # #?F}}# # #  H
 +5H&'G||/44::<<	II0"555$	** ,%d++c4(((C!]22 + 3        H (2AAHL!!8?H4Dh M ( , $++++++++   	> 	> 	>1====*,@A 	 	 	&(331    $&#1
 	 	 	
 (w{    " 	J 	J 	J1vv||~~((33 J)w{!LLLL&GKqIIII !O
 	M 	M 	M
 *w{!LLLL# 	F 	F 	F"1EEEE 	+ 	+ 	+LGL40000!****	+sa   GG 
M(G22M(H$$)M(I$$M(1A KM(0LM(L..M(;(M##M()__name__
__module____qualname__r   r6   r   rF   floatintrX   r_   rb   rM   rL   rz   r   r3   r<   r:   r$   r$   -   s         "&$8G GG c3hG 	G
 "G G G GR  # # #  5 5 54/ / /V+ V+ V+ V+ V+r<   r$   )-r   r   r   r   typingr   r   r4   r   r   r   r   r	   r
   r   aiohttp.clientr   botocore.httpsessionr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   	multidictr    aiobotocore.awsrequestr   aiobotocore._endpoint_helpersr!   r"   r$   r3   r<   r:   <module>r      s    				 				  ! ! ! ! ! ! ! !                                                                 * " ! ! ! ! !     ? ? ? ? ? ? ? ?V+ V+ V+ V+ V+ V+ V+ V+ V+ V+r<   