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_urlrrrrrrrrrrrrrrrrrrrrrrrrrc4s6jrtdt||||}|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|'xt|\}}(| r|(rtd | dkr|(} | dkrj } |dk r<| dk r|/IdH}1z|1|/IdHWn t?k r|1@YnXWn t?k r4|/@YnXWnFtAk rPYn0tBk r~}0ztC|0jD|0W5d}0~0XYnXj#&|1jE|1jF|1jGdkrH| rH|%D]}&|&H||||1IdHq|d7}|I|1| r|| kr|1@tJ|djKtL||1jGdkr|1jMt!jNks8|1jGdkr\|1jMt!jOkr\t!jP}d}|Qt!jRr\|St!jR|1jTQt!jUpx|1jTQt!jV}2|2dkrqHn|1Wzt|2jX d}3Wn.tk r}zt|2|W5d}~XYnX|3j+},|,dkr|1@tdn|,s|Y|3}3|Z|3Zkr,d} |St!j"d|3}d}|1Wq֐qHqW5QRX|dkrbj[}|rp|1\|$dk r|1j]dk r|1j]^|$j_n|$_tL||1_`|%D]}&|&a||||1IdHq|1WSt?k r0}zB|#@|$r|$_d}$|%D]}&|&b||||IdHqW5d}~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)0rrZUPGRADEZ CONNECTIONZSEC_WEBSOCKET_VERSIONr setdefaultbase64Z b64encodeosurandomdecodeZSEC_WEBSOCKET_KEYrZSEC_WEBSOCKET_PROTOCOLZORIGINrKZSEC_WEBSOCKET_EXTENSIONSr5rVrr0rrrrlowerZSEC_WEBSOCKET_ACCEPThashlibZsha1rEZdigestsplitrLrIrrrrrrMrjZ set_parserrGrHrrry))rrrrrrrrrrrrrrrrrrrrr rZdefault_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_tbrcCsdSNrcrr0r1r2rcrcrd__exit__0szClientSession.__exit__cs|Sr3rcr*rcrcrd __aenter__9szClientSession.__aenter__cs|IdHdSr3)rr4rcrcrd __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/rrr5r6r7 __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 ||_dSr3)rD)rrGrcrcrdrIsz#_BaseRequestContextManager.__init__)argrcCs |j|Sr3)rDrrrHrcrcrdrLsz_BaseRequestContextManager.sendcCs|j|dSr3)rDthrowrIrcrcrdrJOsz _BaseRequestContextManager.throwr)cCs |jSr3)rDrr*rcrcrdrRsz _BaseRequestContextManager.closecCs|j}|Sr3)rD __await__)rZretrcrcrdrKUs z$_BaseRequestContextManager.__await__cCs|Sr3)rKr*rcrcrd__iter__Ysz#_BaseRequestContextManager.__iter__cs|jIdH|_|jSr3rCr*rcrcrdr6\sz%_BaseRequestContextManager.__aenter__)r^r_r` __slots__rrfrrrrJrr rrKrLr6rcrcrcrdrBEsrBc@s0eZdZeeeeeeeddddZdS)rNr0rtbrcs|jdSr3)rErrr0rrOrcrcrdr7bs z _RequestContextManager.__aexit__r^r_r`rrrrr7rcrcrcrdras  rc@s0eZdZeeeeeeeddddZdS)r NrNcs|jIdHdSr3)rErrPrcrcrdr7qsz"_WSRequestContextManager.__aexit__rQrcrcrcrdr ps  r c@s^eZdZdZeddefeddddZeddd Ze e e e e e e dd d d Z dS) _SessionRequestContextManagerrDrE_sessionrFN)rGrrcCs||_d|_||_dSr3rS)rrGrrcrcrdr~sz&_SessionRequestContextManager.__init__r)csDz|jIdH|_Wn&tk r8|jIdHYnX|jSdSr3)rDrErrTrr*rcrcrdr6s z(_SessionRequestContextManager.__aenter__rNcs,|jdk st|j|jIdHdSr3)rErrrTrPrcrcrdr7s z'_SessionRequestContextManager.__aexit__)r^r_r`rMrr2rTrr6rrrrr7rcrcrcrdrRzs   rRrF)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)r9rTrRr)rrrrrrrrrrrrrrrrrrrrr}rr~rrrcrcrdrVsF<  rV)r8rrrrrrrrtypesrrtypingrrrrrr 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<srUrrfrTrBrr rRr9r;rr=r:rVrcrcrcrdsH  T  ,  (  )  %