B `@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`ddlambZbddlcmdZdmeZeddlfmgZgmhZhmiZimjZjdZkyddllmmZmWnenk 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]rcrci/private/var/folders/7j/8686xlfs15q3tgljmghtvg0r0000gn/T/pip-target-isidps9b/lib/python/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|_'x|j'D]}|(qWdS)N)r|z0Session and connector has to use same event looprz8read_timeout is deprecated, use timeout argument instead) stacklevel)rZ)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__..))rirAr9 RuntimeErrorZ get_debug traceback extract_stacksys _getframerfr;rjupdate_cookiesrgrkrlrmrnrCDEFAULT_TIMEOUTrpwarningswarnDeprecationWarningattrZevolve ValueErrorrqrrrsrorzrrt frozensetrurvrwrxryfreeze)selfr{r|r}r~rrrrrrrrrrrrrrrrhrr real_headers trace_configrcrcrd__init__sx             zClientSession.__init__)clsrcCstjd|jtdddS)Nz6Inheritance class {} from ClientSession is discouragedr)r)rrformatr^r)rrcrcrd__init_subclass__1s zClientSession.__init_subclass__)namevalrcs2||jkr tjd|tddt||dS)Nz8Setting custom ClientSession.{} attribute is discouragedr)r)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=rResourceWarningrfriZcall_exception_handler)rrkwargscontextrcrcrd__del__Es    zClientSession.__del___RequestContextManager)methodurlrrcKst|j||f|S)zPerform HTTP request.)r_request)rrrrrcrcrdrVSszClientSession.request )paramsdatajsonr}r~rrallow_redirects max_redirectscompresschunked expect100rread_until_eofproxy proxy_authr verify_ssl fingerprint ssl_contextssl proxy_headerstrace_request_ctxr)r str_or_urlrrrr}r~rrrrrrrrrrrrrrrrrrrrc4sJjrtdt||||}|dk r6|dk r6tdn|dk rNtj|jd}t| tsl| dk rlt dt d}g}j } |} |}y t|}Wn,tk r}zt||Wdd}~XYnXtj} |dk rx|D]}!| t|!qW|dk r|/IdH}1y|1|/IdHWn t?k r|1@YnXWn t?k r@|/@YnXWnFtAk r\Yn0tBk r}0ztC|0jD|0Wdd}0~0XYnXj#&|1jE|1jF|1jGdkrN| rNx$|%D]}&|&H||||1IdHqW|d7}|I|1| r|| kr|1@tJ|djKtL||1jGdkr.|1jMt!jNksH|1jGdkrl|1jMt!jOkrlt!jP}d}|Qt!jRrl|St!jR|1jTQt!jUp|1jTQt!jV}2|2dkrPn|1Wyt|2jX d}3Wn.tk r}zt|2|Wdd}~XYnX|3j+},|,dkr|1@tdn|,s|Y|3}3|Z|3Zkr:d} |St!j"d|3}d}|1WqPqWWdQRX|dkrpj[}|r~|1\|$dk r|1j]dk r|1j]^|$j_n|$_tL||1_`x$|%D]}&|&a||||1IdHqW|1St?k rD}zF|#@|$r |$_d}$x$|%D]}&|&b||||IdHqWWdd}~XYnXdS)NzSession is closedz9data and json parameters can not be used at the same time)dumpszChunk size is deprecated #1615r)rZcs g|]}t||jdqS))r)rNZtrace_config_ctx)rr)rrrcrdrsz*ClientSession._request..z.ri)r|T)Zuse_maskr notakeover)rr rZclient_notakeover)0rrUPGRADEZ CONNECTIONZSEC_WEBSOCKET_VERSIONr setdefaultbase64 b64encodeosurandomdecodeZSEC_WEBSOCKET_KEYrZSEC_WEBSOCKET_PROTOCOLZORIGINrKZSEC_WEBSOCKET_EXTENSIONSr5rVrr0rrr~rlowerZSEC_WEBSOCKET_ACCEPThashlibsha1rEdigestsplitrLrIrrrrrrMri set_parserrGrHrrrx))rrrrrrrr r rrr~rrrrrrrrr rdefault_headerskeyvalueZsec_keyZextstrrZr_keymatchrZresp_protocolsrrZ compress_hdrsrrZ conn_protorreaderwriterrcrcrdr s             zClientSession._ws_connectzCIMultiDict[str])r~rcCslt|j}|rht|ttfs$t|}t}x<|D]0\}}||krR|||q4|||<||q4W|S)z3Add default headers and transform it to CIMultiDict)rrtrrrrrr)rr~resultZ added_namesr$r%rcrcrdrks zClientSession._prepare_headers)r)rrrrcKst|jtj|fd|i|S)zPerform HTTP GET request.r)rrrr)rrrrrcrcrdr{szClientSession.getcKst|jtj|fd|i|S)zPerform HTTP OPTIONS request.r)rrrZ METH_OPTIONS)rrrrrcrcrdoptionsszClientSession.optionscKst|jtj|fd|i|S)zPerform HTTP HEAD request.r)rrrr)rrrrrcrcrdheadszClientSession.head)r)rrrrcKst|jtj|fd|i|S)zPerform HTTP POST request.r)rrrr)rrrrrcrcrdpostszClientSession.postcKst|jtj|fd|i|S)zPerform HTTP PUT request.r)rrrZMETH_PUT)rrrrrcrcrdputszClientSession.putcKst|jtj|fd|i|S)zPerform HTTP PATCH request.r)rrrZ METH_PATCH)rrrrrcrcrdpatchszClientSession.patch)rrrcKst|jtj|f|S)zPerform HTTP DELETE request.)rrrZ METH_DELETE)rrrrcrcrddeleteszClientSession.delete)rcs0|js,|jdk r&|jr&|jIdHd|_dS)zMClose underlying connector. Release all acquired resources. N)rrgrkr)rrcrcrdrszClientSession.closecCs|jdkp|jjS)z@Is client session closed. A readonly property. N)rgr)rrcrcrdrszClientSession.closedcCs|jS)z(Connector instance used for the session.)rg)rrcrcrdr{szClientSession.connectorcCs|jS)zThe session cookies.)rj)rrcrcrdrszClientSession.cookie_jarcCs|jS)z"The session HTTP protocol version.)rm)rrcrcrdrszClientSession.versioncCs|jS)z)Do URL requoting on redirection handling.)ro)rrcrcrdrhsz"ClientSession.requote_redirect_url)rrcCstjdtdd||_dS)z)Do URL requoting on redirection handling.z=session.requote_redirect_url modification is deprecated #2778r)rN)rrrro)rrrcrcrdrhs cCstjdtdd|jS)zSession's loop.z"client.loop property is deprecatedr)r)rrrri)rrcrcrdr|s zClientSession.loopcCs|jS)zTimeout for the session.)rp)rrcrcrdrszClientSession.timeoutcCs|jS)z*The default headers of the client session.)rt)rrcrcrdr~szClientSession.headerscCs|jS)z2Headers for which autogeneration should be skipped)ru)rrcrcrdrszClientSession.skip_auto_headerscCs|jS)z2An object that represents HTTP Basic Authorization)rl)rrcrcrdrszClientSession.authcCs|jS)zJson serializer callable)rn)rrcrcrdrszClientSession.json_serializecCs|jS)z-Should connector be closed on session closing)rk)rrcrcrdrszClientSession.connector_ownercCs|jS)z` Should `ClientResponse.raise_for_status()` be called for each response )rq)rrcrcrdr szClientSession.raise_for_statuscCs|jS)z6Should the body response be automatically decompressed)rr)rrcrcrdrszClientSession.auto_decompresscCs|jS)z Should get proxies information from HTTP_PROXY / HTTPS_PROXY environment variables or ~/.netrc file if present )rs)rrcrcrdrszClientSession.trust_envcCs|jS)z7A list of TraceConfig instances used for client tracing)ry)rrcrcrdr!szClientSession.trace_configscCs d|_dS)zwDetach connector from session without closing the former. Session is switched to closed state anyway. N)rg)rrcrcrddetach&szClientSession.detachcCs tddS)NzUse async with instead) TypeError)rrcrcrd __enter__-szClientSession.__enter__)exc_typeexc_valexc_tbrcCsdS)Nrc)rr3r4r5rcrcrd__exit__0szClientSession.__exit__cs|S)Nrc)rrcrcrd __aenter__9szClientSession.__aenter__cs|IdHdS)N)r)rr3r4r5rcrcrd __aexit__<szClientSession.__aexit__)_r^r_r`__doc__rrrfrrr1r2r6r HttpVersion11rCrr7rAbstractEventLooprQrRr strr>rPrrFrrrraobjectrUr rOintrrr<rrrrrSrVr bytesrWr3rrrrrr rrr*r+r,r-r.r/rpropertyrr{rrrrhsetterr|rr~rrrrrrrrrrrrr0r2rrr6r7r8 __classcell__rcrc)rrdrTsj|V  jj        &  rTc@seZdZdZeddefddddZddddd Zeddd d Z dd d dZ e e defd ddZ e e defd ddZed ddZdS)_BaseRequestContextManager)_coro_respzasyncio.Future[Any]N)cororcCs ||_dS)N)rD)rrFrcrcrdrIsz#_BaseRequestContextManager.__init__)argrcCs |j|S)N)rDr)rrGrcrcrdrLsz_BaseRequestContextManager.sendcCs|j|dS)N)rDthrow)rrGrcrcrdrHOsz _BaseRequestContextManager.throw)rcCs |jS)N)rDr)rrcrcrdrRsz _BaseRequestContextManager.closecCs|j}|S)N)rD __await__)rretrcrcrdrIUs z$_BaseRequestContextManager.__await__cCs|S)N)rI)rrcrcrd__iter__Ysz#_BaseRequestContextManager.__iter__cs|jIdH|_|jS)N)rDrE)rrcrcrdr7\sz%_BaseRequestContextManager.__aenter__)r^r_r` __slots__rrerrrrHrr rrIrKr7rcrcrcrdrCEsrCc@s0eZdZeeeeeeeddddZdS)rN)r3rtbrcs|jdS)N)rEr)rr3rrMrcrcrdr8bs z _RequestContextManager.__aexit__)r^r_r`rrrrr8rcrcrcrdras rc@s0eZdZeeeeeeeddddZdS)r N)r3rrMrcs|jIdHdS)N)rEr)rr3rrMrcrcrdr8qsz"_WSRequestContextManager.__aexit__)r^r_r`rrrrr8rcrcrcrdr ps r c@s^eZdZdZeddefeddddZeddd Ze e e e e e e dd d d Z dS) _SessionRequestContextManager)rDrE_sessionzasyncio.Future[Any]N)rFrrcCs||_d|_||_dS)N)rDrErO)rrFrrcrcrdr~sz&_SessionRequestContextManager.__init__)rcsDy|jIdH|_Wn&tk r8|jIdHYnX|jSdS)N)rDrErrOr)rrcrcrdr7s z(_SessionRequestContextManager.__aenter__)r3rrMrcs,|jdk st|j|jIdHdS)N)rErrrO)rr3rrMrcrcrdr8s z'_SessionRequestContextManager.__aexit__)r^r_r`rLrr2rTrr7rrrrr8rcrcrcrdrNzs  rNrF)rrrr~rrrrrrrrrrrrr}rr{rr|)rrrrrr~rrrrrrrrrrrrr}rr{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|r}rrr{r)rrrr~rrrrrrrrrrrr)r9rTrNr)rrrrrr~rrrrrrrrrrrrr}rr{rr|rrrcrcrdrVs@< rV)r9rrrrrrrrtypesrrtypingrrrrrr 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: cookiejarr;Zhelpersr<r=r>r?r@rArBrCrDrErFrGrHZhttp_websocketrIrJrKrLZstreamsrMtracingrNrOZtypedefsrPrQrRrS__all__rrW ImportErrorr=srUrrerTrCrr rNr:r<rr>r;rVrcrcrcrdsH  T  ,  &  )  %~