
    bf$                        d dl Z d dlZ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	m
Z
 d dlmZ d dlmZ d dlmZmZ d dl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% d dl&Z&d
dl'm(Z(m)Z) d
dl*m+Z+ d
dl,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6 d
dl7m8Z8 d
dl9m:Z:m;Z;m<Z< d
dl)m=Z=m>Z>m?Z?m@Z@mAZA d
dlBmCZC d
dlDmEZE 	 d dlFZFeFjG        ZGn# eH$ r dZFeIZGY nw xY wdZJerd
dlKmLZL d
dl9mMZM d
dlNmOZO  G d d          ZP G d d          ZQ G d d          ZR G d d          ZS G d d           ZT G d! d"eS          ZU G d# d$eS          ZV G d% d&eS          ZWdS )'    N)defaultdictdeque)suppress)
HTTPStatus)SimpleCookie)cycleislice)	monotonic)TracebackType)TYPE_CHECKINGAny	AwaitableCallableDefaultDictDictIteratorListLiteralOptionalSetTupleTypeUnioncast   )hdrshelpers)AbstractResolver)
ClientConnectionErrorClientConnectorCertificateErrorClientConnectorErrorClientConnectorSSLErrorClientHttpProxyErrorClientProxyConnectionErrorServerFingerprintMismatchUnixClientConnectorErrorcert_errors
ssl_errors)ResponseHandler)ClientRequestFingerprint_merge_ssl_params)ceil_timeoutget_running_loopis_ip_addressnoopsentinel)EventResultOrError)DefaultResolver)BaseConnectorTCPConnectorUnixConnectorNamedPipeConnector)ClientTimeout)ConnectionKey)Tracec                   B    e Zd ZdZdee         ddfdZdefdZddZdS )	_DeprecationWaiter
_awaitable_awaited	awaitablereturnNc                 "    || _         d| _        d S NFr=   )selfr@   s     K/var/www/html/Alfredo/env/lib/python3.11/site-packages/aiohttp/connector.py__init__z_DeprecationWaiter.__init__K   s    #    c                 B    d| _         | j                                        S NT)r?   r>   	__await__rD   s    rE   rJ   z_DeprecationWaiter.__await__O   s    ((***rG   c                 L    | j         st          j        dt                     d S d S )NzDConnector.close() is a coroutine, please use await connector.close())r?   warningswarnDeprecationWarningrK   s    rE   __del__z_DeprecationWaiter.__del__S   s<    } 	M5"    	 	rG   rA   N)	__name__
__module____qualname__	__slots__r   r   rF   rJ   rP    rG   rE   r<   r<   H   sn        *I)C. T    +3 + + + +     rG   r<   c            
       H   e Zd ZdZdZdddddedej        ddf
d	Zde	fd
Z
efdeddfdZded         fdZedej        fd            Zedeej                 fd            Zedee         fd            Zdeg df         ddfdZddZddZddZedefd            ZdS )
ConnectionN	connectorr4   keyr9   protocollooprA   c                     || _         || _        || _        || _        g | _        |                                r-t          j        t          j	        d                    | _
        d S d S )Nr   )_key
_connector_loop	_protocol
_callbacks	get_debug	tracebackextract_stacksys	_getframe_source_traceback)rD   rY   rZ   r[   r\   s        rE   rF   zConnection.__init__a   si     	#
4<46>> 	O%.%<S]1=M=M%N%ND"""	O 	OrG   c                     d| j          dS )NzConnection<>)r^   rK   s    rE   __repr__zConnection.__repr__q   s    )TY))))rG   	_warningsc                 2   | j         d| i} |j        d| t          fi | | j                                        rd S | j                            | j        | j         d           | dd}| j        
| j        |d<   | j        	                    |           d S d S )NsourcezUnclosed connection Tshould_closezUnclosed connection)client_connectionmessagesource_traceback)
ra   rN   ResourceWarningr`   	is_closedr_   _releaser^   rh   call_exception_handler)rD   rl   kwargscontexts       rE   rP   zConnection.__del__t   s    >%%FIN:$::OVVvVVVz##%% O$$TYT$RRR,0=RSSG%1.2.D*+J--g66666 &%rG   Tc                     dS )z9Force subclasses to not be falsy, to make checks simpler.TrV   rK   s    rE   __bool__zConnection.__bool__   s    trG   c                 H    t          j        dt          d           | j        S )Nz%connector.loop property is deprecated   )
stacklevel)rM   rN   rO   r`   rK   s    rE   r\   zConnection.loop   s.    35GTU	
 	
 	
 	
 zrG   c                 ,    | j         d S | j         j        S N)ra   	transportrK   s    rE   r   zConnection.transport   s    >!4~''rG   c                     | j         S r   )ra   rK   s    rE   r[   zConnection.protocol   s
    ~rG   callbackc                 B    || j                             |           d S d S r   )rb   append)rD   r   s     rE   add_callbackzConnection.add_callback   s,    O""8,,,,,  rG   c                     | j         d d          g c}| _         |D ]8}t          t                    5   |             d d d            n# 1 swxY w Y   9d S r   )rb   r   	Exception)rD   	callbackscbs      rE   _notify_releasezConnection._notify_release   s    %)_QQQ%7"	4? 	 	B)$$                	 	s   AA	A	c                     |                                   | j        0| j                            | j        | j        d           d | _        d S d S )NTro   )r   ra   r_   rv   r^   rK   s    rE   closezConnection.close   sP    >%O$$TYT$RRR!DNNN &%rG   c                     |                                   | j        :| j                            | j        | j        | j        j                   d | _        d S d S )Nro   )r   ra   r_   rv   r^   rp   rK   s    rE   releasezConnection.release   s`    >%O$$	4>8S %    "DNNN	 &%rG   c                 H    | j         d u p| j                                          S r   )ra   is_connectedrK   s    rE   closedzConnection.closed   s%    ~%JT^-H-H-J-J)JJrG   rQ   )rR   rS   rT   rh   
_transportr)   asyncioAbstractEventLooprF   strrk   rM   r   rP   r   r{   propertyr\   r   	Transportr   r[   r   r   r   r   r   boolr   rV   rG   rE   rX   rX   \   s       JO"O O "	O
 'O 
O O O O *# * * * * (0 7 7 7D 7 7 7 7'$-     g/    X (8G$56 ( ( ( X(
 (?3    X-Xb$h%7 -D - - - -   " " " "" " " " K K K K XK K KrG   rX   c                       e Zd ZdZddZdS )_TransportPlaceholderz.placeholder for BaseConnector.connect functionrA   Nc                     d S r   rV   rK   s    rE   r   z_TransportPlaceholder.close   s    rG   rQ   )rR   rS   rT   __doc__r   rV   rG   rE   r   r      s.        88     rG   r   c                   f   e Zd ZdZdZdZdZeddddddd	d
ee	de
f         dededededeej                 de
ddfdZefdeddfdZd9dZdeddfdZd9dZ	 	 	 d:deee                  dee         dee         ddfdZedefd            Zedefd            Zedefd            Zd;d Zd!d"d#e ddfd$Z!d;d%Z"de#d         fd&Z$d;d'Z%edefd(            Z&d!d"defd)Z'd*e(d+e)d,         d-d.de*fd/Z+d!d"dee          fd0Z,d;d1Z-d!d"d2e ddfd3Z.dd4d!d"d5e d6eddfd7Z/d*e(d+e)d,         d-d.de fd8Z0dS )<r4   a\  Base connector class.

    keepalive_timeout - (optional) Keep-alive timeout.
    force_close - Set to True to force close and do reconnect
        after each request (and between redirects).
    limit - The total number of simultaneous connections.
    limit_per_host - Number of simultaneous connections to one host.
    enable_cleanup_closed - Enables clean-up closed ssl transports.
                            Disabled by default.
    timeout_ceil_threshold - Trigger ceiling of timeout values when
                             it's above timeout_ceil_threshold.
    loop - Optional event loop.
    TNg       @Fd   r      keepalive_timeoutforce_closelimitlimit_per_hostenable_cleanup_closedr\   timeout_ceil_thresholdr   r   r   r   r   r\   r   rA   c                   |r||t           urt          d          n|t           u rd}t          |          }|| _        d| _        |                                r+t          j        t          j	        d                    | _
        i | _        || _        || _        t                      | _        t!          t                    | _        t%          t&          |          | _        || _        t!          t,                    | _        || _        t3          j        t6          |          | _        t;                      | _        d | _        d | _         | | _!        g | _"        | #                                 d S )Nz6keepalive_timeout cannot be set if force_close is Trueg      .@Fr   r\   )$r1   
ValueErrorr.   _timeout_ceil_threshold_closedrc   rd   re   rf   rg   rh   _conns_limit_limit_per_hostset	_acquiredr   _acquired_per_hostr   float_keepalive_timeout_force_closer   _waitersr`   	functoolspartialr)   _factoryr   cookies_cleanup_handle_cleanup_closed_handle_cleanup_closed_disabled_cleanup_closed_transports_cleanup_closed)rD   r   r   r   r   r   r\   r   s           rE   rF   zBaseConnector.__init__   sa     	) ,1B(1R1R O   !H,,$(!%%'=$>> 	O%.%<S]1=M=M%N%ND"PR-/2uu  	 #'u.?"@"@' $E**
!)/EEE#~~ ?C FJ#,A(A%MO'rG   rl   c                 0   | j         rd S | j        sd S d | j                                        D             }|                                  d| i} |j        d| t
          fi | | |dd}| j        
| j        |d<   | j                            |           d S )Nc                 ,    g | ]}t          |          S rV   )repr).0cs     rE   
<listcomp>z)BaseConnector.__del__.<locals>.<listcomp>  s    777Qa777rG   rn   zUnclosed connector zUnclosed connector)rY   connectionsrr   rs   )	r   r   values_closerN   rt   rh   r`   rw   )rD   rl   connsrx   ry   s        rE   rP   zBaseConnector.__del__
  s    < 	F{ 	F77$+"4"4"6"6777D!	5T55QQ&QQQ +
 

 !-*.*@G&'
))'22222rG   c                 :    t          j        dt                     | S )NzH"with Connector():" is deprecated, use "async with Connector():" instead)rM   rN   rO   rK   s    rE   	__enter__zBaseConnector.__enter__  s%    4	
 	
 	

 rG   excc                 .    |                                   d S r   )r   )rD   r   s     rE   __exit__zBaseConnector.__exit__'  s    rG   c                 
   K   | S r   rV   rK   s    rE   
__aenter__zBaseConnector.__aenter__*  s      rG   exc_type	exc_valueexc_tracebackc                 >   K   |                                   d {V  d S r   )r   )rD   r   r   r   s       rE   	__aexit__zBaseConnector.__aexit__-  s.       jjllrG   c                     | j         S )z1Ultimately close connection on releasing if True.)r   rK   s    rE   r   zBaseConnector.force_close5  s       rG   c                     | j         S )zThe total number for simultaneous connections.

        If limit is 0 the connector has no limit.
        The default limit size is 100.
        )r   rK   s    rE   r   zBaseConnector.limit:  s     {rG   c                     | j         S )zThe limit for simultaneous connections to the same endpoint.

        Endpoints are the same if they are have equal
        (host, port, is_ssl) triple.
        )r   rK   s    rE   r   zBaseConnector.limit_per_hostC  s     ##rG   c                    | j         r | j                                          d| _         | j                                        }| j        }| j        ri }||z
  }| j                                        D ]\  }}g }|D ]\  }}	|                                re|	|z
  dk     rD|j        }
|	                                 |j
        r!| j        s| j                            |
           f|                    ||	f           ~|j        }
|	                                 |j
        r!| j        s| j                            |
           |r|||<   || _        | j        r*t          j        | d|| j        | j                  | _         dS dS )zCleanup unused transports.Nr   _cleanupr   )r   cancelr`   timer   r   itemsr   r   r   is_sslr   r   r   r   weakref_handler   )rD   nowtimeoutr   deadlinerZ   r   aliveprotouse_timer   s              rE   r   zBaseConnector._cleanupL  s    	( ''))) $(D joo); 	&KW}H"k//11 - -
U', N NOE8))++ N#h.22(-I!KKMMM"z R$2O R $ ? F Fy Q Q Q!LL%):;;;;$)O	: Nd.K N ;BB9MMM -',K$%DK; 	#*#9
'+'C$ $ $D   	 	rG   rZ   r9   valc                 r    | j         }||vrd S ||         }|                    |           |s
| j         |= d S d S r   )r   remove)rD   rZ   r   acquired_per_hostr   s        rE   _drop_acquired_per_hostz%BaseConnector._drop_acquired_per_hosty  s]     !3'''F!#&S 	-',,,	- 	-rG   c                     | j         r| j                                          | j        D ]}||                                 g | _        | j        s/t          j        | d| j        | j        | j	                  | _         dS dS )z~Double confirmation for transport close.

        Some broken ssl servers may leave socket open without proper close.
        Nr   r   )
r   r   r   abortr   r   r   _cleanup_closed_periodr`   r   )rD   r   s     rE   r   zBaseConnector._cleanup_closed  s    
 & 	1'..0008 	" 	"I$!!!*,', 	*1*@!+
'+'C+ + +D'''	 	rG   c                 `    |                                   t          t                                S )zClose all opened transports.)r   r<   r0   rK   s    rE   r   zBaseConnector.close  s!    !$&&)))rG   c                    | j         rd S d| _         	 | j                                        ru	 | j                                         | j                                         | j                                         d | _        | j                                         d | _	        d S | j        r| j        
                                 | j	        r| j	        
                                 | j                                        D ]}|D ]\  }}|                                 | j        D ]}|                                 | j        D ]}||                                 	 | j                                         | j                                         | j                                         d | _        | j                                         d | _	        d S # | j                                         | j                                         | j                                         d | _        | j                                         d | _	        w xY wrI   )r   r`   ru   r   clearr   r   r   r   r   r   r   r   r   )rD   datar   t0r   s        rE   r   zBaseConnector._close  sP   < 	F	/z##%% , KN  """M!!!#'D +11333*.D'''1 # .$++--- * 5+22444**,, " "!% " "IE2KKMMMM"   !< & &	(OO%%%&
 KN  """M!!!#'D +11333*.D''' KN  """M!!!#'D +11333*.D'....s   G  B6G A4H?c                     | j         S )z;Is connector closed.

        A readonly property.
        )r   rK   s    rE   r   zBaseConnector.closed  s     |rG   c                 t   | j         rh| j         t          | j                  z
  }| j        rD|dk    r>|| j        v r5| j                            |          }|J | j        t          |          z
  }nH| j        r?|| j        v r6| j                            |          }|J | j        t          |          z
  }nd}|S )z
        Return number of available connections.

        The limit, limit_per_host and the connection key are taken into account.

        If it returns less than 1 means that there are no connections
        available.
        r   Nr   )r   lenr   r   r   get)rD   rZ   	availableacquireds       rE   _available_connectionsz$BaseConnector._available_connections  s     ; 	c$.&9&99I $AMM4222266s;;+++ 03x==@	! 	cT-D&D&D.22377H''',s8}}<IIIrG   reqtracesr:   r   r8   c                   K   |j         }|                     |          }|dk    s
|| j        v r| j                                        }| j        |                             |           |r|D ]}|                                 d{V  	 | d{V  nO# t          $ rB}|| j        v r2	 | j        |                             |           n# t          $ r Y nw xY w|d}~ww xY w	 || j        v r| j        |         s| j        |= n## || j        v r| j        |         s| j        |= w xY w|r|D ]}|
                                 d{V  |                     |          }	|	yt          t          t                                }
| j                            |
           | j        |                             |
           |r|D ]}|                                 d{V  	 |                     |||           d{V }	| j        r#|	                                 t-          d          	 | j        s0| j                            |
           |                     ||
           nZ# t          $ rM | j        sD| j                            |
           |                     ||
           |                                   w xY w|r|D ]}|                                 d{V  n|rt          t          t                                }
| j                            |
           | j        |                             |
           |D ]}|                                 d{V  | j                            |
           |                     ||
           | j                            |	           | j        |                             |	           t7          | ||	| j                  S )z'Get from pool or create new connection.r   NzConnector is closed.)connection_keyr   r   r`   create_futurer   send_connection_queued_startBaseExceptionr   r   send_connection_queued_end_getr   r)   r   r   addr   send_connection_create_start_create_connectionr   r   r   r   _release_waitersend_connection_create_endsend_connection_reuseconnrX   )rD   r   r   r   rZ   r   futtraceer   placeholders              rE   connectzBaseConnector.connect  s       //44	 >>SDM11***,,C M#%%c*** ?# ? ?E<<>>>>>>>>>>+								  	 	 	$-''c*11#6666%    	  $-''c0B'c* $-''c0B'c***** =# = =E::<<<<<<<<<<		#=0E0G0GHHKN{+++#C(,,[999 ?# ? ?E<<>>>>>>>>>>C"55c67KKKKKKKK< HKKMMM/0FGGGH | CN))+66600kBBB !   | +N))+66600kBBB((***  =# = =E::<<<<<<<<<< ?"?4I4K4KLL"";///',00===# < <E99;;;;;;;;;;%%k222,,S+>>>5!!!$((///$UDJ777s\   
B D 
C	C' CC
CCCCCD  D"AI AJ2c                 (   	 | j         |         }n# t          $ r Y d S w xY w| j                                        }|r|                                \  }}|                                r^||z
  | j        k    rD|j        }|                                 |j	        r!| j
        s| j                            |           nO|s| j         |= |S |j        }|                                 |j	        r!| j
        s| j                            |           || j         |= d S r   )r   KeyErrorr`   r   popr   r   r   r   r   r   r   r   )rD   rZ   r   t1r   r   r   s          rE   r  zBaseConnector._getA  sA   	K$EE 	 	 	44	 Z__ 	F		IE2!!## F7T444 %IKKMMMz J$*G J7>>yIII  - K, L!O	: Fd&C F3::9EEE%  	F* Kts    
c                 l   | j         sdS t          | j                                                   }t          j        |           |D ]m}|                     |          dk     r| j         |         }|rB|                                }|                                s|                    d            dS |BndS )z
        Iterates over all waiters until one to be released is found.

        The one to be released is not finished and
        belongs to a host that has available connections.
        Nr   )	r   listkeysrandomshuffler   popleftdone
set_result)rD   queuesrZ   waiterswaiters        rE   r  zBaseConnector._release_waiter`  s     } 	F dm((**++v 		 		C**3//!33mC(G  **{{}} %%d+++FF	  		 		rG   r   c                     | j         rd S 	 | j                            |           |                     ||           |                                  d S # t
          $ r Y d S w xY wr   )r   r   r   r   r  r  )rD   rZ   r   s      rE   _release_acquiredzBaseConnector._release_acquiredz  s    < 	F	#N!!%(((((e444   """""  	 	 	 DD	s   0A 
AAro   r[   rp   c                   | j         rd S |                     ||           | j        rd}|s|j        rI|j        }|                                 |j        r#| j        s| j        	                    |           d S d S d S | j
                            |          }|g x}| j
        |<   |	                    || j                                        f           | j        /t          j        | d| j        | j        | j                  | _        d S d S )NTr   r   )r   r  r   rp   r   r   r   r   r   r   r   r   r`   r   r   r   r   r   r   )rD   rZ   r[   rp   r   r   s         rE   rv   zBaseConnector._release  sD    < 	FsH--- 	 L 	80 	 *INNz B$"? B/66yAAAAAB B B B KOOC((E}+--C(LL(DJOO$5$56777#+'.'=+J+/+G( ( ($$$ ,+rG   c                 "   K   t                      r   )NotImplementedError)rD   r   r   r   s       rE   r  z BaseConnector._create_connection  s       "###rG   )rA   r4   )NNNrQ   )1rR   rS   rT   r   r   rh   r   r1   r   objectr   r   intr   r   r   rF   rM   r   rP   r   r   r   r   r  r   r   r   r   r   r   r   r)   r   r   r   r   r   r   r   r*   r   rX   r  r  r  r  rv   r  rV   rG   rE   r4   r4      s         G !
 9A!&+48()5 5 5 !u!455 	5
 5 5  $5 w015 !&5 
5 5 5 5n (0 3 3 3D 3 3 3 3*   S T       
 37-115	 4./ M*  .	
 
    !T ! ! ! X! s    X $ $ $ $ X$+ + + +Z	-"	-)8	-		- 	- 	- 	-   .*y * * * *
#/ #/ #/ #/J     X/ c    BQ8 Q8*.w-Q8BQQ8	Q8 Q8 Q8 Q8f H_,E    >   4#_ #_ #QU # # # #( ## # ## "#
 # 
# # # #J$ $*.w-$BQ$	$ $ $ $ $ $rG   r4   c                       e Zd Zddee         ddfdZdedefdZde	e
ef         deee
ef                  ddfd	Zde	e
ef         ddfd
ZddZde	e
ef         deee
ef                  fdZde	e
ef         defdZdS )_DNSCacheTableNttlrA   c                 0    i | _         i | _        || _        d S r   )	_addrs_rr_timestamps_ttl)rD   r'  s     rE   rF   z_DNSCacheTable.__init__  s    VX9;			rG   hostc                     || j         v S r   )r)  )rD   r,  s     rE   __contains__z_DNSCacheTable.__contains__  s    t~%%rG   rZ   addrsc                     t          |          t          |          f| j        |<   | j        t	                      | j        |<   d S d S r   )r   r   r)  r+  r
   r*  )rD   rZ   r/  s      rE   r  z_DNSCacheTable.add  sF    $U||SZZ8s9 $-KKDS!!! ! rG   c                     | j                             |d            | j        | j                            |d            d S d S r   )r)  r  r+  r*  rD   rZ   s     rE   r   z_DNSCacheTable.remove  sI    3%%%9   d+++++ ! rG   c                 j    | j                                          | j                                         d S r   )r)  r   r*  rK   s    rE   r   z_DNSCacheTable.clear  s1         rG   c                 ~    | j         |         \  }}t          t          ||                    }t          |           |S r   )r)  r  r	   next)rD   rZ   r\   lengthr/  s        rE   
next_addrsz_DNSCacheTable.next_addrs  s9    ~c*fVD&))**T


rG   c                 ^    | j         dS | j        |         | j         z   t                      k     S rC   )r+  r*  r
   r2  s     rE   expiredz_DNSCacheTable.expired  s-    95$ty09;;>>rG   r   rQ   )rR   rS   rT   r   r   rF   r#  r   r.  r   r   r$  r   r   r   r  r   r   r7  r9  rV   rG   rE   r&  r&    s>        HUO t    
& &D & & & &0uS#X 0tDcN/C 0 0 0 0 0,%S/ ,d , , , ,! ! ! !eCHo $tCH~2F    ?5c? ?t ? ? ? ? ? ?rG   r&  c            !       R    e Zd ZdZdddddddddeddddddd	d
edee         dedee         dedee	         de
eee	f         deeeef                  dee         de
deef         dededededeej                 def  fdZded         f fdZedefd            Zedefd            Z	 d>dee         d ee         ddfd!Z	 d?ded ed"eed#                  deeeef                  fd$Zd%eeef         ded ed"eed#                  deeeef                  f
d&Zd'ed"ed#         d(d)de fd*Z!e" e#j$        d          d+ede	fd,                        Z%d'edee	         fd-Z&d'eded.         fd/Z'e(d0d1ed'ed(d)d2e)e*         d3edeej+        e f         fd4Z,d@d6Z-dAd7Z.defd8Z/d9ej+        d'eddfd:Z0e(fd9ej+        d'ed(d)d2e)e*         deej1        e f         f
d;Z2e(d0d'ed"ed#         d(d)d2e)e*         deej+        e f         f
d<Z3d'ed"ed#         d(d)deej1        e f         fd=Z4 xZ5S )Br5   a/  TCP connector.

    verify_ssl - Set to True to check ssl certifications.
    fingerprint - Pass the binary sha256
        digest of the expected certificate in DER format to verify
        that the certificate the server presents matches. See also
        https://en.wikipedia.org/wiki/Transport_Layer_Security#Certificate_pinning
    resolver - Enable DNS lookups and use this
        resolver
    use_dns_cache - Use memory cache for DNS lookups.
    ttl_dns_cache - Max seconds having cached a DNS entry, None forever.
    family - socket address family
    local_addr - local tuple of (host, port) to bind socket to

    keepalive_timeout - (optional) Keep-alive timeout.
    force_close - Set to True to force close and do reconnect
        after each request (and between redirects).
    limit - The total number of simultaneous connections.
    limit_per_host - Number of simultaneous connections to one host.
    enable_cleanup_closed - Enables clean-up closed ssl transports.
                            Disabled by default.
    loop - Optional event loop.
    TN
   r   Fr   r   )
verify_sslfingerprintuse_dns_cachettl_dns_cachefamilyssl_contextssl
local_addrresolverr   r   r   r   r   r\   r   r<  r=  r>  r?  r@  rA  rB  rC  rD  r   r   r   r   r   r\   r   c          	      $   t                                          |
||||||           t          ||||          | _        |	t	          | j                  }	|	| _        || _        t          |          | _	        i | _
        || _        || _        d S )Nr   r   )r'  )superrF   r,   _sslr3   r`   	_resolver_use_dns_cacher&  _cached_hosts_throttle_dns_events_family_local_addr)rD   r<  r=  r>  r?  r@  rA  rB  rC  rD  r   r   r   r   r   r\   r   	__class__s                    rE   rF   zTCPConnector.__init__  s    ( 	/#)"7#9 	 	
 	
 	
 &c:{KPP	&DJ777H!++>>>OQ!%rG   rA   c                     | j                                         D ]}|                                 t                                                      S )zClose all ongoing DNS calls.)rK  r   r   rF  r   )rD   evrN  s     rE   r   zTCPConnector.close  sB    +2244 	 	BIIKKKKww}}rG   c                     | j         S )zSocket family like AF_INET.)rL  rK   s    rE   r@  zTCPConnector.family$  s     |rG   c                     | j         S )z%True if local DNS caching is enabled.)rI  rK   s    rE   r>  zTCPConnector.use_dns_cache)  s     ""rG   r,  portc                     | || j                             ||f           dS ||t          d          | j                                          dS )z8Remove specified host/port or clear all dns local cache.Nz5either both host and port or none of them are allowed)rJ  r   r   r   )rD   r,  rS  s      rE   clear_dns_cachezTCPConnector.clear_dns_cache.  se      0%%tTl33333!1WXXX$$&&&&&rG   r   r:   c                   K   t          |          r|||| j        dddgS | j        sn|r |D ]}|                    |           d{V  | j                            ||| j                   d{V }|r |D ]}|                    |           d{V  |S ||f}|| j        v rX| j                            |          s>| j        	                    |          }|r |D ]}|
                    |           d{V  |S t          j        |                     ||||                    }	 t          j        |           d{V S # t          j        $ r d	d}	|                    |	            w xY w)
z*Resolve host and return list of addresses.r   )hostnamer,  rS  r@  r   flagsNr@  r
  $asyncio.Future[List[Dict[str, Any]]]rA   c                     t          t          t          j                  5  |                                  d d d            d S # 1 swxY w Y   d S r   )r   r   r   CancelledErrorresult)r
  s    rE   drop_exceptionz2TCPConnector._resolve_host.<locals>.drop_exceptions  s    i)?@@ ! !JJLLL! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !s   AA	A)r
  rZ  rA   N)r/   rL  rI  send_dns_resolvehost_startrH  resolvesend_dns_resolvehost_endrJ  r9  r7  send_dns_cache_hitr   create_task_resolve_host_with_throttleshieldr\  add_done_callback)
rD   r,  rS  r   r  resrZ   r]  resolved_host_taskr^  s
             rE   _resolve_hostzTCPConnector._resolve_host9  s.       
	 !%  "l 	 	 " 	 A# A AE::4@@@@@@@@@@..tT$,.OOOOOOOOC ?# ? ?E88>>>>>>>>>>JTl$$$$T-?-G-G-L-L$'22377F 9# 9 9E2248888888888M %0,,S$fEE
 
		 (:;;;;;;;;;% 	 	 	! ! ! ! 00@@@	s   &E   *E*rZ   c                   K   || j         v rK| j         |         }|r |D ]}|                    |           d{V  |                                 d{V  nUt          | j                  | j         |<   |r |D ]}|                    |           d{V  	 |r |D ]}|                    |           d{V  | j                            ||| j	                   d{V }|r |D ]}|
                    |           d{V  | j                            ||           | j         |                                          n4# t          $ r'}| j         |                             |            d}~ww xY w	 | j                             |           n# | j                             |           w xY w| j                            |          S )z(Resolve host with a dns events throttle.NrY  )r   )rK  rb  waitr2   r`   send_dns_cache_missr_  rH  r`  rL  ra  rJ  r  r   r  r  r7  )	rD   rZ   r,  rS  r   eventr  r/  r  s	            rE   rd  z(TCPConnector._resolve_host_with_throttlez  si      $+++-c2E 9# 9 9E2248888888888**,, .@
-K-KD%c* :# : :E33D99999999993 E!' E E#>>tDDDDDDDDDD"n44T44UUUUUUUU C!' C C#<<TBBBBBBBBBB"&&sE222)#.224444     )#.22q2999	 5 )--c2222)--c2222!,,S111s+   B&D= <F =
E."E))E..F F)r   r   r8   c                    K   |j         r!|                     |||           d{V \  }}n |                     |||           d{V \  }}|S )zcCreate connection.

        Has same keyword arguments as BaseEventLoop.create_connection.
        N)proxy_create_proxy_connection_create_direct_connection)rD   r   r   r   _r   s         rE   r  zTCPConnector._create_connection  st       9 	R!::3PPPPPPPPHAuu!;;CQQQQQQQQHAurG   verifiedc                    | rt          j                    S t          j        t           j                  }|xj        t           j        z  c_        |xj        t           j        z  c_        d|_        t           j        |_	        	 |xj        t           j
        z  c_        n># t          $ r1}t          j        d                    |                     Y d }~nd }~ww xY w|                                 |S )NFz{!s}: The Python interpreter is compiled against OpenSSL < 1.0.0. Ref: https://docs.python.org/3/library/ssl.html#ssl.OP_NO_COMPRESSION)rB  create_default_context
SSLContextPROTOCOL_TLS_CLIENToptionsOP_NO_SSLv2OP_NO_SSLv3check_hostname	CERT_NONEverify_modeOP_NO_COMPRESSIONAttributeErrorrM   rN   formatset_default_verify_paths)rs  
sslcontextattr_errs      rE   _make_ssl_contextzTCPConnector._make_ssl_context  s     	-///(?@@J#/1#/1(-J%%(]J"""c&;;"""!   - .4VH-=-=	        //111s   B 
C&'CCc                 t   |                                 rt          t          d          |j        }t          |t          j                  r|S |dur|                     d          S | j        }t          |t          j                  r|S |dur|                     d          S |                     d          S dS )a*  Logic to get the correct SSL context

        0. if req.ssl is false, return None

        1. if ssl_context is specified in req, use it
        2. if _ssl_context is specified in self, use it
        3. otherwise:
            1. if verify_ssl is not specified in req, use self.ssl_context
               (will generate a default context according to self.verify_ssl)
            2. if verify_ssl is True in req, generate a default SSL context
            3. if verify_ssl is False in req, generate a SSL context that
               won't verify
        NzSSL is not supported.TF)r   rB  RuntimeError
isinstancerv  r  rG  )rD   r   r  s      rE   _get_ssl_contextzTCPConnector._get_ssl_context  s     ::<< 	{"#:;;;J*cn55 "!!%%--e444J*cn55 "!!%%--e444))$///4rG   r+   c                 ~    |j         }t          |t                    r|S | j        }t          |t                    r|S d S r   )rB  r  r+   rG  )rD   r   rets      rE   _get_fingerprintzTCPConnector._get_fingerprint  sC    gc;'' 	Jic;'' 	JtrG   client_errorargsr  rx   c                  K   	 t          |j        |j                  4 d {V   | j        j        |i | d {V cd d d           d {V  S # 1 d {V swxY w Y   d S # t
          $ r}t          |j        |          |d }~wt          $ r}t          |j        |          |d }~wt          $ r9}|j        t          |t          j                  r  ||j        |          |d }~ww xY wNceil_threshold)r-   sock_connectr  r`   create_connectionr'   r    r   r(   r"   OSErrorerrnor  r   TimeoutError)rD   r   r   r  r  rx   r   s          rE   _wrap_create_connectionz$TCPConnector._wrap_create_connection  s     	A#$W5K   K K K K K K K K :TZ94J6JJJJJJJJK K K K K K K K K K K K K K K K K K K K K K K K K K K K K K  	T 	T 	T1#2DcJJPSS 	L 	L 	L)#*<cBBK 	A 	A 	Ay ZW5I%J%J ,s1377S@	AsQ   !A# AA# 
AA# AA# #
C,-BC,B&&C,34C''C,r*   c                     |                                 sdS |j        }|J |j        dk    rdS |                                  dS )zRaise a :py:exc:`RuntimeError` on missing ``start_tls()``.

        It is necessary for TLS-in-TLS so that it is possible to
        send HTTPS queries through HTTPS proxies.

        This doesn't affect regular HTTP requests, though.
        Nhttps)r   ro  scheme_check_loop_for_start_tls)rD   r   	proxy_urls      rE   _fail_on_no_start_tlsz"TCPConnector._fail_on_no_start_tls  sW     zz|| 	FI	$$$w&&F&&(((((rG   c                 d    	 | j         j         d S # t          $ r}t          d          |d }~ww xY w)Na  An HTTPS request is being sent through an HTTPS proxy. This needs support for TLS in TLS but it is not implemented in your runtime for the stdlib asyncio.

Please upgrade to Python 3.11 or higher. For more details, please see:
* https://bugs.python.org/issue37179
* https://github.com/python/cpython/pull/28073
* https://docs.aiohttp.org/en/stable/client_advanced.html#proxy-support
* https://github.com/aio-libs/aiohttp/discussions/6044
)r`   	start_tlsr  r  )rD   attr_excs     rE   r  z&TCPConnector._check_loop_for_start_tls  sT    	J     	 	 		K  	s    
/*/c                 R    	 |                                   dS # t          $ r Y dS w xY w)NTF)r  r  rK   s    rE   _loop_supports_start_tlsz%TCPConnector._loop_supports_start_tls.  sD    	**,,, 4  	 	 	55	s    
&&underlying_transportc                     |j         j        j        dk    rdS t          |dd          }|rdS t	          j        dt          | d           dS )z6Issue a warning if the requested URL has HTTPS scheme.r  N_start_tls_compatibleFa  An HTTPS request is being sent through an HTTPS proxy. This support for TLS in TLS is known to be disabled in the stdlib asyncio (Python <3.11). This is why you'll probably see an error in the log below.

It is possible to enable it via monkeypatching. For more details, see:
* https://bugs.python.org/issue37179
* https://github.com/python/cpython/pull/28073

You can temporarily patch this as follows:
* https://docs.aiohttp.org/en/stable/client_advanced.html#proxy-support
* https://github.com/aio-libs/aiohttp/discussions/6044
   )rn   r~   )request_infourlr  getattrrM   rN   RuntimeWarning)rD   r  r   asyncio_supports_tls_in_tlss       rE   _warn_about_tls_in_tlsz#TCPConnector._warn_about_tls_in_tls6  s{     &'11F&- #'
 '
# ' 	F
G  !	
 	
 	
 	
 	
 	
rG   c                   K   |                                  }t          t          j        |                     |                    }	 t          |j        |j                  4 d{V  	 | j        	                    ||||j
        p|j        |j                   d{V }n## t          $ r |                                  w xY w	 ddd          d{V  n# 1 d{V swxY w Y   | d} ||j        t!          |                    |                    |           n# t$          $ r}	t'          |j        |	          |	d}	~	wt(          $ r}	t+          |j        |	          |	d}	~	wt           $ r9}	|	j        t/          |	t0          j                  r  ||j        |	          |	d}	~	wt4          $ r<}
t7          d|j        d|j        dd|j        d	|j        pd
 d|
d          |
d}
~
ww xY w||fS )z$Wrap the raw TCP transport with TLS.r  N)server_hostnamessl_handshake_timeoutz:Failed to start TLS (possibly caused by closing transport)z2Cannot initialize a TLS-in-TLS connection to host :dz4 through an underlying connection to an HTTPS proxy z ssl:defaultz [])r   r   rB  rv  r  r-   r  r  r`   r  r  r,  totalr  r   r   r  connection_mader'   r    r(   r"   r  r  r   r  	TypeErrorr   rS  ro  )rD   r  r   r   r  	tls_protor  tls_transportmsgr   type_errs              rE   _start_tls_connectionz"TCPConnector._start_tls_connection[  s6      MMOO	 #.$*?*?*D*DEE
+	#$W5K          *.**>*>,!"(+(;(Gsx.5m +? + + % % % % % %MM %    )..000 "	                          J $R"l3#5ws||DDD%%   /  	T 	T 	T1#2DcJJPSS 	L 	L 	L)#*<cBBK 	A 	A 	Ay ZW5I%J%J ,s1377S@ 
	 
	 
	
 ("8" " #N" "%(Y" "7:w7K)" " " " " 
 
	& i''sx   !D &C(6BC B??CD 
CD "C#D 
G+(D>>G+E!!G+.4F""G+/7G&&G+c                
  K   |                      |          }|                     |          }|j        j        }|J |                    d          r|                    d          dz   }|j        }|J 	 |                     |||           d {V }	nJ# t          $ r=}
|
j	        t          |
t          j                  r t          |j        |
          |
d }
~
ww xY wd }|	D ]}|d         }|d         }|r"|j        p|d                             d          nd }	 |                     | j        |||||d         |d         |d	         || j        ||
           d {V \  }}n# t          $ r}
|
}Y d }
~
d }
~
ww xY w|                                rh|rf	 |                    |           nO# t*          $ rB}
|                                 | j        s| j                            |           |
}Y d }
~
d }
~
ww xY w||fc S |J |)Nz...)r   r,  rS  rW  r@  r   rX  )	r   rB  r@  r   rX  r  rC  r   r  )r  r  r  raw_hostendswithrstriprS  ri  r  r  r  r   r  r!   r   r  r  r   rM  r   checkr%   r   r   r   r   )rD   r   r   r   r  r  r=  r,  rS  hostsr   last_exchinfor  transpr   s                   rE   rq  z&TCPConnector._create_direct_connection  s      **3//
++C00w == 	*;;s##c)Dx
	I ,,T4,GGGGGGGGEE 	I 	I 	Iy ZW5I%J%J  's'93??SH	I )- ,	 ,	E=D=D $9j(9AA#FFF &*&B&BM#" ?..$3#/!- 'C ' ' ! ! ! ! ! ! (    zz||  %%f----0   LLNNN8 G7>>vFFF"HHHHH 5=   '''NsI   6B 
C8CCAE$$
E:.E55E:F**
G647G11G6c                   K   |                      |           |                                 }i }|j        |j        }|j        t          j                 |t          j        <   |j        }|J t          t          j        |||j	        | j
        |j                  }|                     |g |t                     d {V \  }}	|	                                 |j                            t          j        d           }
|
=|                                s|
|j        t          j        <   n|
|j        t          j        <   |                                r|r|                     ||           t          j        |_        |j        |_        t/          j        |j        d d d           }t5          | ||	| j
                  }|                    |           d {V }	 |j        }|J |                    || j                   |                    |           d {V }d |_        d |_         	 |j!        dk    rJ|j"        }|tG          |j!                  j$        }tK          |j&        |j'        |j!        ||j                  |s<|(                    dd           }|tS          d	          |*                                }n## tV          $ r |,                                  w xY w|s|,                                 n# |s|,                                 w w xY w|sU| -                    |          }| .                    | j/        ||||j0        |
           d {V 	 |,                                 S | 1                    |||           d {V 	 |,                                 S # tV          $ r* |,                                 |,                                  w xY w# |,                                 w xY w||	fS )N)headersauthr\   rB  r  )ro  
proxy_authproxy_headers_hash)read_until_eofr      )statusrr   r  socket)r  z)Transport does not expose socket instance)r   rB  sockr  r   )r   r   )2r  r  proxy_headersr  r   HOSTro  r*   METH_GETr  r`   rB  rq  r$   r   r  AUTHORIZATIONr   PROXY_AUTHORIZATIONr  METH_CONNECTmethodr  attrevolver   rX   sendra   set_response_paramsr   startr   r  reasonr   phraser#   r  historyget_extra_infor  dupr  r   r  r  r   r,  r  )rD   r   r   r   runtime_has_start_tlsr  r  	proxy_reqr   r   r  rZ   conn
proxy_respr[   resprr   rawsockr  s                      rE   rp  z%TCPConnector._create_proxy_connection  s      	""3''' $ = = ? ?"$('G [3	i!M
 
 
	 "&!?!?r71K "@ "
 "
 
 
 
 
 
 
	5 	 $$T%7>>::<< C8<D455>B	!$":;::<< Y	#$ <++Is;;;  $0IGIM+"$4TX  C dC
;;D(~~d33333333JE#>+++
 ,,#8+/+G -    (--d33333333 "&"&*{c))"&+"?&0&=&=&DG2&3 L#';$+$(L    1 0"+":":8T":"R"R"?". K# #  #*++--$    OO%%% 1 *!))) 1 *!))))* - 
!%!6!6s!;!;J!%!=!= '&$(+ "> " "       "   """" "77 # 8            """"s !     """

r   """"%sQ   AN O #BJ7 6K1 7 KK1 O 1L

AO $O 4OO O$)NNr   )r   r*   rA   NrQ   )6rR   rS   rT   r   r1   r   r   bytesr$  rv  r   r+   r   r   r   r   r#  r   r   rF   r   r   r   r@  r>  rU  r   r   r   ri  rd  r*   r)   r  staticmethodr   	lru_cacher  r  r  r!   r   r   r   r  r  r  r  r  BaseTransportr  rq  rp  __classcell__rN  s   @rE   r5   r5     s        6  '+"'),04804/38@!&+48()%'& '& '& '& e_	'&
 '&  }'& '& j)'& 4j01'& U38_-'& +,'& !uf!45'& '& '& '&   $!'&" w01#'&$ !&%'& '& '& '& '& '&Ry           X #t # # # X#
 AE	' 	'SM	'08	'		' 	' 	' 	' GK? ??"?,4T'],C?	d38n	? ? ? ?B*238_*2 *2 	*2
 g'*2 
d38n	*2 *2 *2 *2X *.w-BQ	    YD Z     \*M hz6J    BM h}6M     )=A A AA A !	A
 9oA A 
w /1	2A A A A,) ) ) )$   "$    #
%/#
 #
 
	#
 #
 #
 #
T )=>( >(%/>( >( !	>(
 9o>( 
w$o5	6>( >( >( >(L )=N N NN WN !	N 9oN 
w /1	2N N N N`B  B *.w-B BQB 	w$o5	6B  B  B  B  B  B  B  B rG   r5   c                        e Zd ZdZdedddfdededeee	df         d	e
d
e
deej                 ddf fdZedefd            Zdeded         dddefdZ xZS )r6   a  Unix socket connector.

    path - Unix socket path.
    keepalive_timeout - (optional) Keep-alive timeout.
    force_close - Set to True to force close and do reconnect
        after each request (and between redirects).
    limit - The total number of simultaneous connections.
    limit_per_host - Number of simultaneous connections to one host.
    loop - Optional event loop.
    Fr   r   Npathr   r   r   r   r\   rA   c                 b    t                                          |||||           || _        d S )Nr   r   r   r   r\   )rF  rF   _pathrD   r  r   r   r   r   r\   rN  s          rE   rF   zUnixConnector.__init__|  sB     	#/) 	 	
 	
 	
 


rG   c                     | j         S )zPath to unix socket.r  rK   s    rE   r  zUnixConnector.path       zrG   r   r   r:   r   r8   c                   K   	 t          |j        |j                  4 d {V  | j                            | j        | j                   d {V \  }}d d d           d {V  n# 1 d {V swxY w Y   nP# t          $ rC}|j        t          |t          j                  r t          | j        |j        |          |d }~ww xY w|S r  )r-   r  r  r`   create_unix_connectionr   r  r  r  r  r   r  r&   r  r   rD   r   r   r   rr  r   r   s          rE   r  z UnixConnector._create_connection  s     
	X#$W5K           "&!B!BM4:" "      5                            	X 	X 	Xy ZW5I%J%J *49c6H#NNTWW	X
 s:   !A8 /A&A8 &
A00A8 3A04A8 8
C>C  CrR   rS   rT   r   r1   r   r   r   r#  r   r$  r   r   r   rF   r   r  r*   r   r)   r  r  r  s   @rE   r6   r6   p  s       	 	 "8@48   !!45	
   w01 
     $ c    X *.w-BQ	       rG   r6   c                        e Zd ZdZdedddfdededeee	df         d	e
d
e
deej                 ddf fdZedefd            Zdeded         dddefdZ xZS )r7   a  Named pipe connector.

    Only supported by the proactor event loop.
    See also: https://docs.python.org/3/library/asyncio-eventloop.html

    path - Windows named pipe path.
    keepalive_timeout - (optional) Keep-alive timeout.
    force_close - Set to True to force close and do reconnect
        after each request (and between redirects).
    limit - The total number of simultaneous connections.
    limit_per_host - Number of simultaneous connections to one host.
    loop - Optional event loop.
    Fr   r   Nr  r   r   r   r   r\   rA   c                     t                                          |||||           t          | j        t          j                  st          d          || _        d S )Nr  z9Named Pipes only available in proactor loop under windows)rF  rF   r  r`   r   ProactorEventLoopr  r  r  s          rE   rF   zNamedPipeConnector.__init__  sw     	#/) 	 	
 	
 	
 J1
 
 	 N   


rG   c                     | j         S )zPath to the named pipe.r  rK   s    rE   r  zNamedPipeConnector.path  r  rG   r   r   r:   r   r8   c                   K   	 t          |j        |j                  4 d {V  | j                            | j        | j                   d {V \  }}t          j        d           d {V  d d d           d {V  n# 1 d {V swxY w Y   nJ# t          $ r=}|j
        t          |t          j                  r t          |j        |          |d }~ww xY wt          t           |          S )Nr  r   )r-   r  r  r`   create_pipe_connectionr   r  r   sleepr  r  r  r  r!   r   r   r)   r  s          rE   r  z%NamedPipeConnector._create_connection  s     	I#$W5K   
' 
' 
' 
' 
' 
' 
' 
' "&!B!BM4:" "      5 mA&&&&&&&&&
' 
' 
' 
' 
' 
' 
' 
' 
' 
' 
' 
' 
' 
' 
' 
' 
' 
' 
' 
' 
' 
' 
' 
' 
' 
' 
'  	I 	I 	Iy ZW5I%J%J &s'93??SH	I
 OU+++s;   !B A	B .B  
B

B B
B 
C8CCr  r  s   @rE   r7   r7     s        " "8@48   !!45	
   w01 
     0 c    X, ,*.w-,BQ,	, , , , , , , ,rG   r7   )Xr   r   r  rf   rd   rM   collectionsr   r   
contextlibr   httpr   http.cookiesr   	itertoolsr   r	   r   r
   typesr   typingr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   abcr   client_exceptionsr   r    r!   r"   r#   r$   r%   r&   r'   r(   client_protor)   client_reqrepr*   r+   r,   r-   r.   r/   r0   r1   locksr2   rD  r3   rB  rv  ImportErrorr#  __all__clientr8   r9   tracingr:   r<   rX   r   r4   r&  r5   r6   r7   rV   rG   rE   <module>r     s         



      * * * * * * * *             % % % % % % # # # # # # # #                                             $          ! ! ! ! ! !                        * ) ) ) ) ) H H H H H H H H H H R R R R R R R R R R R R R R % % % % % % % % % % % %JJJJJ   
CJJJ
 S  %%%%%%,,,,,,       (XK XK XK XK XK XK XK XKv       s$ s$ s$ s$ s$ s$ s$ s$l$? $? $? $? $? $? $? $?NR
  R
  R
  R
  R
 = R
  R
  R
 j2 2 2 2 2M 2 2 2jB, B, B, B, B, B, B, B, B, B,s   >C
 
	CC