o
    NEg                  1   @   s  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
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 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+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z> ddl?m@Z@mAZAmBZBmCZCmDZD ddlEmFZF ddlGmHZHmIZImJZJmKZK ddlLmMZM ddlNmOZOmPZPmQZQmRZRmSZSmTZTmUZUmVZVmWZW ddl'mXZXmYZYmZZZm[Z[ ddl\m]Z]m^Z^m_Z_m`Z` ddlambZb ddlcmdZdmeZe ddlfmgZgmhZhmiZimjZj dZkzddllmmZm W n eny"   eoZmY nw ejpddddG dd dZqeqddZredZsG dd dZtG d d! d!eeeesf ees ZuG d"d# d#eueA ZvG d$d% d%eueF ZwG d&d' d'Zxdddddddd(ddd)ddddeVde'jydddd*d+ezd,ejd-eeezezf  d.ed/ed0eei d1eeez  d2eeQ d3e{d4e|d5eez d6ee{ d7e{d8ee{ d9e{d:eej d;eeQ d<eeqeof d=eeh d>eYd?eeH d@ee| dAeej} dBexf0dCdDZ~dS )EzHTTP Client for asyncio.    N)SimpleNamespaceTracebackType)Any	AwaitableCallable	Coroutine	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)	DEBUGPY_36	BasicAuthCeilTimeoutTimeoutHandleget_running_loopproxies_from_env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,   r-   r.   r/   r0   r1   r2   r3   r4   r7   r9   r:   r8   r6   ClientSessionClientTimeoutrequest)
SSLContextT)auto_attribsfrozenslotsc                   @   sN   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S )rU   Ntotalconnect	sock_readsock_connect)
__name__
__module____qualname__r[   r   float__annotations__r\   r]   r^    rd   rd   h/var/www/eduai.edurigo.com/doc_train/edurigo_ai/Puru/venv/lib/python3.10/site-packages/aiohttp/client.pyrU      s
   
 rU   i,  r[   _RetTypec                7       s  e Zd ZdZeg dZdZd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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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df.dd Z$d!ed  ddfd"d#Z%e&rd$ed%e'ddf fd&d'Z(e)fd(e'ddfd)d*Z*d+ed,e+d-e'dd.fd/d0Z,ddddddddd1dddddddedddddddd2d+ed3e+d4ee-eef  d5e'd6e'd
ee dee deee  dee d7ed8e#d9ee d:ee d;edee d<ed=ee+ d>ee dee ef d?ee d@ee. dAee/ dBeee/ee0f  dCee dDee1 dee# de
f6dEdFZ2e3j4dGdHdddddddddddddddIdJdKd,e+d+edLee dedMee dNedOedPee dee dQee dee d=ee+ d>ee dBee/ede0f d?ee d@ee. dAee/ dCee d9e#dRe#ddSf*dTdUZ5e3j4dGdHdddddddddddddddIdJdKd,e+d+edLee dedMee dNedOedPee dee dQee dee d=ee+ d>ee dBee/ede0f d?ee d@ee. dAee/ dCee d9e#dRe#def*dVdWZ6dee ddXfdYdZZ7dd[d,e+d7ed-e'dd.fd\d]Z8dd[d,e+d7ed-e'dd.fd^d_Z9dd[d,e+d7ed-e'dd.fd`daZ:ddbd,e+d5e'd-e'dd.fdcddZ;ddbd,e+d5e'd-e'dd.fdedfZ<ddbd,e+d5e'd-e'dd.fdgdhZ=d,e+d-e'dd.fdidjZ>ddkdlZ?e@defdmdnZAe@dee fdodpZBe@defdqdrZCe@deDe#e#f fdsdtZEe@defdudvZFeFjGd%eddfdwdvZFe@dejfdxdyZHe@deee f fdzd{ZIe@dd|d}ZJe@deKeL fd~dZMe@dee fddZNe@defddZOe@defddZPe@deeeQe
geRd f f fddZSe@defddZTe@defddZUe@de!e" fddZVdddZWdddZXdeeeY  deeY deeZ ddfddZ[dddZ\deeeY  deeY deeZ ddfddZ]  Z^S )rT   z/First-class interface for making HTTP requests.)_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_bufsizeNTF   )	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_envrj   trace_configsread_bufsizer~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rj   r   r   returnc                C   s  |d u r|d ur|j }t|}|d u rt|d}|j |ur!td|| _ | r1ttd| _	|d u r:t
|d}|| _|d urG| j| || _|| _|| _|| _|| _|tu rt| _|turrtjdtdd tj| j|d| _|d urtj| j|d| _tjd	tdd n|| _|turtd
|d urtd|| _|| _|| _|| _|| _|rt |}nt  }|| _!|d urt"dd |D | _#nt" | _#|| _$|	| _%|
| _&|pg | _'| j'D ]}|(  qd S )Nr   z0Session and connector has to use same event loopr   z8read_timeout is deprecated, use timeout argument instead   
stacklevelrf   )r\   z8conn_timeout is deprecated, use timeout argument insteadzGread_timeout and timeout parameters conflict, please setup timeout.readzJconn_timeout and timeout parameters conflict, please setup timeout.connectc                 S   s   g | ]}t |qS rd   )r   ).0ird   rd   re   
<listcomp>%  s    z*ClientSession.__init__.<locals>.<listcomp>))rk   rA   r9   RuntimeError	get_debug	tracebackextract_stacksys	_getframerh   r;   rl   update_cookiesri   rm   rn   ro   rp   rC   DEFAULT_TIMEOUTrr   warningswarnDeprecationWarningattrevolve
ValueErrorrs   rt   ru   rq   r|   r   rv   	frozensetrw   rx   ry   rz   r{   freeze)selfr~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rj   r   r   real_headerstrace_configrd   rd   re   __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   formatr_   r   )r   rd   rd   re   __init_subclass__1  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__rd   re   r   ;  s   
zClientSession.__setattr__	_warningsc                 C   sd   | j s0tr
d| i}n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)client_sessionmessagesource_traceback)closedr=   r   ResourceWarningrh   rk   call_exception_handler)r   r   kwargscontextrd   rd   re   __del__E  s   




zClientSession.__del__methodurlr   _RequestContextManagerc                 K   s   t | j||fi |S )zPerform HTTP request.)r   _request)r   r   r   r   rd   rd   re   rV   S  s   zClientSession.request
   )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proxy_headerstrace_request_ctxr   
str_or_urlr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   c          4         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} |} |}zt|}W n ty^ } zt||d }~ww t j} |d urt|D ]	}!| t|! qj|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}#|# }$|d u r j} fdd jD }%|%D ]}&|&|||I d H  q|# }'z|'P 	 t|\}}(|	r|(rtd
|	d u r|(}	|	d u r j }	|d ur|	d urt!j"|v rtd j#$|})|d ur+t% }*|*&| |*$|}+|+r+|)'|+ |d ur5t|}n j(rRt) * D ]\},}-|,|j+krP|-j,}|-j-} nq> j.||fi d|d|d| d|d|)d|	d|d|d|d|d jd j/d|d|d|'d d|d|d|%}.z/t0|"j1 jd  j2d usJ  j2j1|.|%|"d I d H }/W d    n	1 sw   Y  W n t3j4y }0 zt5d!6||0d }0~0ww |/j7d usJ |/j8d usJ |/j8j9|'|: d"k| j;|"j<|d# z2z"|.=|/I d H }1z
|1|/I d H  W n t>y   |1?   w W n t>y-   |/?   w W n t@y8     tAyJ }0 ztB|0jC |0d }0~0ww  j#&|1jD|1jE |1jFd$v r"|
r"|%D ]}&|&G||||1I d H  q_|d%7 }|H|1 |r||kr|1?  tI|d jJtK||1jFd&kr|1jLt!jMks|1jFd'v r|1jLt!jNkrt!jO}d }|Pt!jQr|Rt!jQ |1jSPt!jTp|1jSPt!jU}2|2d u rnU|1V  z
t|2 jW d(}3W n ty } zt|2|d }~ww |3j+},|,d)vr|1?  td*|,s|X|3}3|Y |3Y krd }	|Rt!j"d  |3}d }|1V  q	 W d    n	1 s.w   Y  |d u r; jZ}|rB|1[  |$d urY|1j\d urU|1j\]|$j^ n|$^  tK||1__|%D ]}&|&`||||1I d H  q`|1W S  t>y } z|#?  |$r|$^  d }$|%D ]}&|&a||||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   rf   c                    s    g | ]}t  ||jd qS ))r   )rN   trace_config_ctx)r   r   r   r   rd   re   r     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   tracesr   )r   r   zConnection timeout to host {}HEAD)r   skip_payloadr   r   r   r   )-  .  /  i3  i4  r   r   )r   r   )encoded)r   https z"Can redirect only to http or https)br   r   r5   r   r   JsonPayloadrp   
isinstanceboolr   r   r   ro   _prepare_headersr   r*   setrw   addr   rC   rr   rU   r@   rk   r[   startr|   r{   send_request_startr   rD   rn   r   AUTHORIZATIONrl   filter_cookiesr;   r   loadru   rB   itemsschemer   r   rx   ry   r?   r\   ri   asyncioTimeoutErrorr.   r   	transportprotocolset_response_paramsupperrt   r]   sendBaseExceptioncloser"   OSErrorr$   argsr   r   statussend_request_redirectappendr/   request_infotupler   	METH_HEAD	METH_POSTMETH_GETgetCONTENT_LENGTHpopr   LOCATIONURIreleaserq   joinoriginrs   r   
connectionadd_callbackcancel_historysend_request_endsend_request_exception)4r   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   	redirectshistoryr   r   eskip_headersr   real_timeouttmhandler   tracer   auth_from_urlall_cookiestmp_cookie_jarreq_cookiesr   
proxy_inforeqconnexcrespr_url
parsed_urlrd   r   re   r   Y  s  #





	







	

	





  
/

zClientSession._requestrd   g      $@r   i  @ )r   	protocolsr   receive_timeout	autocloseautoping	heartbeatr   r  r   r   r   r   r   r   r   r   r   max_msg_sizer*  r+  r,  r-  r.  r  r/  _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|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  _ws_connect)r   r   r   r*  r   r+  r,  r-  r.  r   r  r   r   r   r   r   r   r   r   r   r/  rd   rd   re   
ws_connect  sV   	
zClientSession.ws_connectc          )         s$  |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< 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 }|rtj|jv rdd |jtj  dD }|D ]
} | |v r| } nqd}!|r9|jtj}"|"r5zt!|"\}}!W n" t"y4 }# zt|j|j|#j#d |j|jd|#d }#~#ww d}d}!|j$}$|$d usCJ |$j%}%|%d usMJ |$j&}&|&d usWJ t'|%d| j(d}'|%)t*|'||' t+|%|&d||!d}(W n t,y   |-   w | j.|'|(|||||| j(||||!dS )N	websocketupgrade13   ,)r   F)r   r   r   r   r   r   r   e   zInvalid response status)r   r  r   r   zInvalid upgrade headerzInvalid connection headerzInvalid challenge responsec                 S   s   g | ]}|  qS rd   )strip)r   protord   rd   re   r   *  s    z-ClientSession._ws_connect.<locals>.<listcomp>r   r}   r   T)use_maskr   
notakeover)r+  r.  r   client_notakeover)/r   r   UPGRADE
CONNECTIONSEC_WEBSOCKET_VERSIONr   
setdefaultbase64	b64encodeosurandomdecodeSEC_WEBSOCKET_KEYr  SEC_WEBSOCKET_PROTOCOLORIGINrK   SEC_WEBSOCKET_EXTENSIONSr5   rV   r  r0   r  r  r   r	  lowerSEC_WEBSOCKET_ACCEPThashlibsha1rE   digestsplitrL   rI   r   r  r   r   rM   rk   
set_parserrG   rH   r   r   rz   ))r   r   r   r*  r   r+  r,  r-  r.  r   r  r   r   r   r   r   r   r   r   r   r/  r   default_headerskeyvaluesec_keyextstrr'  r_keymatchr   resp_protocolsr:  r<  compress_hdrsr&  r%  
conn_protor   readerwriterrd   rd   re   r1    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   rv   r   r   r   r   r   r   )r   r   resultadded_namesrS  rT  rd   rd   re   r   k  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   rd   rd   re   r	  {     zClientSession.getc                K   ra  )zPerform HTTP OPTIONS request.r   )r   r   r   METH_OPTIONSrb  rd   rd   re   options     zClientSession.optionsc                K   ra  )zPerform HTTP HEAD request.r   )r   r   r   r  rb  rd   rd   re   head  rf  zClientSession.head)r   c                K   ra  )zPerform HTTP POST request.r   )r   r   r   r  r   r   r   r   rd   rd   re   post  rc  zClientSession.postc                K   ra  )zPerform HTTP PUT request.r   )r   r   r   METH_PUTrh  rd   rd   re   put  rc  zClientSession.putc                K   ra  )zPerform HTTP PATCH request.r   )r   r   r   
METH_PATCHrh  rd   rd   re   patch  rc  zClientSession.patchc                 K   s   t | jtj|fi |S )zPerform HTTP DELETE request.)r   r   r   METH_DELETE)r   r   r   rd   rd   re   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   ri   rm   r   r   rd   rd   re   r     s   
zClientSession.closec                 C   s   | j du p| j jS )z@Is client session closed.

        A readonly property.
        N)ri   r   rp  rd   rd   re   r     s   zClientSession.closedc                 C      | j S )z(Connector instance used for the session.ri   rp  rd   rd   re   r~        zClientSession.connectorc                 C   rq  )zThe session cookies.)rl   rp  rd   rd   re   r     rs  zClientSession.cookie_jarc                 C   rq  )z"The session HTTP protocol version.)ro   rp  rd   rd   re   r     rs  zClientSession.versionc                 C   rq  ))Do URL requoting on redirection handling.)rq   rp  rd   rd   re   rj     rs  z"ClientSession.requote_redirect_urlc                 C   s   t jdtdd || _dS )rt  z=session.requote_redirect_url modification is deprecated #2778r   r   N)r   r   r   rq   )r   r   rd   rd   re   rj     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   rk   rp  rd   rd   re   r     s   zClientSession.loopc                 C   rq  )zTimeout for the session.)rr   rp  rd   rd   re   r     rs  zClientSession.timeoutc                 C   rq  )z*The default headers of the client session.)rv   rp  rd   rd   re   r     rs  zClientSession.headersc                 C   rq  )z2Headers for which autogeneration should be skipped)rw   rp  rd   rd   re   r     rs  zClientSession.skip_auto_headersc                 C   rq  )z2An object that represents HTTP Basic Authorization)rn   rp  rd   rd   re   r     rs  zClientSession.authc                 C   rq  )zJson serializer callable)rp   rp  rd   rd   re   r     rs  zClientSession.json_serializec                 C   rq  )z-Should connector be closed on session closing)rm   rp  rd   rd   re   r     rs  zClientSession.connector_ownerc                 C   rq  )z`
        Should `ClientResponse.raise_for_status()`
        be called for each response
        )rs   rp  rd   rd   re   r   	  s   zClientSession.raise_for_statusc                 C   rq  )z6Should the body response be automatically decompressed)rt   rp  rd   rd   re   r     rs  zClientSession.auto_decompressc                 C   rq  )z
        Should get proxies information
        from HTTP_PROXY / HTTPS_PROXY environment variables
        or ~/.netrc file if present
        )ru   rp  rd   rd   re   r     s   zClientSession.trust_envc                 C   rq  )z7A list of TraceConfig instances used for client tracing)r{   rp  rd   rd   re   r   !  rs  zClientSession.trace_configsc                 C   s
   d| _ dS )zwDetach connector from session without closing the former.

        Session is switched to closed state anyway.
        Nrr  rp  rd   rd   re   detach&  s   
zClientSession.detachc                 C   s   t d)NzUse async with instead)	TypeErrorrp  rd   rd   re   	__enter__-     zClientSession.__enter__exc_typeexc_valexc_tbc                 C   s   d S Nrd   r   ry  rz  r{  rd   rd   re   __exit__0  s   zClientSession.__exit__c                    s   | S r|  rd   rp  rd   rd   re   
__aenter__9  s   zClientSession.__aenter__c                    s   |   I d H  d S r|  )r   r}  rd   rd   re   	__aexit__<  s   zClientSession.__aexit__r   N)r   r^  )r   rT   )_r_   r`   ra   __doc__r   r   rh   r   r   r1   r2   r6   r   HttpVersion11rC   r   r7   r   AbstractEventLooprQ   rR   r   strr>   rP   r   rF   r   r   r   rb   objectrU   r   rO   intr   r   r<   r   r   r   r   rS   rV   r   bytesrW   r3   r   r   r   r  r2  r1  r   r	  re  rg  ri  rk  rm  ro  r   propertyr   r~   r   r   r   rj   setterr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   ru  rw  r   r   r~  r  r  __classcell__rd   rd   r   re   rT      s<   
	




o

	



  8	

6	

 /
	


	
	


		




	
rT   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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  rd   rd   re   r   I     
z#_BaseRequestContextManager.__init__argc                 C   s   | j |S r|  )r  r   r   r  rd   rd   re   r   L  s   z_BaseRequestContextManager.sendc                 C   s   | j | d S r|  )r  throwr  rd   rd   re   r  O  s   z _BaseRequestContextManager.throwc                 C   s
   | j  S r|  )r  r   rp  rd   rd   re   r   R  r  z _BaseRequestContextManager.closec                 C   s   | j  }|S r|  )r  	__await__)r   retrd   rd   re   r  U  s   
z$_BaseRequestContextManager.__await__c                 C   s   |   S r|  )r  rp  rd   rd   re   __iter__Y  rx  z#_BaseRequestContextManager.__iter__c                    s   | j I d H | _| jS r|  r  rp  rd   rd   re   r  \  s   z%_BaseRequestContextManager.__aenter__)r  Nr   r  r  )r_   r`   ra   	__slots__r   rg   r   r   r   r  r   r	   r   r  r  r  rd   rd   rd   re   r  E  s    

r  c                   @   6   e Zd Zdeee  dee dee ddfddZdS )r   ry  r&  tbr   Nc                    s   | j   d S r|  )r  r  r   ry  r&  r  rd   rd   re   r  b  s   z _RequestContextManager.__aexit__r_   r`   ra   r   r   r   r   r  rd   rd   rd   re   r   a      
r   c                   @   r  )r0  ry  r&  r  r   Nc                    s   | j  I d H  d S r|  )r  r   r  rd   rd   re   r  q  s   z"_WSRequestContextManager.__aexit__r  rd   rd   rd   re   r0  p  r  r0  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   rd   rd   re   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   rp  rd   rd   re   r    s   z(_SessionRequestContextManager.__aenter__ry  r&  r  c                    s.   | j d usJ | j   | j I d H  d S r|  )r  r   r  r  rd   rd   re   r    s   
z'_SessionRequestContextManager.__aexit__)r_   r`   ra   r  r   r2   rT   r   r  r   r   r   r   r  rd   rd   rd   re   r  z  s&    
		
r  r   F)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||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   force_close)r   r   r   r   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r9   rT   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   rd   rd   re   rV     sf   <		
rV   )r  r   rB  rM  r   rD  r   r   r   typesr   r   typingr   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   	multidictr   r   r   r   yarlr   r   r   r   r   abcr   client_exceptionsr   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   client_reqrepr1   r2   r3   r4   r5   	client_wsr6   r~   r7   r8   r9   r:   	cookiejarr;   helpersr<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   http_websocketrI   rJ   rK   rL   streamsrM   tracingrN   rO   typedefsrP   rQ   rR   rS   __all__r   rW   ImportErrorr  srU   r   rg   rT   r  r   r0  r  r  r  r   r  r  rV   rd   rd   rd   re   <module>   s    HT,(
        )
%
	

