
­­­­­­­­­­­­­­­­­­
<!DOCTYPE html>
<html>
U
    '7`                     @   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 enk
rF   eoZmY nX 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*ezejeeezezf  eeeei eeez  eeQ e{e|eez ee{ e{ee{ e{eej eeQ eeqeof eeh eYeeH ee| eej} exd+d,d-Z~dS ).z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)Z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__rZ   r   float__annotations__r[   r\   r]    rc   rc   A/opt/alt/python38/lib64/python3.8/site-packages/aiohttp/client.pyrU      s   
rU   i,  rZ   _RetTypec                       s  e Zd ZdZedddddddd	d
ddddddddddddg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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f ee eee f eeeee!e"  e#ddddZ$ed  ddd d!Z%e&r*ee'dd" fd#d$Z(e)fe'dd%d&d'Z*ee+e'd(d)d*d+Z,ddddddddd,dddddddedddddddd-ee+ee-eef  e'e'ee ee eee  ee ee#ee ee eee eee+ ee ee ef ee ee. ee/ eee/ee0f  ee ee1 ee# e
d.d/d0Z2e3j4d1d2ddddddddddddddd3d4d5e+eee eee eeee ee ee ee ee+ ee ee/ede0f ee ee. ee/ ee e#e#d6d7d8d9Z5e3j4d1d2ddddddddddddddd3d4d5e+eee eee eeee ee ee ee ee+ ee ee/ede0f ee ee. ee/ ee e#e#ed7d:d;Z6ee d<d=d>d?Z7dd@e+ee'd(dAdBdCZ8dd@e+ee'd(dAdDdEZ9dd@e+ee'd(dAdFdGZ:ddHe+e'e'd(dIdJdKZ;ddHe+e'e'd(dIdLdMZ<ddHe+e'e'd(dIdNdOZ=e+e'd(dPdQdRZ>ddSdTdUZ?e@edSdVdWZAe@ee dSdXdYZBe@edSdZd[ZCe@eDe#e#f dSd\d]ZEe@edSd^d_ZFeFjGedd`dad_ZFe@ejdSdbdcZHe@eee f dSdddeZIe@d<dSdfdgZJe@eKeL dSdhdiZMe@ee dSdjdkZNe@edSdldmZOe@edSdndoZPe@eeeQe
geRd f f dSdpdqZSe@edSdrdsZTe@edSdtduZUe@e!e" dSdvdwZVddSdxdyZWddSdzd{ZXeeeY  eeY eeZ dd|d}d~Z[d dSddZ\eeeY  eeY eeZ dd|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_envri   trace_configsread_bufsize)r}   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   ri   r   r   returnc                C   s  |d kr|d k	r|j }t|}|d kr0t|d}|j |k	rBtd|| _ | rbttd| _	|d krtt
|d}|| _|d k	r| j| || _|| _|| _|| _|| _|tkrt| _|tk	rtjdtdd tj| j|d| _|d k	r>tj| j|d| _tjd	tdd n*|| _|tk	r,td
|d k	r>td|| _|| _|| _|| _|| _|rlt |}nt  }|| _!|d k	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   
stacklevelre   )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 rc   )r   ).0irc   rc   rd   
<listcomp>%  s     z*ClientSession.__init__.<locals>.<listcomp>))rj   rA   r9   RuntimeErrorZ	get_debug	tracebackextract_stacksys	_getframerg   r;   rk   update_cookiesrh   rl   rm   rn   ro   rC   DEFAULT_TIMEOUTrq   warningswarnDeprecationWarningattrZevolve
ValueErrorrr   rs   rt   rp   r{   r   ru   	frozensetrv   rw   rx   ry   rz   Zfreeze)selfr}   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   ri   r   r   real_headerstrace_configrc   rc   rd   __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   formatr^   r   )r   rc   rc   rd   __init_subclass__1  s    zClientSession.__init_subclass__)namevalr   c                    s2   || j k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__rc   rd   r   ;  s    
zClientSession.__setattr__)	_warningsr   c                 C   s\   | j sXtrd| i}ni }|jd| tf| | dd}| jd k	rL| j|d< | j| d S )NsourcezUnclosed client session zUnclosed client session)Zclient_sessionmessageZsource_traceback)closedr=   r   ResourceWarningrg   rj   Zcall_exception_handler)r   r   kwargscontextrc   rc   rd   __del__E  s    
 


zClientSession.__del___RequestContextManager)methodurlr   r   c                 K   s   t | j||f|S )zPerform HTTP request.)r   _request)r   r   r   r   rc   rc   rd   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   )r   
str_or_urlr   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          4         s6   j rtdt||||}|d k	r6|d k	r6tdn|d k	rNtj| jd}t|tsl|d k	rlt	
dt d}g } j} |} |}zt|}W n, tk
r } zt||W 5 d }~X Y nX t j} |d k	r|D ]}!| t|! q|d k	r8zt|}W n. tk
r6 } zt||W 5 d }~X Y nX |tkrJ j}"nt|tsbt|d}"n|}"t j|"j}#|# }$|d kr j} fdd jD }%|%D ]}&|&|||I d H  q|# }'z|'x t|\}}(|	r|(rtd	|	d kr|(}	|	d kr j }	|d k	r<|	d k	r<t!j"|kr<td
 j#$|})|d k	r|t% }*|*&| |*$|}+|+r||)'|+ |d k	rt|}n< j(rt) * D ](\},}-|,|j+kr|-j,}|-j-} q̐q j.||||| ||)|	|||| j j/|||' |||%d}.zHt0|"j1 jd.  j2d k	s(t3 j2j1|.|%|"dI d H }/W 5 Q R X W n6 t4j5k
r }0 zt6d7||0W 5 d }0~0X Y nX |/j8d k	st3|/j9d k	st3|/j9j:|'|; dk| j<|"j=|d zpzJ|.>|/I d H }1z|1|/I d H  W n  t?k
r   |1@   Y nX W n  t?k
r4   |/@   Y nX W nF tAk
rP    Y n0 tBk
r~ }0 ztC|0jD |0W 5 d }0~0X Y nX  j#&|1jE|1jF |1jGdkrH|
rH|%D ]}&|&H||||1I d H  q|d7 }|I|1 |r||kr|1@  tJ|d jKtL||1jGdkr|1jMt!jNks8|1jGdkr\|1jMt!jOkr\t!jP}d }|Qt!jRr\|St!jR |1jTQt!jUpx|1jTQt!jV}2|2d krqHn|1W  zt|2 jX d}3W n. tk
r } zt|2|W 5 d }~X Y nX |3j+},|,dkr|1@  tdn|,s|Y|3}3|Z |3Z kr,d }	|St!j"d  |3}d }|1W  q֐qHqW 5 Q R X |d krb j[}|rp|1\  |$d k	r|1j]d k	r|1j]^|$j_ n|$_  tL||1_`|%D ]}&|&a||||1I d H  q|1W S  t?k
r0 } zB|#@  |$r|$_  d }$|%D ]}&|&b||||I d H  q  W 5 d }~X Y nX d S )NzSession is closedz9data and json parameters can not be used at the same time)dumpszChunk size is deprecated #1615r   re   c                    s    g | ]}t  ||jd qS ))r   )rN   Ztrace_config_ctx)r   r   r   r   rc   rd   r     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 URL)r   r   r   r   r   r   r   r   r   r   r~   r   r   r   timersessionr   r   tracesr   )r   r   zConnection timeout to host {}ZHEAD)r   Zskip_payloadr   r   r   r   )-  .  /  i3  i4  r   r   )r   r   )encoded)r   https z"Can redirect only to http or https)cr   r   r5   r   r   ZJsonPayloadro   
isinstanceboolr   r   r   rn   _prepare_headersr   r*   setrv   addr   rC   rq   rU   r@   rj   rZ   startr{   rz   Zsend_request_startr   rD   rm   r   ZAUTHORIZATIONrk   Zfilter_cookiesr;   r   loadrt   rB   itemsschemer   r   rw   rx   r?   r[   rh   AssertionErrorasyncioTimeoutErrorr.   r   	transportprotocolZset_response_paramsupperrs   r\   sendBaseExceptioncloser"   OSErrorr$   argsr   r   statusZsend_request_redirectappendr/   request_infotupler   	METH_HEAD	METH_POSTMETH_GETgetZCONTENT_LENGTHpopr   ZLOCATIONURIreleaserp   joinoriginrr   r   
connectionZadd_callbackcancelZ_historyZsend_request_endZ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   Z	redirectshistoryr   r   eZskip_headersr   Zreal_timeouttmhandler   tracer   Zauth_from_urlZall_cookiesZtmp_cookie_jarZreq_cookiesr   Z
proxy_inforeqconnexcrespZr_url
parsed_urlrc   r   rd   r   Y  s   #





	








  
	   
 

 






zClientSession._requestrc   g      $@r   i  @ r   	protocolsr   receive_timeout	autocloseautoping	heartbeatr   r   r   r   r   r   r   r   r   r   r   max_msg_size_WSRequestContextManager)r   r   r  r   r  r  r  r  r   r   r   r   r   r   r   r   r   r   r   r  r   c                C   s6   t | j|||||||||	|
||||||||||dS )zInitiate websocket connection.r  )r  _ws_connect)r   r   r   r  r   r  r  r  r  r   r   r   r   r   r   r   r   r   r   r   r  rc   rc   rd   
ws_connect  s0    zClientSession.ws_connectc          )         sJ  |d k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 k	r|
|tj< |rt|d}||tj< 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r6t|j|jd|j|jd|jtjd dkrjt|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krdd |jtj  dD }|D ]} | |kr| } qqd}!|r|jtj}"|"rzt!|"\}}!W nF t"k
r }# z&t|j|j|#j#d |j|jd|#W 5 d }#~#X Y nX nd}d}!|j$}$|$d k	st%|$j&}%|%d k	st%|$j'}&|&d k	st%t(|%d| j)d}'|%*t+|'||' t,|%|&d||!d}(W n  t-k
r    |.   Y n&X | j/|'|(|||||| j)||||!dS d S )NZ	websocketZupgradeZ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 rc   )strip)r   protorc   rc   rd   r   *  s   z-ClientSession._ws_connect.<locals>.<listcomp>r   r|   r   T)Zuse_maskr   
notakeover)r  r  r   Zclient_notakeover)0r   r   ZUPGRADEZ
CONNECTIONZSEC_WEBSOCKET_VERSIONr   
setdefaultbase64	b64encodeosurandomdecodeZSEC_WEBSOCKET_KEYr   ZSEC_WEBSOCKET_PROTOCOLZORIGINrK   ZSEC_WEBSOCKET_EXTENSIONSr5   rV   r   r0   r   r  r   r   lowerZSEC_WEBSOCKET_ACCEPThashlibZsha1rE   digestsplitrL   rI   r   r   r   r   r   rM   rj   Z
set_parserrG   rH   r   r   ry   ))r   r   r   r  r   r  r  r  r  r   r   r   r   r   r   r   r   r   r   r   r  r   Zdefault_headerskeyvalueZsec_keyZextstrr
  Zr_keymatchr   Zresp_protocolsr  r  Zcompress_hdrsr	  r  Z
conn_protor   readerwriterrc   rc   rd   r    s      


	
	

  
zClientSession._ws_connectzCIMultiDict[str])r   r   c                 C   sh   t | j}|rdt|ttfs$t |}t }| D ]0\}}||krP||| q2|||< || q2|S )z3Add default headers and transform it to CIMultiDict)r   ru   r   r   r   r   r   r   )r   r   resultZadded_namesr&  r'  rc   rc   rd   r   k  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   rc   rc   rd   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_OPTIONSr,  rc   rc   rd   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   r,  rc   rc   rd   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   rc   rc   rd   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_PUTr/  rc   rc   rd   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_PATCHr/  rc   rc   rd   patch  s    zClientSession.patch)r   r   r   c                 K   s   t | jtj|f|S )zPerform HTTP DELETE request.)r   r   r   ZMETH_DELETE)r   r   r   rc   rc   rd   delete  s    zClientSession.deleter   c                    s0   | j s,| jdk	r&| jr&| j I dH  d| _dS )zMClose underlying connector.

        Release all acquired resources.
        N)r   rh   rl   r   r   rc   rc   rd   r     s    zClientSession.closec                 C   s   | j dkp| j jS )z@Is client session closed.

        A readonly property.
        N)rh   r   r5  rc   rc   rd   r     s    zClientSession.closedc                 C   s   | j S )z(Connector instance used for the session.rh   r5  rc   rc   rd   r}     s    zClientSession.connectorc                 C   s   | j S )zThe session cookies.)rk   r5  rc   rc   rd   r     s    zClientSession.cookie_jarc                 C   s   | j S )z"The session HTTP protocol version.)rn   r5  rc   rc   rd   r     s    zClientSession.versionc                 C   s   | j S ))Do URL requoting on redirection handling.)rp   r5  rc   rc   rd   ri     s    z"ClientSession.requote_redirect_url)r   r   c                 C   s   t jdtdd || _dS )r7  z=session.requote_redirect_url modification is deprecated #2778r   r   N)r   r   r   rp   )r   r   rc   rc   rd   ri     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   rj   r5  rc   rc   rd   r~     s      zClientSession.loopc                 C   s   | j S )zTimeout for the session.)rq   r5  rc   rc   rd   r     s    zClientSession.timeoutc                 C   s   | j S )z*The default headers of the client session.)ru   r5  rc   rc   rd   r     s    zClientSession.headersc                 C   s   | j S )z2Headers for which autogeneration should be skipped)rv   r5  rc   rc   rd   r     s    zClientSession.skip_auto_headersc                 C   s   | j S )z2An object that represents HTTP Basic Authorization)rm   r5  rc   rc   rd   r     s    zClientSession.authc                 C   s   | j S )zJson serializer callable)ro   r5  rc   rc   rd   r     s    zClientSession.json_serializec                 C   s   | j S )z-Should connector be closed on session closing)rl   r5  rc   rc   rd   r     s    zClientSession.connector_ownerc                 C   s   | j S )z`
        Should `ClientResponse.raise_for_status()`
        be called for each response
        )rr   r5  rc   rc   rd   r   	  s    zClientSession.raise_for_statusc                 C   s   | j S )z6Should the body response be automatically decompressed)rs   r5  rc   rc   rd   r     s    zClientSession.auto_decompressc                 C   s   | j S )z
        Should get proxies information
        from HTTP_PROXY / HTTPS_PROXY environment variables
        or ~/.netrc file if present
        )rt   r5  rc   rc   rd   r     s    zClientSession.trust_envc                 C   s   | j S )z7A list of TraceConfig instances used for client tracing)rz   r5  rc   rc   rd   r   !  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.
        Nr6  r5  rc   rc   rd   detach&  s    zClientSession.detachc                 C   s   t dd S )NzUse async with instead)	TypeErrorr5  rc   rc   rd   	__enter__-  s    zClientSession.__enter__)exc_typeexc_valexc_tbr   c                 C   s   d S Nrc   r   r;  r<  r=  rc   rc   rd   __exit__0  s    zClientSession.__exit__c                    s   | S r>  rc   r5  rc   rc   rd   
__aenter__9  s    zClientSession.__aenter__c                    s   |   I d H  d S r>  )r   r?  rc   rc   rd   	__aexit__<  s    zClientSession.__aexit__)_r^   r_   r`   __doc__r   r   rg   r   r   r1   r2   r6   r   HttpVersion11rC   r   r7   r   AbstractEventLooprQ   rR   r   strr>   rP   r   rF   r   r   r   ra   objectrU   r   rO   intr   r   r<   r   r   r   r   rS   rV   r   bytesrW   r3   r   r   r   r   r  r  r   r   r-  r.  r0  r1  r2  r3  r   propertyr   r}   r   r   r   ri   setterr~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r8  r:  r   r   r@  rA  rB  __classcell__rc   rc   r   rd   rT      sv  



o
  

  86 /  	      	  	  
		
	
rT   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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>  )rO  )r   rR  rc   rc   rd   r   I  s    z#_BaseRequestContextManager.__init__)argr   c                 C   s   | j |S r>  )rO  r   r   rS  rc   rc   rd   r   L  s    z_BaseRequestContextManager.sendc                 C   s   | j | d S r>  )rO  throwrT  rc   rc   rd   rU  O  s    z _BaseRequestContextManager.throwr4  c                 C   s
   | j  S r>  )rO  r   r5  rc   rc   rd   r   R  s    z _BaseRequestContextManager.closec                 C   s   | j  }|S r>  )rO  	__await__)r   retrc   rc   rd   rV  U  s    
z$_BaseRequestContextManager.__await__c                 C   s   |   S r>  )rV  r5  rc   rc   rd   __iter__Y  s    z#_BaseRequestContextManager.__iter__c                    s   | j I d H | _| jS r>  rN  r5  rc   rc   rd   rA  \  s    z%_BaseRequestContextManager.__aenter__)r^   r_   r`   	__slots__r   rf   r   r   r   rU  r   r	   r   rV  rX  rA  rc   rc   rc   rd   rM  E  s   rM  c                   @   s0   e Zd Zeee  ee ee ddddZdS )r   Nr;  r	  tbr   c                    s   | j   d S r>  )rP  r   r   r;  r	  r[  rc   rc   rd   rB  b  s    z _RequestContextManager.__aexit__r^   r_   r`   r   r   r   r   rB  rc   rc   rc   rd   r   a  s
   
r   c                   @   s0   e Zd Zeee  ee ee ddddZdS )r  NrZ  c                    s   | j  I d H  d S r>  )rP  r   r\  rc   rc   rd   rB  q  s    z"_WSRequestContextManager.__aexit__r]  rc   rc   rc   rd   r  p  s
   
r  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rO  rP  _sessionrQ  N)rR  r   r   c                 C   s   || _ d | _|| _d S r>  r_  )r   rR  r   rc   rc   rd   r   ~  s    z&_SessionRequestContextManager.__init__r4  c                    sD   z| j I d H | _W n& tk
r8   | j I d H   Y nX | jS d S r>  )rO  rP  r   r`  r   r5  rc   rc   rd   rA    s    z(_SessionRequestContextManager.__aenter__rZ  c                    s,   | j d k	st| j   | j I d H  d S r>  )rP  r   r   r`  r\  rc   rc   rd   rB    s    
z'_SessionRequestContextManager.__aexit__)r^   r_   r`   rY  r   r2   rT   r   rA  r   r   r   r   rB  rc   rc   rc   rd   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   sd   d}|dk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   )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   rc   rc   rd   rV     sF    <	rV   )rC  r   r  r#  r   r  r   r   r   typesr   r   typingr   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,   r-   r.   r/   r0   Zclient_reqrepr1   r2   r3   r4   r5   Z	client_wsr6   r}   r7   r8   r9   r:   Z	cookiejarr;   Zhelpersr<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   Zhttp_websocketrI   rJ   rK   rL   ZstreamsrM   tracingrN   rO   ZtypedefsrP   rQ   rR   rS   __all__r   rW   ImportErrorrG  srU   r   rf   rT   rM  r   r  r^  rD  rF  r   rH  rE  rV   rc   rc   rc   rd   <module>   s   HT,(

       ) 
%

