U '7`@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl m Z m Z ddl m Z mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZddlZddlmZm Z m!Z!m"Z"ddl#m$Z$ddl%m&Z&m'Z'm(Z(dd l)m*Z*dd l+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;mZ>dd l?m@Z@mAZAmBZBmCZCmDZDdd lEmFZFdd lGmHZHmIZImJZJmKZKddlLmMZMddlNmOZOmPZPmQZQmRZRmSZSmTZTmUZUmVZVmWZWddl'mXZXmYZYmZZZm[Z[ddl\m]Z]m^Z^m_Z_m`Z`ddlambZbddlcmdZdmeZeddlfmgZgmhZhmiZimjZjdZkzddllmmZmWnenk rFeoZmYnXejpddddGdddZqeqddZredZsGdddZtGd d!d!ee e esfeesZuGd"d#d#eueAZvGd$d%d%eueFZwGd&d'd'Zxdddddddd(ddd)ddddeVde'jydddd*ezejeeezezfe e eeieeezeeQe{e|eezee{e{ee{e{eejeeQeeqeofeeheYeeHee|eej}exd+d,d-Z~dS).zHTTP Client for asyncio.N)SimpleNamespace TracebackType)Any AwaitableCallable Coroutine FrozenSet GeneratorGenericIterableListMappingOptionalSetTupleTypeTypeVarUnion) CIMultiDict MultiDictMultiDictProxyistr)URL)hdrshttppayload)AbstractCookieJar)ClientConnectionErrorClientConnectorCertificateErrorClientConnectorErrorClientConnectorSSLError ClientErrorClientHttpProxyError ClientOSErrorClientPayloadErrorClientProxyConnectionErrorClientResponseErrorClientSSLErrorContentTypeError InvalidURLServerConnectionErrorServerDisconnectedErrorServerFingerprintMismatchServerTimeoutErrorTooManyRedirectsWSServerHandshakeError) ClientRequestClientResponse Fingerprint RequestInfo_merge_ssl_params)ClientWebSocketResponse) BaseConnectorNamedPipeConnector TCPConnector UnixConnector) CookieJar) DEBUGPY_36 BasicAuth CeilTimeout TimeoutHandleget_running_loopproxies_from_envsentinelstrip_auth_from_url)WS_KEY HttpVersionWebSocketReaderWebSocketWriter)WSHandshakeError WSMessage ws_ext_gen ws_ext_parse)FlowControlDataQueue)Trace TraceConfig) JSONEncoder LooseCookies LooseHeadersStrOrURL)rrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1r2r3r4r7r9r:r8r6 ClientSession ClientTimeoutrequest) SSLContextT)Z auto_attribsfrozenslotsc@sNeZdZUdZeeed<dZeeed<dZeeed<dZ eeed<dS)rUNtotalconnect sock_read sock_connect) __name__ __module__ __qualname__rZrfloat__annotations__r[r\r]rcrcA/opt/alt/python38/lib64/python3.8/site-packages/aiohttp/client.pyrUs rUi,rZ_RetTypecseZdZdZedddddddd d d d d dddddddddgZdZddddddeje e e e j dddededdddddeeeejeeeeeeeeeeee ee ee eeeeeeeefeeeee feeeee!e"e#ddddZ$edddd d!Z%e&r*ee'dd"fd#d$ Z(e)fe'dd%d&d'Z*ee+e'd(d)d*d+Z,ddddddddd,dddddddedddddddd-ee+ee-eefe'e'eeeeeeeeeee#eeeeeeeeee+eeee efeeee.ee/eee/ee0feeee1ee#e d.d/d0Z2e3j4d1d2ddddddddddddddd3d4d5e+eeeeeeeeeeeeeeeeee+eeee/ede0feeee.ee/eee#e#d6d7d8d9Z5e3j4d1d2ddddddddddddddd3d4d5e+eeeeeeeeeeeeeeeeee+eeee/ede0feeee.ee/eee#e#e d7d:d;Z6eedd?Z7dd@e+ee'd(dAdBdCZ8dd@e+ee'd(dAdDdEZ9dd@e+ee'd(dAdFdGZ:ddHe+e'e'd(dIdJdKZ;ddHe+e'e'd(dIdLdMZddSdTdUZ?e@edSdVdWZAe@eedSdXdYZBe@edSdZd[ZCe@eDe#e#fdSd\d]ZEe@edSd^d_ZFeFjGedd`dad_ZFe@ejdSdbdcZHe@eee fdSdddeZIe@dtj|j|d|_tjd tddn*||_|tk r,td |dk r>td ||_||_||_||_||_|rlt |}nt }||_!|dk rt"d d |D|_#nt"|_#||_$| |_%| |_&|pg|_'|j'D]}|(qdS)Nr~z0Session and connector has to use same event looprz8read_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.connectcSsg|] }t|qSrc)r).0ircrcrd %sz*ClientSession.__init__..))rjrAr9 RuntimeErrorZ get_debug traceback extract_stacksys _getframergr;rkupdate_cookiesrhrlrmrnrorCDEFAULT_TIMEOUTrqwarningswarnDeprecationWarningattrZevolve ValueErrorrrrsrtrpr{rru frozensetrvrwrxryrzZfreeze)selfr}r~rrrrrrrrrrrrrrrrrrirr real_headers trace_configrcrcrd__init__s            zClientSession.__init__)clsrcCstjd|jtdddS)Nz6Inheritance class {} from ClientSession is discouragedrr)rrformatr^r)rrcrcrd__init_subclass__1szClientSession.__init_subclass__)namevalrcs2||jkr tjd|tddt||dS)Nz8Setting custom ClientSession.{} attribute is discouragedrr)ATTRSrrrrsuper __setattr__)rrr __class__rcrdr;s zClientSession.__setattr__) _warningsrcCs\|jsXtrd|i}ni}|jd|tf||dd}|jdk rL|j|d<|j|dS)NsourcezUnclosed client session zUnclosed client session)Zclient_sessionmessageZsource_traceback)closedr=rResourceWarningrgrjZcall_exception_handler)rrkwargscontextrcrcrd__del__Es    zClientSession.__del___RequestContextManager)methodurlrrcKst|j||f|S)zPerform HTTP request.)r_request)rrrrrcrcrdrVSszClientSession.request )paramsdatajsonrrrrallow_redirects max_redirectscompresschunked expect100rread_until_eofproxy proxy_authr verify_ssl fingerprint ssl_contextssl proxy_headerstrace_request_ctxr)r str_or_urlrrrrrrrrrrrrrrrrrrrrrrrrrc4sjrtdt||||}|dk r6|dk r6tdn|dk rNtj|jd}t| tsl| dk rlt dt d}g}j } |} |}z t|}Wn,tk r}zt||W5d}~XYnXtj} |dk r|D]}!| t|!q|dk r8z t|}Wn.tk r6}zt||W5d}~XYnX|tkrJj}"nt|tsbt|d}"n|}"tj|"j}#|#}$|dkrj}fddjD}%|%D]}&|&|||IdHq|#}'z|'Ht|\}}(| r|(rtd | dkr|(} | dkrj } |dk r<| dk rYnXWn t=k r|/>YnXWnFt?k r Yn0t@k rN}0ztA|0jB|0W5d}0~0XYnXj#&|1jC|1jD|1jEdkr| r|%D]}&|&F||||1IdHqx|d7}|G|1| r|| kr|1>tH|djItJ||1jEdkr|1jKt!jLks|1jEdkr,|1jKt!jMkr,t!jN}d}|Ot!jPr,|Qt!jP|1jROt!jSpH|1jROt!jT}2|2dkrZqn|1Uzt|2jV d}3Wn.tk r}zt|2|W5d}~XYnX|3j+},|,dkr|1>tdn|,s|W|3}3|X|3Xkrd} |Qt!j"d|3}d}|1Uq֐qqW5QRX|dkr2jY}|r@|1Z|$dk rn|1j[dk rf|1j[\|$j]n|$]tJ||1_^|%D]}&|&_||||1IdHq||1WSt=k r}zB|#>|$r|$]d}$|%D]}&|&`||||IdHqЂW5d}~XYnXdS)NzSession is closedz9data and json parameters can not be used at the same time)dumpszChunk size is deprecated #1615rrecs g|]}t||jdqS))r)rNZtrace_config_ctx)rrrrrcrdrs  z*ClientSession._request..z.rr|rT)Zuse_maskr notakeover)rrrZclient_notakeover)/rrZUPGRADEZ CONNECTIONZSEC_WEBSOCKET_VERSIONr setdefaultbase64Z b64encodeosurandomdecodeZSEC_WEBSOCKET_KEYrZSEC_WEBSOCKET_PROTOCOLZORIGINrKZSEC_WEBSOCKET_EXTENSIONSr5rVrr0rrrrlowerZSEC_WEBSOCKET_ACCEPThashlibZsha1rEZdigestsplitrLrIrrr transportrMrjZ set_parserrGrHrrry))rrrrrrrrrrrrrrrrrrrrrrZdefault_headerskeyvalueZsec_keyZextstrrZr_keymatchrZresp_protocolsrrZ compress_hdrsrrZ conn_protorreaderwriterrcrcrdr s           zClientSession._ws_connectzCIMultiDict[str])rrcCsht|j}|rdt|ttfs$t|}t}|D]0\}}||krP|||q2|||<||q2|S)z3Add default headers and transform it to CIMultiDict)rrurrrrrr)rrresultZ added_namesrrrcrcrdrks  zClientSession._prepare_headers)r)rrrrcKst|jtj|fd|i|S)zPerform HTTP GET request.r)rrrrrrrrrcrcrdr{szClientSession.getcKst|jtj|fd|i|S)zPerform HTTP OPTIONS request.r)rrrZ METH_OPTIONSr rcrcrdoptionsszClientSession.optionscKst|jtj|fd|i|S)zPerform HTTP HEAD request.r)rrrrr rcrcrdheadszClientSession.head)r)rrrrcKst|jtj|fd|i|S)zPerform HTTP POST request.r)rrrrrrrrrcrcrdpostszClientSession.postcKst|jtj|fd|i|S)zPerform HTTP PUT request.r)rrrZMETH_PUTr#rcrcrdputszClientSession.putcKst|jtj|fd|i|S)zPerform HTTP PATCH request.r)rrrZ METH_PATCHr#rcrcrdpatchszClientSession.patch)rrrcKst|jtj|f|S)zPerform HTTP DELETE request.)rrrZ METH_DELETE)rrrrcrcrddeleteszClientSession.deletercs0|js,|jdk r&|jr&|jIdHd|_dS)zMClose underlying connector. Release all acquired resources. N)rrhrlrrrcrcrdrszClientSession.closecCs|jdkp|jjS)z@Is client session closed. A readonly property. N)rhrr)rcrcrdrszClientSession.closedcCs|jS)z(Connector instance used for the session.rhr)rcrcrdr}szClientSession.connectorcCs|jS)zThe session cookies.)rkr)rcrcrdrszClientSession.cookie_jarcCs|jS)z"The session HTTP protocol version.)rnr)rcrcrdrszClientSession.versioncCs|jS))Do URL requoting on redirection handling.)rpr)rcrcrdrisz"ClientSession.requote_redirect_url)rrcCstjdtdd||_dS)r+z=session.requote_redirect_url modification is deprecated #2778rrN)rrrrp)rrrcrcrdris cCstjdtdd|jS)zSession's loop.z"client.loop property is deprecatedrr)rrrrjr)rcrcrdr~s zClientSession.loopcCs|jS)zTimeout for the session.)rqr)rcrcrdrszClientSession.timeoutcCs|jS)z*The default headers of the client session.)rur)rcrcrdrszClientSession.headerscCs|jS)z2Headers for which autogeneration should be skipped)rvr)rcrcrdrszClientSession.skip_auto_headerscCs|jS)z2An object that represents HTTP Basic Authorization)rmr)rcrcrdrszClientSession.authcCs|jS)zJson serializer callable)ror)rcrcrdrszClientSession.json_serializecCs|jS)z-Should connector be closed on session closing)rlr)rcrcrdrszClientSession.connector_ownercCs|jS)z` Should `ClientResponse.raise_for_status()` be called for each response )rrr)rcrcrdr szClientSession.raise_for_statuscCs|jS)z6Should the body response be automatically decompressed)rsr)rcrcrdrszClientSession.auto_decompresscCs|jS)z Should get proxies information from HTTP_PROXY / HTTPS_PROXY environment variables or ~/.netrc file if present )rtr)rcrcrdrszClientSession.trust_envcCs|jS)z7A list of TraceConfig instances used for client tracing)rzr)rcrcrdr!szClientSession.trace_configscCs d|_dS)zwDetach connector from session without closing the former. Session is switched to closed state anyway. Nr*r)rcrcrddetach&szClientSession.detachcCs tddS)NzUse async with instead) TypeErrorr)rcrcrd __enter__-szClientSession.__enter__)exc_typeexc_valexc_tbrcCsdSNrcrr/r0r1rcrcrd__exit__0szClientSession.__exit__cs|Sr2rcr)rcrcrd __aenter__9szClientSession.__aenter__cs|IdHdSr2)rr3rcrcrd __aexit__<szClientSession.__aexit__)_r^r_r`__doc__rrrgrrr1r2r6r HttpVersion11rCrr7rAbstractEventLooprQrRr strr>rPrrFrrrraobjectrUr rOintrrr<rrrrrSrVr bytesrWr3rrrrr r rrr!r"r$r%r&r'rpropertyrr}rrrrisetterr~rrrrrrrrrrrrrrr,r.rrr4r5r6 __classcell__rcrcrrdrTsv     o     8 6 /            rTc@seZdZdZeddefddddZddddd Zeddd d Z dd d dZ e e defd ddZ e e defd ddZed ddZdS)_BaseRequestContextManager_coro_respasyncio.Future[Any]N)cororcCs ||_dSr2)rC)rrFrcrcrdrIsz#_BaseRequestContextManager.__init__)argrcCs |j|Sr2)rCrrrGrcrcrdrLsz_BaseRequestContextManager.sendcCs|j|dSr2)rCthrowrHrcrcrdrIOsz _BaseRequestContextManager.throwr(cCs |jSr2)rCrr)rcrcrdrRsz _BaseRequestContextManager.closecCs|j}|Sr2)rC __await__)rZretrcrcrdrJUs z$_BaseRequestContextManager.__await__cCs|Sr2)rJr)rcrcrd__iter__Ysz#_BaseRequestContextManager.__iter__cs|jIdH|_|jSr2rBr)rcrcrdr5\sz%_BaseRequestContextManager.__aenter__)r^r_r` __slots__rrfrrrrIrr rrJrKr5rcrcrcrdrAEsrAc@s0eZdZeeeeeeeddddZdS)rNr/rtbrcs|jdSr2)rDrrr/rrNrcrcrdr6bs z _RequestContextManager.__aexit__r^r_r`rrrrr6rcrcrcrdras  rc@s0eZdZeeeeeeeddddZdS)rNrMcs|jIdHdSr2)rDrrOrcrcrdr6qsz"_WSRequestContextManager.__aexit__rPrcrcrcrdrps  rc@s^eZdZdZeddefeddddZeddd Ze e e e e e e dd d d Z dS) _SessionRequestContextManagerrCrD_sessionrEN)rFrrcCs||_d|_||_dSr2rR)rrFrrcrcrdr~sz&_SessionRequestContextManager.__init__r(csDz|jIdH|_Wn&tk r8|jIdHYnX|jSdSr2)rCrDrrSrr)rcrcrdr5s z(_SessionRequestContextManager.__aenter__rMcs|j|jIdHdSr2)rDrrSrOrcrcrdr6s z'_SessionRequestContextManager.__aexit__)r^r_r`rLrr2rTrr5rrrrr6rcrcrcrdrQzs   rQrF)rrrrrrrrrrrrrrrrrrr}rr~)rrrrrrrrrrrrrrrrrrrrr}rr~rcCsdd}|dkrd}t|dd}t||||||d}t|j|||||||||| | | | | ||||d|S)aConstructs 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 >>> data = await resp.read() FNT)r~Z force_close)r~rrrr}r)rrrrrrrrrrrrrrrr)r9rTrQr)rrrrrrrrrrrrrrrrrrrrr}rr~rrrcrcrdrVsF<  rV)r7rrrrrrrrtypesrrtypingrrrrrr r r r r rrrrrrrZ multidictrrrrZyarlrrrrrabcrZclient_exceptionsrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0Z client_reqrepr1r2r3r4r5Z client_wsr6r}r7r8r9r:Z cookiejarr;Zhelpersr<r=r>r?r@rArBrCrDrErFrGrHZhttp_websocketrIrJrKrLZstreamsrMtracingrNrOZtypedefsrPrQrRrS__all__rrW ImportErrorr;srUrrfrTrArrrQr8r:rr<r9rVrcrcrcrdsH  T  ,  (  )  %