a
    |f                     @   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 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/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@ ddlAmBZBmCZCmDZDmEZEmFZF ddlGmHZH ddlImJZJmKZKmLZLmMZM ddlNmOZO ddlPmQZQmRZRmSZSmTZTmUZUmVZVmWZWmXZXmYZY ddl)mZZZm[Z[m\Z\m]Z] ddl^m_Z_m`Z`maZambZb ddlcmdZd ddlemfZfmgZg ddlhmiZimjZjmkZkmlZlmmZm dZnzddlompZp W n eqyV   erZpY n0 ejsddddG dd dZtetddZueiet evd< edZwG d d! d!ZxG d"d# d#eeeewf eew ZyG d$d% d%eyeC ZzG d&d' d'eyeH Z{G d(d) d)Z|dddddddd*ddd+ddddeXde)j}dddd,e~emeee~e~f  eeeel eee~  eeS eeee~ ee eee eeem eeS eeterf eek e[eeJ ee eej e|d-d.d/ZdS )0zHTTP Client for asyncio.    N)suppress)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TimeoutHandleceil_timeoutget_env_proxy_for_urlget_running_loopsentinelstrip_auth_from_url)WS_KEYHttpVersionWebSocketReaderWebSocketWriter)WSHandshakeError	WSMessage
ws_ext_genws_ext_parse)FlowControlDataQueue)TraceTraceConfig)FinalJSONEncoderLooseCookiesLooseHeadersStrOrURL)r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r8   r:   r;   r9   r7   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 )rW   Ntotalconnect	sock_readsock_connect)
__name__
__module____qualname__r]   r   float__annotations__r^   r_   r`    rf   rf   HD:\Projects\storyit_web\backend\venv\Lib\site-packages\aiohttp/client.pyrW      s   
rW   i,  r]   DEFAULT_TIMEOUT_RetTypec                       s,  e Zd ZdZeg dZdZdZdrd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 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-ee.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e0e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e1 ee2 eee2ee3f  ee ee4 ee% edddZ5e6j7d 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e0eef  ee ee ee ee2ede3f ee ee1 ee2 ee e%e%d%d&d'd(Z8e6j7d 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e0eef  ee ee ee ee2ede3f ee ee1 ee2 ee e%e%ed&d)d*Z9ee d+d,d-d.Z:dd/eee)dd0d1d2Z;dd/eee)dd0d3d4Z<dd/eee)dd0d5d6Z=dd7ee)e)dd8d9d:Z>dd7ee)e)dd8d;d<Z?dd7ee)e)dd8d=d>Z@ee)dd?d@dAZAddBdCdDZBeCedBdEdFZDeCee dBdGdHZEeCedBdIdJZFeCeGe%e%f dBdKdLZHeCedBdMdNZIeIjJeddOdPdNZIeCejdBdQdRZKeCe"dBdSdTZLeCd+dBdUdVZMeCeNeO dBdWdXZPeCee dBdYdZZQeCedBd[d\ZReCedBd]d^ZSeCeeeTegeUd f f dBd_d`ZVeCedBdadbZWeCedBdcddZXeCe#e$ dBdedfZYddBdgdhZZddBdidjZ[eee\  ee\ ee] ddkdldmZ^d dBdndoZ_eee\  ee\ ee] ddkdpdqZ`  ZaS )srV   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_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_envrn   trace_configsread_bufsize)base_urlr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rn   r   r   returnc                C   s  |d u r|d ur|j }t|}|d u s0t|tr8|| _n"t|| _| j | jksZJ d|d u rlt|d}|j |ur~td|| _ | rt	
td| _|d u rt|d}|| _|d ur| j| || _|| _|| _|| _|| _|tu rRt| _|tur$tjdtdd tj| j|d| _|d ur|tj| j|d	| _tjd
tdd n*|| _|turjtd|d ur|td|| _|| _ || _!|| _"|| _#|rt$|}nt$ }|| _%|d urt&dd |D | _'nt& | _'|	| _(|
| _)|| _*|pg | _+| j+D ]}|,  qd 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   
stacklevelrh   )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   | ]}t |V  qd S N)r   ).0irf   rf   rg   	<genexpr>0      z)ClientSession.__init__.<locals>.<genexpr>)-ro   rC   
isinstancer   rk   originr:   RuntimeErrorZ	get_debug	tracebackextract_stacksys	_getframerl   r<   rp   update_cookiesrm   rq   rr   rs   rt   rD   ri   rv   warningswarnDeprecationWarningattrevolve
ValueErrorrw   rx   ry   ru   r   r   rz   	frozensetr{   r|   r}   r~   r   freeze)selfr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rn   r   r   real_headerstrace_configrf   rf   rg   __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   formatra   r   )r   rf   rf   rg   __init_subclass__<  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__rf   rg   r   F  s    
zClientSession.__setattr__)	_warningsr   c                 C   s`   | j s\trd| i}ni }|jd| tfi | | dd}| jd urP| j|d< | j| d S )NsourcezUnclosed client session zUnclosed client session)Zclient_sessionmessageZsource_traceback)closedr>   r   ResourceWarningrl   ro   Zcall_exception_handler)r   r   kwargscontextrf   rf   rg   __del__P  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   rf   rf   rg   rX   ^  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   rk   is_absolutepath
startswithjoin)r   r   r   rf   rf   rg   
_build_urld  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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   c          3         s   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} |} |}z |}W n. ty } zt||W Y d }~n
d }~0 0 t j} |d ur|D ]}!| t|! q|d ur>zt|}W n0 ty< } zt||W Y d }~n
d }~0 0 |tu rP j}"nt|tsht|d}"n|}"t j|"j}#|# }$|d u r j} fdd jD }%|%D ] }&|&||||I d H  q|#  }'zh|' t!|\}}(|	r|(rtd	|	d u r|(}	|	d u r  j"}	|d urH|	d urHt#j$|v rHtd
 j%&|})|d urt' }*|*(| |*&|}+|+r|))|+ |d urt|}n> j*rt+t, t-|\}}W d    n1 s0    Y   j.||||| ||)|	|||| j j/|||' |||%d},znt0|"j14 I d H @  j2d us8J  j2j1|,|%|"dI d H }-W d   I d H  q~1 I d H st0    Y  W n8 t3j4y }. zt5d6||.W Y d }.~.n
d }.~.0 0 |-j7d usJ |-j8d usJ |-j8j9|'|: dk| j;|"j<|d zlzH|,=|-I d H }/z|/|-I d H  W n t>yD   |/?   Y n0 W n t>yf   |-?   Y n0 W nb t@y    Y nN tAy }. z4|.jBd u rt|.t3j4r tC|.jD |.W Y d }.~.n
d }.~.0 0  j%(|/jE|/jF |/jGdv r|
r|%D ]"}&|&H|||||/I d H  q|d7 }|I|/ |rX||krX|/?  tJ|d jKtL||/jGdkrr|/jMt#jNks|/jGdv r|/jMt#jOkrt#jP}d }|Qt#jRr|St#jR |/jTQt#jUp|/jTQt#jV}0|0d u rސqn|/W  zt|0 jX d}1W n0 ty* } zt|0|W Y d }~n
d }~0 0 |1jY}2|2dvrN|/?  tdn|2s^|Z|1}1|[ |1[ krd }	|St#j$d  |1}d }|/W  qqqW d    n1 s0    Y  |d u rΈ j\}|r|/]  |$d ur
|/j^d ur|/j^_|$j` n|$`  tL||/_a|%D ]"}&|&b|||||/I d H  q|/W S  t>y } zP|#?  |$rl|$`  d }$|%D ]"}&|&c|||||I d H  qp 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   rh   c                    s    g | ]}t  ||jd qS ))r   )rO   Ztrace_config_ctx)r   r   r   r   rf   rg   
<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 URL)r   r   r   r   r   r   r   r   r   r   r   r   r   r   timersessionr   r   traces)r   r   zConnection timeout to host {}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)dr   r   r6   r   r   ZJsonPayloadrt   r   boolr   r   r   rs   _prepare_headersr   r+   setr{   addr   r   rD   rv   rW   r@   ro   r]   startr   r   Zsend_request_startZupdate_queryr   rE   rr   r   ZAUTHORIZATIONrp   Zfilter_cookiesr<   r   loadry   r   LookupErrorrB   r|   r}   rA   r^   rm   asyncioTimeoutErrorr/   r   	transportprotocolZset_response_paramsupperrx   r_   sendBaseExceptioncloser#   OSErrorerrnor%   argsr   r   statusZsend_request_redirectappendr0   request_infotupler   	METH_HEAD	METH_POSTMETH_GETgetZCONTENT_LENGTHpopr   ZLOCATIONURIreleaseru   schemer   r   rw   r   
connectionZadd_callbackcancelZ_historyZsend_request_endZsend_request_exception)3r   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  rf   r   rg   r   l  s   #

 

 

	








,>
	"



 


(


zClientSession._requestrf   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   r!  r   r   r   r   r   r   r   r   r   r   r   r   r"  r   c                C   s8   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   r"  rf   rf   rg   
ws_connect  s2    zClientSession.ws_connectc          *         sL  |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< 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r8t|j|jd|j|jd|jtjd dkrlt|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qd}"|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	websocketupgradeZ13   ,)r   F)r   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 rf   )strip)r   protorf   rf   rg   r   D  s   z-ClientSession._ws_connect.<locals>.<listcomp>r   r   r   T)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ORIGINrL   ZSEC_WEBSOCKET_EXTENSIONSr6   rX   r  r1   r  r  r   r  lowerZSEC_WEBSOCKET_ACCEPThashlibsha1rF   digestsplitrM   rJ   r  r  r   r   rN   ro   
set_parserrH   rI   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   default_headerskeyvalueZsec_keyZextstrr  Zr_keymatchr   Zresp_protocolsr+  r,  Zcompress_hdrsr  r  Z
conn_protor   readerwriterrf   rf   rg   r$    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   rz   r   r   r   r   r.  r   )r   r   resultZadded_namesr<  r=  rf   rf   rg   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   rf   rf   rg   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_OPTIONSrB  rf   rf   rg   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  rB  rf   rf   rg   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   rf   rf   rg   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_PUTrE  rf   rf   rg   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_PATCHrE  rf   rf   rg   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   rf   rf   rg   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   rm   rq   r   r   rf   rf   rg   r     s    zClientSession.closec                 C   s   | j du p| j jS )z@Is client session closed.

        A readonly property.
        N)rm   r   rK  rf   rf   rg   r     s    zClientSession.closedc                 C   s   | j S )z(Connector instance used for the session.rm   rK  rf   rf   rg   r     s    zClientSession.connectorc                 C   s   | j S )zThe session cookies.)rp   rK  rf   rf   rg   r     s    zClientSession.cookie_jarc                 C   s   | j S )z"The session HTTP protocol version.)rs   rK  rf   rf   rg   r     s    zClientSession.versionc                 C   s   | j S ))Do URL requoting on redirection handling.)ru   rK  rf   rf   rg   rn     s    z"ClientSession.requote_redirect_url)r   r   c                 C   s   t jdtdd || _dS )rM  z=session.requote_redirect_url modification is deprecated #2778r   r   N)r   r   r   ru   )r   r   rf   rf   rg   rn     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   ro   rK  rf   rf   rg   r     s    zClientSession.loopc                 C   s   | j S )zTimeout for the session.)rv   rK  rf   rf   rg   r     s    zClientSession.timeoutc                 C   s   | j S )z*The default headers of the client session.)rz   rK  rf   rf   rg   r   
  s    zClientSession.headersc                 C   s   | j S )z2Headers for which autogeneration should be skipped)r{   rK  rf   rf   rg   r     s    zClientSession.skip_auto_headersc                 C   s   | j S )z2An object that represents HTTP Basic Authorization)rr   rK  rf   rf   rg   r     s    zClientSession.authc                 C   s   | j S )zJson serializer callable)rt   rK  rf   rf   rg   r     s    zClientSession.json_serializec                 C   s   | j S )z-Should connector be closed on session closing)rq   rK  rf   rf   rg   r     s    zClientSession.connector_ownerc                 C   s   | j S )zGShould `ClientResponse.raise_for_status()` be called for each response.)rw   rK  rf   rf   rg   r   #  s    zClientSession.raise_for_statusc                 C   s   | j S )z7Should the body response be automatically decompressed.)rx   rK  rf   rf   rg   r   *  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.
        )ry   rK  rf   rf   rg   r   /  s    zClientSession.trust_envc                 C   s   | j S )z7A list of TraceConfig instances used for client tracing)r   rK  rf   rf   rg   r   9  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.
        NrL  rK  rf   rf   rg   detach>  s    zClientSession.detachc                 C   s   t dd S )NzUse async with instead)	TypeErrorrK  rf   rf   rg   	__enter__E  s    zClientSession.__enter__)exc_typeexc_valexc_tbr   c                 C   s   d S r   rf   r   rQ  rR  rS  rf   rf   rg   __exit__H  s    zClientSession.__exit__c                    s   | S r   rf   rK  rf   rf   rg   
__aenter__Q  s    zClientSession.__aenter__c                    s   |   I d H  d S r   )r   rT  rf   rf   rg   	__aexit__T  s    zClientSession.__aexit__)N)bra   rb   rc   __doc__r   r   rl   rm   r   r   r2   r3   r7   r   HttpVersion11rD   r   rU   r8   r   AbstractEventLooprS   rT   r   strr?   rR   r   rG   r   r   r   rd   objectrW   r   rP   intr   r   r=   r   r   r   r   rX   r   r   r   bytesrY   r4   r   r   r   r
  r%  r$  r   r  rC  rD  rF  rG  rH  rI  r   propertyr   r   r   r   r   rn   setterr   r   r   r	   r   r   r   r   r   r   r   r   r   r   r   rN  rP  r   r   rU  rV  rW  __classcell__rf   rf   r   rg   rV      sB   



w


  ;8 1			
		
	
rV   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   )rd  )r   rg  rf   rf   rg   r   a  s    z#_BaseRequestContextManager.__init__)argr   c                 C   s   | j |S r   )rd  r   r   rh  rf   rf   rg   r   d  s    z_BaseRequestContextManager.sendc                 C   s   | j | d S r   )rd  throwri  rf   rf   rg   rj  g  s    z _BaseRequestContextManager.throwrJ  c                 C   s
   | j  S r   )rd  r   rK  rf   rf   rg   r   j  s    z _BaseRequestContextManager.closec                 C   s   | j  }|S r   )rd  	__await__)r   retrf   rf   rg   rk  m  s    
z$_BaseRequestContextManager.__await__c                 C   s   |   S r   )rk  rK  rf   rf   rg   __iter__q  s    z#_BaseRequestContextManager.__iter__c                    s   | j I d H | _| jS r   rc  rK  rf   rf   rg   rV  t  s    z%_BaseRequestContextManager.__aenter__)ra   rb   rc   	__slots__r   rj   r   r   r   rj  r   r
   r   rk  rm  rV  rf   rf   rf   rg   rb  ]  s   rb  c                   @   s4   e Zd ZdZeee  ee ee ddddZdS )r   rf   NrQ  r  tbr   c                    s   | j   d S r   )re  r  r   rQ  r  rp  rf   rf   rg   rW  |  s    z _RequestContextManager.__aexit__	ra   rb   rc   rn  r   r   r   r   rW  rf   rf   rf   rg   r   y  s   
r   c                   @   s4   e Zd ZdZeee  ee ee ddddZdS )r#  rf   Nro  c                    s   | j  I d H  d S r   )re  r   rq  rf   rf   rg   rW    s    z"_WSRequestContextManager.__aexit__rr  rf   rf   rf   rg   r#    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rd  re  _sessionrf  N)rg  r   r   c                 C   s   || _ d | _|| _d S r   rt  )r   rg  r   rf   rf   rg   r     s    z&_SessionRequestContextManager.__init__rJ  c                    sB   z| j I d H | _W n$ ty6   | j I d H   Y n0 | jS d S r   )rd  re  r   ru  r   rK  rf   rf   rg   rV    s    z(_SessionRequestContextManager.__aenter__ro  c                    s,   | j d usJ | j   | j I d H  d S r   )re  r   ru  rq  rf   rf   rg   rW    s    
z'_SessionRequestContextManager.__aexit__)ra   rb   rc   rn  r   r3   rV   r   rV  r   r   r   r   rW  rf   rf   rf   rg   rs    s   	
rs  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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:   rV   rs  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   rf   rf   rg   rX     sF    >	rX   )rX  r   r0  r6  r   r2  r   r   r   
contextlibr   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/   r0   r1   Zclient_reqrepr2   r3   r4   r5   r6   Z	client_wsr7   r   r8   r9   r:   r;   	cookiejarr<   Zhelpersr=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   Zhttp_websocketrJ   rK   rL   rM   ZstreamsrN   tracingrO   rP   ZtypedefsrQ   rR   rS   rT   rU   __all__r   rY   ImportErrorr\  srW   ri   re   rj   rV   rb  r   r#  rs  rY  r[  r   r]  rZ  rX   rf   rf   rf   rg   <module>   s   HT,(
       @ %

