o
    Zh                  5   @   s  U d Z 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ZddlZddl	m
Z
 ddlmZ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  ddl!Z!ddl"m#Z#m$Z$m%Z%m&Z& ddl'm(Z( dd	l)m*Z*m+Z+m,Z, dd
l-m.Z. ddl/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZB ddlCmDZDmEZEmFZFmGZGmHZH ddlImJZJ ddlKmLZLmMZMmNZNmOZO ddlPmQZQ ddlRmSZSmTZTmUZUmVZVmWZWmXZXmYZYmZZZm[Z[m\Z\ ddl+m]Z]m^Z^m_Z_m`Z` ddlambZbmcZcmdZdmeZe ddlfmgZg ddlhmiZimjZj ddlkmlZlmmZmmnZnmoZo dZper%ddlqmrZr ndZre!jsddddG dd dZtetddZueet evd< edZweeEexgeyf ZzG d d! d!Z{G d"d# d#eeeewf eew Z|G d$d% d%e|eE Z}G d&d' d'e|eJ Z~G d(d) d)Zdddddddd*ddd+dddde[de+jdddd,d,d-d.eyd/eod0eeeyeyf  d1ed2ed3een d4eeey  d5eeU d6ed7ed8eey d9ee d:ed;ee d<ed=eeo d>eeU d?e etef d@eem dAe^dBeeL dCee dDeej dEedFedGef4dHdIZdS )JzHTTP Client for asyncio.    N)suppress)SimpleNamespaceTracebackType)TYPE_CHECKINGAny	AwaitableCallable	CoroutineFinal	FrozenSet	GeneratorGenericIterableListMappingOptionalSetTupleTypeTypeVarUnion)CIMultiDict	MultiDictMultiDictProxyistr)URL   )hdrshttppayload)AbstractCookieJar)ClientConnectionErrorClientConnectorCertificateErrorClientConnectorErrorClientConnectorSSLErrorClientErrorClientHttpProxyErrorClientOSErrorClientPayloadErrorClientProxyConnectionErrorClientResponseErrorClientSSLErrorContentTypeError
InvalidURLServerConnectionErrorServerDisconnectedErrorServerFingerprintMismatchServerTimeoutErrorTooManyRedirectsWSServerHandshakeError)ClientRequestClientResponseFingerprintRequestInfo_merge_ssl_params)ClientWebSocketResponse)BaseConnectorNamedPipeConnectorTCPConnectorUnixConnector)	CookieJar)
	_SENTINELDEBUG	BasicAuthTimeoutHandleceil_timeoutget_env_proxy_for_urlget_running_loopmethod_must_be_empty_bodysentinelstrip_auth_from_url)WS_KEYHttpVersionWebSocketReaderWebSocketWriter)WSHandshakeError	WSMessage
ws_ext_genws_ext_parse)FlowControlDataQueue)TraceTraceConfig)JSONEncoderLooseCookiesLooseHeadersStrOrURL)r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r:   r<   r=   r;   r9   ClientSessionClientTimeoutrequest)
SSLContextT)Zauto_attribsfrozenslotsc                   @   sZ   e Zd ZU dZee ed< dZee ed< dZee ed< dZ	ee ed< dZ
eed< dS )rY   Ntotalconnect	sock_readsock_connect   ceil_threshold)__name__
__module____qualname__r^   r   float__annotations__r_   r`   ra   rc    ri   ri   E/var/www/html/lang_env/lib/python3.10/site-packages/aiohttp/client.pyrY      s   
 rY   i,  r^   DEFAULT_TIMEOUT_RetTypec                ?       s  e Zd ZU dZeg dZdZeej	 e
d< dZee e
d< 	dddddddejeeeejdddededddddd	d	d
d ddee dee deej dee dee deee  dee dedee dee dee dedee  de!de"e!e#ege$d f f de"e%e&f dee% de"e'e(f de!d e!d!e!d"ee)e*  d#e+d$e+d%e+d&e,d'df6d(d)Z-d*ed  d'dfd+d,Z.e/rd-ed.e0d'df fd/d0Z1e2fd1e0d'dfd2d3Z3d4ed5ed6e0d'd7fd8d9Z4d:ed'e5fd;d<Z6ddddddddd=dddddddedddddddddddd>d4ed:ed?ee7eef  d@e0dAe0dee dee deee  dee dBe!dCe+dDee dEee! dFe!de"de!e#ege$d f f dGe!dHee dIee de"e(e&f dJee! dKee8 dLee9 dMe"e9e!e:f dNee dOee dPee; d#ee+ dee! d$ee+ d%ee+ d'ef>dQdRZ<e=j>dSdTddddddddddddddddUdVdWd5ed4edXee de%dYee% dZe!d[e!d\ee% dee d]ee d?ee7eef  dee dHee dIee dMe"e9e!de:f dJee! dKee8 dLee9 dOee dDe+d^e+d'd_f,d`daZ?e=j>dSdTddddddddddddddddUdVdWd5ed4edXee de%dYee% dZe!d[e!d\ee% dee d]ee d?ee7eef  dee dHee dIee dMee"e9e!e:f  dJee! dKee8 dLee9 dOee dDe+d^e+d'ef,dbdcZ@dee d'ddfdedfZAddgd5edBe!d6e0d'd7fdhdiZBddgd5edBe!d6e0d'd7fdjdkZCddgd5edBe!d6e0d'd7fdldmZDddnd5ed@e0d6e0d'd7fdodpZEddnd5ed@e0d6e0d'd7fdqdrZFddnd5ed@e0d6e0d'd7fdsdtZGd5ed6e0d'd7fdudvZHddwdxZIeJd'e!fdydzZKeJd'ee fd{d|ZLeJd'e fd}d~ZMeJd'eNe+e+f fddZOeJd'e!fddZPePjQd.e!d'dfddZPeJd'ejfddZReJd'e(fddZSeJdddZTeJd'eUeV fddZWeJd'ee fddZXeJd'efddZYeJd'e!fddZZeJd'e"e!e#ege$d f f fddZ[eJd'e!fddZ\eJd'e!fddZ]eJd'e)e* fddZ^dddZ_dddZ`deeea  deea deeb d'dfddZcdddZddeeea  deea deeb d'dfddZe  ZfS )rX   z/First-class interface for making HTTP requests.)	_base_url_source_traceback
_connectorrequote_redirect_url_loop_cookie_jar_connector_owner_default_auth_version_json_serialize_requote_redirect_url_timeout_raise_for_status_auto_decompress
_trust_env_default_headers_skip_auto_headers_request_class_response_class_ws_response_class_trace_configs_read_bufsize_max_line_size_max_field_size_resolve_charsetNro   rp   TF     c                 C   s   dS )Nzutf-8ri   )rbri   ri   rj   <lambda>   s    zClientSession.<lambda>)	connectorloopcookiesheadersskip_auto_headersauthjson_serializerequest_classresponse_classws_response_classversion
cookie_jarconnector_ownerraise_for_statusread_timeoutconn_timeouttimeoutauto_decompress	trust_envrq   trace_configsread_bufsizemax_line_sizemax_field_sizefallback_charset_resolverbase_urlr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rq   r   r   r   r   r   returnc                C   s@  |d u r|d ur|j }t|}|d u st|tr|| _nt|| _| j | jks-J d|d u r6t|d}|j |ur?td|| _ | rOt	
td| _|d u rXt|d}|| _|d ure| j| || _|| _|| _|| _|| _|tu s||d u rt| _|turtjdtdd tj| j|d| _|d urtj| j|d	| _tjd
tdd n"t|tstdt | d|| _|turtd|d urtd|| _!|| _"|| _#|| _$|| _%|| _&|| _'|rt(|}nt( }|| _)|d urt*dd |D | _+nt* | _+|	| _,|
| _-|| _.|pg | _/| j/D ]}|0  q|| _1d S )Nz2Only absolute URLs without path part are supportedr   z0Session and connector has to use same event loopr   z8read_timeout is deprecated, use timeout argument instead   
stacklevelrk   )r_   z8conn_timeout is deprecated, use timeout argument insteadztimeout parameter cannot be of z. type, please use 'timeout=ClientTimeout(...)'zGread_timeout and timeout parameters conflict, please setup timeout.readzJconn_timeout and timeout parameters conflict, please setup timeout.connectc                 s   s    | ]}t |V  qd S N)r   ).0iri   ri   rj   	<genexpr>D  s    z)ClientSession.__init__.<locals>.<genexpr>)2rr   rE   
isinstancer   rn   originr<   RuntimeError	get_debug	tracebackextract_stacksys	_getframero   r>   rs   update_cookiesrp   rt   ru   rv   rw   rG   rl   ry   warningswarnDeprecationWarningattrZevolverY   
ValueErrortyperz   r{   r|   rx   r   r   r   r   r}   	frozensetr~   r   r   r   r   freezer   )selfr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rq   r   r   r   r   r   real_headerstrace_configri   ri   rj   __init__   s    







zClientSession.__init__clsc                 C   s   t jd| jtdd d S )Nz6Inheritance class {} from ClientSession is discouragedr   r   )r   r   formatrd   r   )r   ri   ri   rj   __init_subclass__R  s   
zClientSession.__init_subclass__namevalc                    s2   || j vrtjd|tdd t || d S )Nz8Setting custom ClientSession.{} attribute is discouragedr   r   )ATTRSr   r   r   r   super__setattr__)r   r   r   	__class__ri   rj   r   \  s   
zClientSession.__setattr__	_warningsc                 C   sZ   | j s+d| i}|jd| tfi | | dd}| jd ur#| j|d< | j| d S d S )NsourcezUnclosed client session zUnclosed client session)Zclient_sessionmessagesource_traceback)closedr   ResourceWarningro   rr   call_exception_handler)r   r   kwargscontextri   ri   rj   __del__f  s   



zClientSession.__del__methodurlr   _RequestContextManagerc                 K   s   t | j||fi |S )zPerform HTTP request.)r   _request)r   r   r   r   ri   ri   rj   rZ   q  s   zClientSession.request
str_or_urlc                 C   s:   t |}| jd u r|S | s|jdsJ | j|S )N/)r   rn   is_absolutepath
startswithjoin)r   r   r   ri   ri   rj   
_build_urlw  s
   
zClientSession._build_url
   )paramsdatajsonr   r   r   r   allow_redirectsmax_redirectscompresschunked	expect100r   read_until_eofproxy
proxy_authr   
verify_sslfingerprintssl_contextsslserver_hostnameproxy_headerstrace_request_ctxr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   c          7         s   j rtdt||||}|d ur|d urtd|d ur'tj| jd}t|ts6|d ur6t	
dt d}g }  j}!|p@i } |} |}z |}"W n tyc }# zt||#d }#~#ww t j}$|d ury|D ]	}%|$t|% qo|d urzt|}W n ty }# zt||#d }#~#ww |tu r j}&nt|tst|d}&n|}&t j|&j|&jd}'|' }(|d u r j}|d u rƈ j}|d u r͈ j}|d u rԈ j } fdd	 j!D })|)D ]}*|*"||"#||I d H  q|'$ }+z|+ 	 t%|"\}"},|	r|,rtd|	d u r|,}	|	d u r j&}	|d ur/|	d ur/t'j(|v r/td j)*|"}-|d urOt+ }.|.,| |.*|"}/|/rO|--|/ |d urYt|}n j.rxt/t0 t1|"\}}W d    n	1 ssw   Y   j2||"fi d|d|d|$d|d|-d|	d|!d|d|d|d jd j3d|d|d|+d d|d ur|nd
d|d|d |)d! j4}0z9t5|&j6|&jd4 I d H   j7d usJ  j7j6|0|)|&d"I d H }1W d   I d H  n1 I d H sw   Y  W n t8j9y }2 zt:d#;|"|2d }2~2ww |1j<d us!J |1j=d us)J |1j=j>|+t?||||&j@| j7jA||d$	 z2z"|0B|1I d H }3z
|3|1I d H  W n tCy^   |3D   w W n tCym   |1D   w W n) tEyx     tFy }2 z|2jGd u rt|2t8j9r tH|2jI |2d }2~2ww  j),|3jJ|3jK |3jLd%v rs|
rs|)D ]}*|*M||"#|||3I d H  q|d&7 }| N|3 |r||kr|3D  tO| d jPtQ| |3jLd'kr|3jRt'jSks|3jLd(v r
|3jRt'jTkr
t'jU}d }|Vt'jWr
|Xt'jW |3jYVt'jZp|3jYVt'j[}4|4d u rnU|3\  z
t|4 j] d)}5W n ty? }# zt|4|#d }#~#ww |5j^}6|6d*vrP|3D  td+|6sX|"_|5}5|"` |5` krjd }	|Xt'j(d  |5}"i }|3\  q	 W d    n	1 sw   Y  |d u r ja}|d u rntb|r||3I d H  n|r|3c  |(d ur|3jdd ur|3jde|(jf n|(f  tQ| |3_g|)D ]}*|*h||"#|||3I d H  q|3W S  tCy }# z"|'D  |(r|(f  d }(|)D ]}*|*i||"#|||#I d H  q d }#~#ww ),NzSession is closedz9data and json parameters can not be used at the same time)dumpszChunk size is deprecated #1615r   rk   )rc   c                    s    g | ]}t  ||jd qS ))r   )rR   Ztrace_config_ctx)r   r   r   r   ri   rj   
<listcomp>  s    
z*ClientSession._request.<locals>.<listcomp>Tz<Cannot combine AUTH argument with credentials encoded in URLzTCannot combine AUTHORIZATION header with AUTH argument or credentials encoded in URLr   r   r   r   r   r   r   r   r   r   r   r   r   r   timersessionr   r   r   tracesr   )r   r   zConnection timeout to host {})	r   Zskip_payloadr   r   r   r   Ztimeout_ceil_thresholdr   r   )-  .  /  i3  i4  r   r   )r   r   )encoded)r   https z"Can redirect only to http or https)jr   r   r8   r   r   ZJsonPayloadrw   r   boolr   r   r   rv   _prepare_headersr   r-   setr~   addr   r   rG   ry   rY   rB   rr   r^   rc   startr   r{   r   r   r   Zsend_request_startZupdate_queryr   rH   ru   r   ZAUTHORIZATIONrs   Zfilter_cookiesr>   r   loadr|   r   LookupErrorrD   r   r   r   rC   r_   rp   asyncioTimeoutErrorr1   r   	transportprotocolZset_response_paramsrF   r`   Z_timeout_ceil_thresholdsendBaseExceptioncloser%   OSErrorerrnor'   argsr   r   statusZsend_request_redirectappendr2   request_infotupler   	METH_HEAD	METH_POSTMETH_GETgetZCONTENT_LENGTHpopr   ZLOCATIONURIreleaserx   schemer   r   rz   callabler   
connectionZadd_callbackcancelZ_historyZsend_request_endZsend_request_exception)7r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Z	redirectshistoryr   r   eZskip_headersr   Zreal_timeouttmhandler   tracer   Zauth_from_urlZall_cookiesZtmp_cookie_jarZreq_cookiesreqconnexcrespZr_url
parsed_urlr  ri   r   rj   r     s   )





	










	
*





  
6



zClientSession._requestri   g      $@r   i  @ )r   	protocolsr   receive_timeout	autocloseautoping	heartbeatr   r   r   r   r   r   r   r   r   r   r   r   max_msg_sizer+  r,  r-  r.  r/  r   r0  _WSRequestContextManagerc                C   s   t | j|fi d|d|d|d|d|d|d|d|	d	|
d
|d|d|d|d|d|d|d|d|d|d|S )zInitiate websocket connection.r   r+  r   r,  r-  r.  r/  r   r   r   r   r   r   r   r   r   r   r   r   r0  )r1  _ws_connect)r   r   r   r+  r   r,  r-  r.  r/  r   r   r   r   r   r   r   r   r   r   r   r   r0  ri   ri   rj   
ws_connect  sZ   	
zClientSession.ws_connectc          *         s8  |d u r	t  }nt |}tjdtjdtjdi}| D ]
\}}||| qtt	
d}| |tj< |r@d||tj< |
d urI|
|tj< |rUt|d}||tj< |d u r[d}t||||}| j||||d|	||||d	
I d H }z|jd
krt|j|jd|j|jd|jtjd dkrt|j|jd|j|jd|jtjd dkrt|j|jd|j|jd|jtjd}tt|t   }||krt|j|jd|j|jdd }|r	tj|jv r	dd |jtj  dD } | D ]}!|!|v r|!} nqd}"|rC|jtj}#|#r?zt!|#\}}"W n" t"y> }$ zt|j|j|$j#d |j|jd|$d }$~$ww d}d}"|j$}%|%d usMJ |%j%}&|&d usWJ |%j&}'|'d usaJ t'|&d| j(d}(|&)t*|(||( t+|&|'d||"d})W n t,y   |-   w | j.|(|)|||||| j(||||"dS )NZ	websocketZUpgradeZ13   ,)r   TF)r   r   r   r   r   r   r   r   e   zInvalid response status)r   r  r   r   zInvalid upgrade headerupgradezInvalid connection headerzInvalid challenge responsec                 S   s   g | ]}|  qS ri   )strip)r   protori   ri   rj   r   y  s    z-ClientSession._ws_connect.<locals>.<listcomp>r   r   r   )Zuse_maskr   
notakeover)r,  r/  r   Zclient_notakeover)/r   r   UPGRADEZ
CONNECTIONZSEC_WEBSOCKET_VERSIONitems
setdefaultbase64	b64encodeosurandomdecodeZSEC_WEBSOCKET_KEYr   ZSEC_WEBSOCKET_PROTOCOLZORIGINrO   ZSEC_WEBSOCKET_EXTENSIONSr8   rZ   r  r3   r  r!  r   r  lowerZSEC_WEBSOCKET_ACCEPThashlibsha1rI   digestsplitrP   rM   r  r  r  r
  rQ   rr   
set_parserrK   rL   r  r  r   )*r   r   r   r+  r   r,  r-  r.  r/  r   r   r   r   r   r   r   r   r   r   r   r   r0  r   default_headerskeyvalueZsec_keyZextstrr)  Zr_keymatchr  Zresp_protocolsr9  r:  Zcompress_hdrsr(  r'  Z
conn_protor
  readerwriterri   ri   rj   r2    s  



		
	
zClientSession._ws_connectCIMultiDict[str]c                 C   sh   t | j}|r2t|ttfst |}t }| D ]\}}||v r(||| q|||< || q|S )z3Add default headers and transform it to CIMultiDict)r   r}   r   r   r   r  r<  r  )r   r   resultZadded_namesrJ  rK  ri   ri   rj   r    s   
zClientSession._prepare_headers)r   c                K      t | jtj|fd|i|S )zPerform HTTP GET request.r   )r   r   r   r  r   r   r   r   ri   ri   rj   r       zClientSession.getc                K   rQ  )zPerform HTTP OPTIONS request.r   )r   r   r   ZMETH_OPTIONSrR  ri   ri   rj   options     zClientSession.optionsc                K   rQ  )zPerform HTTP HEAD request.r   )r   r   r   r  rR  ri   ri   rj   head  rU  zClientSession.head)r   c                K   rQ  )zPerform HTTP POST request.r   )r   r   r   r  r   r   r   r   ri   ri   rj   post  rS  zClientSession.postc                K   rQ  )zPerform HTTP PUT request.r   )r   r   r   ZMETH_PUTrW  ri   ri   rj   put  rS  zClientSession.putc                K   rQ  )zPerform HTTP PATCH request.r   )r   r   r   Z
METH_PATCHrW  ri   ri   rj   patch  rS  zClientSession.patchc                 K   s   t | jtj|fi |S )zPerform HTTP DELETE request.)r   r   r   ZMETH_DELETE)r   r   r   ri   ri   rj   delete  s   zClientSession.deletec                    s6   | j s| jdur| jr| j I dH  d| _dS dS )zMClose underlying connector.

        Release all acquired resources.
        N)r   rp   rt   r  r   ri   ri   rj   r    s   
zClientSession.closec                 C   s   | j du p| j jS )z@Is client session closed.

        A readonly property.
        N)rp   r   r\  ri   ri   rj   r     s   zClientSession.closedc                 C      | j S )z(Connector instance used for the session.rp   r\  ri   ri   rj   r        zClientSession.connectorc                 C   r]  )zThe session cookies.)rs   r\  ri   ri   rj   r     r_  zClientSession.cookie_jarc                 C   r]  )z"The session HTTP protocol version.)rv   r\  ri   ri   rj   r     r_  zClientSession.versionc                 C   r]  ))Do URL requoting on redirection handling.)rx   r\  ri   ri   rj   rq   #  r_  z"ClientSession.requote_redirect_urlc                 C   s   t jdtdd || _dS )r`  z=session.requote_redirect_url modification is deprecated #2778r   r   N)r   r   r   rx   )r   r   ri   ri   rj   rq   (  s   
c                 C   s   t jdtdd | jS )zSession's loop.z"client.loop property is deprecatedr   r   )r   r   r   rr   r\  ri   ri   rj   r   2  s   zClientSession.loopc                 C   r]  )zTimeout for the session.)ry   r\  ri   ri   rj   r   :  r_  zClientSession.timeoutc                 C   r]  )z*The default headers of the client session.)r}   r\  ri   ri   rj   r   ?  r_  zClientSession.headersc                 C   r]  )z2Headers for which autogeneration should be skipped)r~   r\  ri   ri   rj   r   D  r_  zClientSession.skip_auto_headersc                 C   r]  )z2An object that represents HTTP Basic Authorization)ru   r\  ri   ri   rj   r   I  r_  zClientSession.authc                 C   r]  )zJson serializer callable)rw   r\  ri   ri   rj   r   N  r_  zClientSession.json_serializec                 C   r]  )z-Should connector be closed on session closing)rt   r\  ri   ri   rj   r   S  r_  zClientSession.connector_ownerc                 C   r]  )zGShould `ClientResponse.raise_for_status()` be called for each response.)rz   r\  ri   ri   rj   r   X  s   zClientSession.raise_for_statusc                 C   r]  )z7Should the body response be automatically decompressed.)r{   r\  ri   ri   rj   r   _  r_  zClientSession.auto_decompressc                 C   r]  )z
        Should proxies information from environment or netrc be trusted.

        Information is from HTTP_PROXY / HTTPS_PROXY environment variables
        or ~/.netrc file if present.
        )r|   r\  ri   ri   rj   r   d  s   zClientSession.trust_envc                 C   r]  )z7A list of TraceConfig instances used for client tracing)r   r\  ri   ri   rj   r   n  r_  zClientSession.trace_configsc                 C   s
   d| _ dS )zwDetach connector from session without closing the former.

        Session is switched to closed state anyway.
        Nr^  r\  ri   ri   rj   detachs  s   
zClientSession.detachc                 C   s   t d)NzUse async with instead)	TypeErrorr\  ri   ri   rj   	__enter__z     zClientSession.__enter__exc_typeexc_valexc_tbc                 C   s   d S r   ri   r   re  rf  rg  ri   ri   rj   __exit__}  s   zClientSession.__exit__c                    s   | S r   ri   r\  ri   ri   rj   
__aenter__  s   zClientSession.__aenter__c                    s   |   I d H  d S r   )r  rh  ri   ri   rj   	__aexit__  s   zClientSession.__aexit__r   r   N)r   rO  )r   rX   )grd   re   rf   __doc__r   r   ro   r   r   StackSummaryrh   rp   r:   r   r   r4   r5   r9   r   HttpVersion11rG   rW   r  AbstractEventLooprU   rV   r   strrA   rT   r   rJ   r    r  r   r   r   rg   r?   objectrY   r   rS   int_CharsetResolverr   r   r@   r   r   r   r   rZ   r   r   r   bytesr[   r6   r   r   r   r  r3  r2  r  r  rT  rV  rX  rY  rZ  r[  r  propertyr   r   r   r   r   rq   setterr   r   r   r   r   r   r   r   r   r   r   r   r   ra  rc  r  r   ri  rj  rk  __classcell__ri   ri   r   rj   rX      s  
 
	




 

	


 !"#
  Z	

8	

 4
	


	
	


		




	
rX   c                   @   s   e Zd ZdZdeddef ddfddZdd	d
ZdededdfddZ	dddZ
deedef fddZdeedef fddZdefddZdS )_BaseRequestContextManager_coro_respcoroasyncio.Future[Any]Nr   c                 C   s
   || _ d S r   )r{  )r   r}  ri   ri   rj   r        
z#_BaseRequestContextManager.__init__argc                 C   s   | j |S r   )r{  r  )r   r  ri   ri   rj   r    s   z_BaseRequestContextManager.sendr  r   c                 O   s   | j j|i |S r   )r{  throw)r   r  r   ri   ri   rj   r    s   z _BaseRequestContextManager.throwc                 C   s
   | j  S r   )r{  r  r\  ri   ri   rj   r    r  z _BaseRequestContextManager.closec                 C   s   | j  }|S r   )r{  	__await__)r   retri   ri   rj   r    s   
z$_BaseRequestContextManager.__await__c                 C   s   |   S r   )r  r\  ri   ri   rj   __iter__  rd  z#_BaseRequestContextManager.__iter__c                    s   | j I d H | _| jS r   rz  r\  ri   ri   rj   rj    s   z%_BaseRequestContextManager.__aenter__)r  Nr   r~  rl  )rd   re   rf   	__slots__r	   rm   r   r  r   r  r  r   r  r  rj  ri   ri   ri   rj   ry    s    

ry  c                   @   :   e Zd ZdZdeee  dee dee ddfddZdS )	r   ri   re  r(  tbr   Nc                    s    | j   | j  I d H  d S r   )r|  r  Zwait_for_closer   re  r(  r  ri   ri   rj   rk    s   
z _RequestContextManager.__aexit__	rd   re   rf   r  r   r   r  r   rk  ri   ri   ri   rj   r         
r   c                   @   r  )	r1  ri   re  r(  r  r   Nc                    s   | j  I d H  d S r   )r|  r  r  ri   ri   rj   rk    s   z"_WSRequestContextManager.__aexit__r  ri   ri   ri   rj   r1    r  r1  c                   @   sh   e Zd ZdZdeddef deddfddZdefd	d
Zde	e
e  de	e de	e ddfddZdS )_SessionRequestContextManagerr{  r|  _sessionr}  r~  Nr   r   c                 C   s   || _ d | _|| _d S r   r  )r   r}  r   ri   ri   rj   r     s   
z&_SessionRequestContextManager.__init__c                    s:   z| j I d H | _W | jS  ty   | j I d H   w r   )r{  r|  r  r  r  r\  ri   ri   rj   rj    s   z(_SessionRequestContextManager.__aenter__re  r(  r  c                    s.   | j d usJ | j   | j I d H  d S r   )r|  r  r  r  ri   ri   rj   rk    s   
z'_SessionRequestContextManager.__aexit__)rd   re   rf   r  r	   r5   rX   r   rj  r   r   r  r   rk  ri   ri   ri   rj   r    s&    
		
r  r   Fr   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   c                C   s   d}|du rd}t |dd}t||||||d}t|j| |fi d|d|d|d	|d
|d|d|d|	d|
d|d|d|d|d|d|d|d|d||S )a  Constructs and sends a request.

    Returns response object.
    method - HTTP method
    url - request url
    params - (optional) Dictionary or bytes to be sent in the query
      string of the new request
    data - (optional) Dictionary, bytes, or file-like object to
      send in the body of the request
    json - (optional) Any json compatible python object
    headers - (optional) Dictionary of HTTP Headers to send with
      the request
    cookies - (optional) Dict object to send with the request
    auth - (optional) BasicAuth named tuple represent HTTP Basic Auth
    auth - aiohttp.helpers.BasicAuth
    allow_redirects - (optional) If set to False, do not follow
      redirects
    version - Request HTTP version.
    compress - Set to True if request has to be compressed
       with deflate encoding.
    chunked - Set to chunk size for chunked transfer encoding.
    expect100 - Expect 100-continue response from server.
    connector - BaseConnector sub-class instance to support
       connection pooling.
    read_until_eof - Read response until eof if response
       does not have Content-Length header.
    loop - Optional event loop.
    timeout - Optional ClientTimeout settings structure, 5min
       total timeout by default.
    Usage::
      >>> import aiohttp
      >>> resp = await aiohttp.request('GET', 'http://python.org/')
      >>> resp
      <ClientResponse(python.org/) [200]>
      >>> data = await resp.read()
    FNT)r   Zforce_close)r   r   r   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   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   ri   ri   rj   rZ     sn   @		
rZ   )rm  r  r>  rD  r   r@  r   r   r   
contextlibr   typesr   r   typingr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   Z	multidictr   r   r   r   Zyarlr   r   r   r   r   abcr    Zclient_exceptionsr!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   Zclient_reqrepr4   r5   r6   r7   r8   Z	client_wsr9   r   r:   r;   r<   r=   	cookiejarr>   helpersr?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   Zhttp_websocketrM   rN   rO   rP   streamsrQ   tracingrR   rS   ZtypedefsrT   rU   rV   rW   __all__r   r[   srY   rl   rh   rm   ru  rq  rt  rX   ry  r   r1  r  ro  r  rs  rr  rp  rZ   ri   ri   ri   rj   <module>   s    PT0(        p%
	

