a
    nJh                     @   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rJd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-eyeoeeeyeyf  eeeen eeey  eeU eeeey ee eee eeeo eeU e etef eem e^eeL ee eej eeed.d/d0ZdS )1z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)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`   ra   rb   rd    rj   rj   @/var/www/shaz/venv/lib/python3.9/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< dwd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ee ee eej ee ee eee  ee eee ee ee eee  e!e"e!e#ege$d f f e"e%e&f ee% e"e'e(f e!e!e!ee)e*  e+e+e+e,ddddZ-ed  ddddZ.e/rRee0dd fddZ1e2fe0ddddZ3eee0ddddZ4ee5d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!eeee7eef  e0e0ee ee eee  ee e!e+ee ee! e!e"de!e#ege$d f f e!ee ee e"e(e&f ee! ee8 ee9 e"e9e!e:f ee ee ee; ee+ ee! ee+ ee+ ed"d#d$Z<e=j>d%d&dddddddddddddddd'd(d)eeee e%ee% e!e!ee% ee ee ee7eef  ee ee ee e"e9e!de:f ee! ee8 ee9 ee e+e+d*d+d,d-Z?e=j>d%d&dddddddddddddddd'd(d)eeee e%ee% e!e!ee% ee ee ee7eef  ee ee ee ee"e9e!e:f  ee! ee8 ee9 ee e+e+ed+d.d/Z@ee d0d1d2d3ZAdd4ee!e0dd5d6d7ZBdd4ee!e0dd5d8d9ZCdd4ee!e0dd5d:d;ZDdd<ee0e0dd=d>d?ZEdd<ee0e0dd=d@dAZFdd<ee0e0dd=dBdCZGee0ddDdEdFZHddGdHdIZIeJe!dGdJdKZKeJee dGdLdMZLeJe dGdNdOZMeJeNe+e+f dGdPdQZOeJe!dGdRdSZPePjQe!ddTdUdSZPeJejdGdVdWZReJe(dGdXdYZSeJd0dGdZd[ZTeJeUeV dGd\d]ZWeJee dGd^d_ZXeJedGd`daZYeJe!dGdbdcZZeJe"e!e#ege$d f f dGdddeZ[eJe!dGdfdgZ\eJe!dGdhdiZ]eJe)e* dGdjdkZ^ddGdldmZ_ddGdndoZ`eeea  eea eeb ddpdqdrZcd dGdsdtZdeeea  eea eeb ddpdudvZe  ZfS )xrX   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_charsetNrp   rq   TF     c                 C   s   dS )Nzutf-8rj   )rbrj   rj   rk   <lambda>       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_envrr   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   rr   r   r   r   r   r   returnc                C   sV  d | _ |tu s|d u rrt| _|turFtjdtdd tj| j|d| _|d urtj| j|d| _tjdtdd nDt	|t
stdt| d|| _|turtd	|d urtd
|d u r|d ur|j}t|}|d u st	|tr|| _n$t|| _| j | jksJ d|d u r&t|d}|j|ur:td|| _| r\ttd| _|d u rpt|d}|| _|d ur| j| || _ || _|| _|| _|| _ || _!|| _"|| _#|| _$|| _%|| _&|| _'|rt(|}nt( }|| _)|d urt*dd |D | _+nt* | _+|	| _,|
| _-|| _.|p2g | _/| j/D ]}|0  q<|| _1d S )Nz8read_timeout is deprecated, use timeout argument instead   
stacklevelrl   )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.connectz2Only absolute URLs without path part are supportedr   z0Session and connector has to use same event loopr   c                 s   s   | ]}t |V  qd S N)r   ).0irj   rj   rk   	<genexpr>G  r   z)ClientSession.__init__.<locals>.<genexpr>)2rq   rG   rm   rz   warningswarnDeprecationWarningattrevolve
isinstancerY   
ValueErrortypers   rE   r   ro   originr<   RuntimeErrorZ	get_debug	tracebackextract_stacksys	_getframerp   r>   rt   update_cookiesru   rv   rw   rx   r{   r|   r}   ry   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   rr   r   r   r   r   r   real_headerstrace_configrj   rj   rk   __init__   s    "










zClientSession.__init__)clsr   c                 C   s   t jd| jtdd d S )Nz6Inheritance class {} from ClientSession is discouragedr   r   )r   r   formatre   r   )r   rj   rj   rk   __init_subclass__U  s    zClientSession.__init_subclass__)namevalr   c                    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__rj   rk   r   _  s    
zClientSession.__setattr__)	_warningsr   c                 C   sV   | j sRd| i}|jd| tfi | | dd}| jd urF| j|d< | j| d S )NsourcezUnclosed client session zUnclosed client session)Zclient_sessionmessageZsource_traceback)closedr   ResourceWarningrp   rs   Zcall_exception_handler)r   r   kwargscontextrj   rj   rk   __del__i  s    



zClientSession.__del___RequestContextManager)methodurlr   r   c                 K   s   t | j||fi |S )zPerform HTTP request.)r   _request)r   r   r   r   rj   rj   rk   rZ   t  s    zClientSession.request)
str_or_urlr   c                 C   s>   t |}| jd u r|S | s*|jds.J | j|S d S )N/)r   ro   is_absolutepath
startswithjoin)r   r   r   rj   rj   rk   
_build_urlz  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   r   r   r   r   r   r   r   r   r   r   r   r   r   c          7         s2   j rtdt||||}|d ur6|d ur6tdn|d urNtj| jd}t|tsl|d urlt	
dt d}g }  j}!|pi } |} |}z |}"W n. ty }# zt||#W Y d }#~#n
d }#~#0 0 t j}$|d ur|D ]}%|$t|% q|d urFzt|}W n0 tyD }# zt||#W Y d }#~#n
d }#~#0 0 |tu rX j}&nt|tspt|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 rN|,}	|	d u r^ j&}	|d ur|	d urt'j(|v rtd j)*|"}-|d urt+ }.|.,| |.*|"}/|/r|--|/ |d urt|}n> j.rt/t0 t1|"\}}W d    n1 s0    Y   j2||"|||$||-|	|!||| j j3|||+ |d urR|nd|||) j4d}0ztt5|&j6|&jd4 I d H @  j7d usJ  j7j6|0|)|&dI d H }1W d   I d H  q1 I d H s0    Y  W n8 t8j9y }2 zt:d;|"|2W Y d }2~2n
d }2~20 0 |1j<d us"J |1j=d us2J |1j=j>|+t?||||&j@| j7jA||d	 zlzH|0B|1I d H }3z|3|1I d H  W n tCy   |3D   Y n0 W n tCy   |1D   Y n0 W nb tEy    Y nN tFy( }2 z4|2jGd u rt|2t8j9r tH|2jI |2W Y d }2~2n
d }2~20 0  j),|3jJ|3jK |3jLdv r|
r|)D ]"}*|*M||"#|||3I d H  qR|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:qn|3\  zt|4 j] d}5W n0 ty }# zt|4|#W Y d }#~#n
d }#~#0 0 |5j^}6|6dvr|3D  tdn|6s|"_|5}5|"` |5` krd }	|Xt'j(d  |5}"i }|3\  q qq W d    n1 s0    Y  |d u r* ja}|d u r6n(tb|rP||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, }# zP|'D  |(r|(f  d }(|)D ]"}*|*i||"#|||#I d H  q W Y d }#~#n
d }#~#0 0 d S )NzSession is closedz9data and json parameters can not be used at the same time)dumpszChunk size is deprecated #1615r   rl   )rd   c                    s    g | ]}t  ||jd qS ))r   )rR   Ztrace_config_ctx)r   r   r   r   rj   rk   
<listcomp>  s   
z*ClientSession._request.<locals>.<listcomp>z<Cannot combine AUTH argument with credentials encoded in URLzTCannot combine AUTHORIZATION header with AUTH argument or credentials encoded in URLT)r   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JsonPayloadrx   r   boolr   r   r   rw   _prepare_headersr   r-   setr   addr   r   rG   rz   rY   rB   rs   r_   rd   startr   r|   r   r   r   Zsend_request_startZupdate_queryr   rH   rv   r   ZAUTHORIZATIONrt   Zfilter_cookiesr>   r   loadr}   r   LookupErrorrD   r   r   r   rC   r`   rq   asyncioTimeoutErrorr1   r   	transportprotocolZset_response_paramsrF   ra   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releasery   schemer   r   r{   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  rj   r   rk   r     s   )

 

 




	








,>"



 


(




zClientSession._requestrj   g      $@r   i  @ r   	protocolsr   receive_timeout	autocloseautoping	heartbeatr   r   r   r   r   r   r   r   r   r   r   r   max_msg_size_WSRequestContextManager)r   r   r,  r   r-  r.  r/  r0  r   r   r   r   r   r   r   r   r   r   r   r   r1  r   c                C   s8   t | j|||||||||	|
|||||||||||dS )zInitiate websocket connection.r+  )r2  _ws_connect)r   r   r   r,  r   r-  r.  r/  r0  r   r   r   r   r   r   r   r   r   r   r   r   r1  rj   rj   rk   
ws_connect  s2    zClientSession.ws_connectc          *         sX  |d u rt  }nt |}tjdtjdtjdi}| D ]\}}||| q6tt	
d}| |tj< |r~d||tj< |
d ur|
|tj< |rt|d}||tj< |d u rd}t||||}| j||||d|	||||d	
I d H }z(|jd
krt|j|jd|j|jd|jtjd dkrDt|j|jd|j|jd|jtjd dkrxt|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 |!} qq d}"|r|jtj}#|#rzt!|#\}}"W nH t"y }$ z.t|j|j|$j#d |j|jd|$W Y d }$~$n
d }$~$0 0 nd}d}"|j$}%|%d usJ |%j%}&|&d usJ |%j&}'|'d usJ t'|&d| j(d}(|&)t*|(||( t+|&|'d||"d})W n t,y.   |-   Y n&0 | j.|(|)|||||| j(||||"dS 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 rj   )strip)r   protorj   rj   rk   r   |  s   z-ClientSession._ws_connect.<locals>.<listcomp>r   r   r   )Zuse_maskr   
notakeover)r-  r0  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   rs   
set_parserrK   rL   r  r  r   )*r   r   r   r,  r   r-  r.  r/  r0  r   r   r   r   r   r   r   r   r   r   r   r   r1  r   default_headerskeyvalueZsec_keyZextstrr)  Zr_keymatchr  Zresp_protocolsr:  r;  Zcompress_hdrsr(  r'  Z
conn_protor
  readerwriterrj   rj   rk   r3  
  s   


	
	


zClientSession._ws_connectzCIMultiDict[str])r   r   c                 C   sh   t | j}|rdt|ttfs$t |}t }| D ]0\}}||v rP||| q2|||< || q2|S )z3Add default headers and transform it to CIMultiDict)r   r~   r   r   r   r  r=  r  )r   r   resultZadded_namesrK  rL  rj   rj   rk   r    s    
zClientSession._prepare_headers)r   )r   r   r   r   c                K   s   t | jtj|fd|i|S )zPerform HTTP GET request.r   )r   r   r   r  r   r   r   r   rj   rj   rk   r    s    zClientSession.getc                K   s   t | jtj|fd|i|S )zPerform HTTP OPTIONS request.r   )r   r   r   ZMETH_OPTIONSrQ  rj   rj   rk   options  s    zClientSession.optionsc                K   s   t | jtj|fd|i|S )zPerform HTTP HEAD request.r   )r   r   r   r  rQ  rj   rj   rk   head  s    zClientSession.head)r   )r   r   r   r   c                K   s   t | jtj|fd|i|S )zPerform HTTP POST request.r   )r   r   r   r  r   r   r   r   rj   rj   rk   post  s    zClientSession.postc                K   s   t | jtj|fd|i|S )zPerform HTTP PUT request.r   )r   r   r   ZMETH_PUTrT  rj   rj   rk   put  s    zClientSession.putc                K   s   t | jtj|fd|i|S )zPerform HTTP PATCH request.r   )r   r   r   Z
METH_PATCHrT  rj   rj   rk   patch  s    zClientSession.patch)r   r   r   c                 K   s   t | jtj|fi |S )zPerform HTTP DELETE request.)r   r   r   ZMETH_DELETE)r   r   r   rj   rj   rk   delete  s    zClientSession.deleter   c                    s0   | j s,| jdur&| jr&| j I dH  d| _dS )zMClose underlying connector.

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

        A readonly property.
        N)rq   r   rZ  rj   rj   rk   r     s    zClientSession.closedc                 C   s   | j S )z(Connector instance used for the session.rq   rZ  rj   rj   rk   r     s    zClientSession.connectorc                 C   s   | j S )zThe session cookies.)rt   rZ  rj   rj   rk   r     s    zClientSession.cookie_jarc                 C   s   | j S )z"The session HTTP protocol version.)rw   rZ  rj   rj   rk   r   !  s    zClientSession.versionc                 C   s   | j S ))Do URL requoting on redirection handling.)ry   rZ  rj   rj   rk   rr   &  s    z"ClientSession.requote_redirect_url)r   r   c                 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   ry   )r   r   rj   rj   rk   rr   +  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   rs   rZ  rj   rj   rk   r   5  s    zClientSession.loopc                 C   s   | j S )zTimeout for the session.)rz   rZ  rj   rj   rk   r   =  s    zClientSession.timeoutc                 C   s   | j S )z*The default headers of the client session.)r~   rZ  rj   rj   rk   r   B  s    zClientSession.headersc                 C   s   | j S )z2Headers for which autogeneration should be skipped)r   rZ  rj   rj   rk   r   G  s    zClientSession.skip_auto_headersc                 C   s   | j S )z2An object that represents HTTP Basic Authorization)rv   rZ  rj   rj   rk   r   L  s    zClientSession.authc                 C   s   | j S )zJson serializer callable)rx   rZ  rj   rj   rk   r   Q  s    zClientSession.json_serializec                 C   s   | j S )z-Should connector be closed on session closing)ru   rZ  rj   rj   rk   r   V  s    zClientSession.connector_ownerc                 C   s   | j S )zGShould `ClientResponse.raise_for_status()` be called for each response.)r{   rZ  rj   rj   rk   r   [  s    zClientSession.raise_for_statusc                 C   s   | j S )z7Should the body response be automatically decompressed.)r|   rZ  rj   rj   rk   r   b  s    zClientSession.auto_decompressc                 C   s   | j S )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}   rZ  rj   rj   rk   r   g  s    zClientSession.trust_envc                 C   s   | j S )z7A list of TraceConfig instances used for client tracing)r   rZ  rj   rj   rk   r   q  s    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[  rZ  rj   rj   rk   detachv  s    zClientSession.detachc                 C   s   t dd S )NzUse async with instead)	TypeErrorrZ  rj   rj   rk   	__enter__}  s    zClientSession.__enter__)exc_typeexc_valexc_tbr   c                 C   s   d S r   rj   r   r`  ra  rb  rj   rj   rk   __exit__  s    zClientSession.__exit__c                    s   | S r   rj   rZ  rj   rj   rk   
__aenter__  s    zClientSession.__aenter__c                    s   |   I d H  d S r   )r  rc  rj   rj   rk   	__aexit__  s    zClientSession.__aexit__)N)gre   rf   rg   __doc__r   r   rp   r   r   StackSummaryri   rq   r:   r   r   r4   r5   r9   r   HttpVersion11rG   rW   r  AbstractEventLooprU   rV   r   strrA   rT   r   rJ   r    r  r   r   r   rh   r?   objectrY   r   rS   int_CharsetResolverr   r   r@   r   r   r   r   rZ   r   r   r   bytesr[   r6   r   r   r   r  r4  r3  r  r  rR  rS  rU  rV  rW  rX  r  propertyr   r   r   r   r   rr   setterr   r   r   r   r   r   r   r   r   r   r   r   r   r]  r_  r  r   rd  re  rf  __classcell__rj   rj   r   rk   rX      sh  
 



 	


  Z8 4			
		
	
rX   c                   @   s   e Zd ZdZeddef ddddZddddd	Zeedd
ddZ	ddddZ
eedef dddZeedef dddZedddZdS )_BaseRequestContextManager_coro_respasyncio.Future[Any]N)coror   c                 C   s
   || _ d S r   )ru  )r   rx  rj   rj   rk   r     s    z#_BaseRequestContextManager.__init__)argr   c                 C   s   | j |S r   )ru  r  )r   ry  rj   rj   rk   r    s    z_BaseRequestContextManager.send)r  r   r   c                 O   s   | j j|i |S r   )ru  throw)r   r  r   rj   rj   rk   rz    s    z _BaseRequestContextManager.throwrY  c                 C   s
   | j  S r   )ru  r  rZ  rj   rj   rk   r    s    z _BaseRequestContextManager.closec                 C   s   | j  }|S r   )ru  	__await__)r   retrj   rj   rk   r{    s    
z$_BaseRequestContextManager.__await__c                 C   s   |   S r   )r{  rZ  rj   rj   rk   __iter__  s    z#_BaseRequestContextManager.__iter__c                    s   | j I d H | _| jS r   rt  rZ  rj   rj   rk   re    s    z%_BaseRequestContextManager.__aenter__)re   rf   rg   	__slots__r	   rn   r   r  r   rz  r  r   r{  r}  re  rj   rj   rj   rk   rs    s   rs  c                   @   s4   e Zd ZdZeee  ee ee ddddZdS )r   rj   Nr`  r(  tbr   c                    s   | j   | j  I d H  d S r   )rv  r  Zwait_for_closer   r`  r(  r  rj   rj   rk   rf    s    
z _RequestContextManager.__aexit__	re   rf   rg   r~  r   r   r  r   rf  rj   rj   rj   rk   r     s   
r   c                   @   s4   e Zd ZdZeee  ee ee ddddZdS )r2  rj   Nr  c                    s   | j  I d H  d S r   )rv  r  r  rj   rj   rk   rf    s    z"_WSRequestContextManager.__aexit__r  rj   rj   rj   rk   r2    s   
r2  c                   @   s^   e Zd ZdZeddef eddddZeddd	Ze	e
e  e	e e	e dd
ddZdS )_SessionRequestContextManagerru  rv  _sessionrw  N)rx  r   r   c                 C   s   || _ d | _|| _d S r   r  )r   rx  r   rj   rj   rk   r     s    z&_SessionRequestContextManager.__init__rY  c                    sB   z| j I d H | _W n$ ty6   | j I d H   Y n0 | jS d S r   )ru  rv  r  r  r  rZ  rj   rj   rk   re    s    z(_SessionRequestContextManager.__aenter__r  c                    s,   | j d usJ | j   | j I d H  d S r   )rv  r  r  r  rj   rj   rk   rf    s    
z'_SessionRequestContextManager.__aexit__)re   rf   rg   r~  r	   r5   rX   r   re  r   r   r  r   rf  rj   rj   rj   rk   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   sh   d}|du rd}t |dd}t||||||d}t|j| |||||||||	|
|||||||||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   rj   rj   rk   rZ     sJ    @	rZ   )rg  r  r?  rE  r   rA  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>   Z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   rm   ri   rn   ro  rk  rn  rX   rs  r   r2  r  ri  r  rm  rl  rj  rZ   rj   rj   rj   rk   <module>   s   PT0(       s %

