/usr/lib/python3.9/site-packages/requests/__pycache__
NameSizeModeActions
adapters.cpython-39.opt-1.pyc225890644editdlrm
adapters.cpython-39.pyc225890644editdlrm
api.cpython-39.opt-1.pyc67110644editdlrm
api.cpython-39.pyc67110644editdlrm
auth.cpython-39.opt-1.pyc82830644editdlrm
auth.cpython-39.pyc82830644editdlrm
certs.cpython-39.opt-1.pyc8320644editdlrm
certs.cpython-39.pyc8320644editdlrm
compat.cpython-39.opt-1.pyc16050644editdlrm
compat.cpython-39.pyc16050644editdlrm
cookies.cpython-39.opt-1.pyc187740644editdlrm
cookies.cpython-39.pyc187740644editdlrm
exceptions.cpython-39.opt-1.pyc51850644editdlrm
exceptions.cpython-39.pyc51850644editdlrm
help.cpython-39.opt-1.pyc26100644editdlrm
help.cpython-39.pyc26100644editdlrm
hooks.cpython-39.opt-1.pyc9420644editdlrm
hooks.cpython-39.pyc9420644editdlrm
models.cpython-39.opt-1.pyc238190644editdlrm
models.cpython-39.pyc238190644editdlrm
packages.cpython-39.opt-1.pyc3610644editdlrm
packages.cpython-39.pyc3610644editdlrm
sessions.cpython-39.opt-1.pyc198160644editdlrm
sessions.cpython-39.pyc198160644editdlrm
status_codes.cpython-39.opt-1.pyc41910644editdlrm
status_codes.cpython-39.pyc41910644editdlrm
structures.cpython-39.opt-1.pyc44120644editdlrm
structures.cpython-39.pyc44120644editdlrm
utils.cpython-39.opt-1.pyc237500644editdlrm
utils.cpython-39.pyc237500644editdlrm
_internal_utils.cpython-39.opt-1.pyc12280644editdlrm
_internal_utils.cpython-39.pyc12540644editdlrm
__init__.cpython-39.opt-1.pyc32890644editdlrm
__init__.cpython-39.pyc34330644editdlrm
__version__.cpython-39.opt-1.pyc5070644editdlrm
__version__.cpython-39.pyc5070644editdlrm
Edit: /usr/lib/python3.9/site-packages/requests/__pycache__/sessions.cpython-39.pyc (19816B)
a ¥/�hzvã@sždZddlZddlZddlZddlmZddlmZddlm Z ddl m Z m Z m Z mZmZddlmZmZmZmZdd lmZmZmZdd lmZmZdd lmZdd lmZm Z m!Z!dd l"m#Z#m$Z$m%Z%m&Z&ddl'm(Z(ddl)m*Z*ddlm+Z+m,Z,m-Z-m.Z.m/Z/m0Z0ddl1m2Z2ddlm3Z3ej4dk�rTz ej5Z6Wne7�yPej8Z6Yn0nejZ6efdd„Z9efdd„Z:Gdd„de;ƒZdS)z• requests.sessions ~~~~~~~~~~~~~~~~~ This module provides a Session object to manage and persist settings across requests (cookies, auth, proxies). éN)Ú timedelta)Ú OrderedDicté)Ú_basic_auth_str)Ú cookielibÚis_py3ÚurljoinÚurlparseÚMapping)Úcookiejar_from_dictÚextract_cookies_to_jarÚRequestsCookieJarÚ merge_cookies)ÚRequestÚPreparedRequestÚDEFAULT_REDIRECT_LIMIT)Ú default_hooksÚ dispatch_hook)Úto_native_string)Úto_key_val_listÚdefault_headersÚ DEFAULT_PORTS)ÚTooManyRedirectsÚ InvalidSchemaÚChunkedEncodingErrorÚContentDecodingError)ÚCaseInsensitiveDict)Ú HTTPAdapter)Ú requote_uriÚget_environ_proxiesÚget_netrc_authÚshould_bypass_proxiesÚget_auth_from_urlÚ rewind_body)Úcodes)ÚREDIRECT_STATIÚwin32cCsp|dur |S|dur|St|tƒr,t|tƒs0|S|t|ƒƒ}| t|ƒ¡dd„| ¡Dƒ}|D] }||=q`|S)zèDetermines appropriate setting for a given request, taking into account the explicit setting on that request, and the setting in the session. If a setting is a dictionary, they will be merged together using `dict_class` NcSsg|]\}}|dur|‘qS©N©)Ú.0ÚkÚvr(r(ú5/usr/lib/python3.9/site-packages/requests/sessions.pyÚ Józ!merge_setting..)Ú isinstancer rÚupdateÚitems)Zrequest_settingZsession_settingÚ dict_classZmerged_settingZ none_keysÚkeyr(r(r,Ú merge_setting2sÿþ r4cCs@|dus| d¡gkr|S|dus0| d¡gkr4|St|||ƒS)z©Properly merges both requests and session hooks. This is necessary because when request_hooks == {'response': []}, the merge breaks Session hooks entirely. NÚresponse)Úgetr4)Z request_hooksZ session_hooksr2r(r(r,Ú merge_hooksQs r7c@s>eZdZdd„Zdd„Zddd „Zd d „Zd d „Zdd„ZdS)ÚSessionRedirectMixincCs,|jr(|jd}tr| d¡}t|dƒSdS)z7Receives a Response. Returns a redirect URI or ``None``ÚlocationÚlatin1Úutf8N)Z is_redirectÚheadersrÚencoder)ÚselfÚrespr9r(r(r,Úget_redirect_targetbs    z(SessionRedirectMixin.get_redirect_targetcCsšt|ƒ}t|ƒ}|j|jkr dS|jdkrL|jdvrL|jdkrL|jdvrLdS|j|jk}|j|jk}t |jd¡df}|s’|j|vr’|j|vr’dS|p˜|S)zFDecide whether Authorization header should be removed when redirectingTÚhttp)éPNÚhttps)i»NFN)r ÚhostnameÚschemeÚportrr6)r>Zold_urlZnew_urlZ old_parsedZ new_parsedZ changed_portZchanged_schemeZ default_portr(r(r,Úshould_strip_authws$ ÿÿ  ÿz&SessionRedirectMixin.should_strip_authFNTc  ksFg} | |¡} t|jƒj} | �rB| ¡} |  |¡| dd…|_z |jWn&tt t fyp|j j dd�Yn0t |jƒ|jkr–td |j¡|d�‚| ¡|  d¡rÆt|jƒ}d t|jƒ| g¡} t| ƒ}|jd krê| rê|j| d �}n |jrö|j} | ¡} |j�st|jt| ƒƒ} nt| ƒ} t| ƒ| _| | |¡|jtjtjfv�rnd }|D]}| j  !|d¡�qRd| _"| j }| !d d¡t#| j$||j ƒt%| j$|j&ƒ|  '| j$¡| (| |¡}| )| |¡| j*du�oÞd |v�pÞd|v}|�rît+| ƒ| }|�r|Vq|j,|f|||||ddœ| ¤Ž}t#|j&| |j ƒ| |¡} |VqdS)zBReceives a Response. Returns a generator of Responses or Requests.rNF)Zdecode_contentzExceeded {} redirects.)r5z//ú:Ú)Úfragment)úContent-Lengthz Content-TypeúTransfer-EncodingZCookierKrL)ÚstreamÚtimeoutÚverifyÚcertÚproxiesÚallow_redirects)-r@r ÚurlrJÚcopyÚappendÚhistoryÚcontentrrÚ RuntimeErrorÚrawÚreadÚlenÚ max_redirectsrÚformatÚcloseÚ startswithÚjoinrrEÚ_replaceÚgeturlÚnetlocrrÚrebuild_methodÚ status_coder$Ztemporary_redirectZpermanent_redirectr<ÚpopÚbodyr Z_cookiesrÚcookiesZprepare_cookiesÚrebuild_proxiesÚ rebuild_authZ_body_positionr#Úsend)r>r?ÚreqrMrNrOrPrQÚyield_requestsZadapter_kwargsZhistrSZprevious_fragmentÚprepared_requestZ parsed_rurlÚparsedZpurged_headersÚheaderr<Z rewindabler(r(r,Úresolve_redirects�s~             þÿùø  z&SessionRedirectMixin.resolve_redirectscCsR|j}|j}d|vr*| |jj|¡r*|d=|jr8t|ƒnd}|durN| |¡dS)zéWhen being redirected we may want to strip authentication from the request to avoid leaking credentials. This method intelligently removes and reapplies authentication where possible to avoid credential loss. Z AuthorizationN)r<rSrGÚrequestÚ trust_envr Z prepare_auth)r>rnr5r<rSZnew_authr(r(r,rjþsz!SessionRedirectMixin.rebuild_authc CsÞ|dur |ni}|j}|j}t|ƒj}| ¡}| d¡}t||d�}|jr||s|t||d�} |  ||  d¡¡} | r||  || ¡d|vrŠ|d=zt ||ƒ\} } Wnt y¸d\} } Yn0|  d¡sÚ| rÚ| rÚt | | ƒ|d<|S)a°This method re-evaluates the proxy configuration by considering the environment variables. If we are redirected to a URL covered by NO_PROXY, we strip the proxy configuration. Otherwise, we set missing proxy keys for this URL (in case they were stripped by a previous redirect). This method also replaces the Proxy-Authorization header where necessary. :rtype: dict NÚno_proxy©rtÚallzProxy-Authorization)NNrC)r<rSr rErTr6r!rsrÚ setdefaultr"ÚKeyErrorr_r) r>rnrQr<rSrEZ new_proxiesrtZ bypass_proxyZenviron_proxiesÚproxyÚusernameÚpasswordr(r(r,ris*        z$SessionRedirectMixin.rebuild_proxiescCsX|j}|jtjkr|dkrd}|jtjkr6|dkr6d}|jtjkrN|dkrNd}||_dS)z‚When being redirected we may want to change the method of the request based on certain specs or browser behavior. ÚHEADÚGETÚPOSTN)Úmethodrer$Z see_otherÚfoundZmoved)r>rnr5rr(r(r,rd<sz#SessionRedirectMixin.rebuild_method)FNTNNF) Ú__name__Ú __module__Ú __qualname__r@rGrqrjrirdr(r(r(r,r8`sÿ n+r8c@s¸eZdZdZgd¢Zdd„Zdd„Zdd„Zd d „Zd+d d„Z dd„Z dd„Z dd„Z d,dd„Z d-dd„Zd.dd„Zdd„Zdd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zd)d*„Zd S)/ÚSessiona€A Requests session. Provides cookie persistence, connection-pooling, and configuration. Basic Usage:: >>> import requests >>> s = requests.Session() >>> s.get('https://httpbin.org/get') Or as a context manager:: >>> with requests.Session() as s: ... s.get('https://httpbin.org/get') ) r<rhÚauthrQÚhooksÚparamsrOrPÚadaptersrMrsr\cCsrtƒ|_d|_i|_tƒ|_i|_d|_d|_d|_ t |_ d|_ t iƒ|_tƒ|_| dtƒ¡| dtƒ¡dS)NFTzhttps://zhttp://)rr<r…rQrr†r‡rMrOrPrr\rsr rhrrˆÚmountr©r>r(r(r,Ú__init__ls  zSession.__init__cCs|Sr'r(rŠr(r(r,Ú __enter__ªszSession.__enter__cGs | ¡dSr')r^)r>Úargsr(r(r,Ú__exit__­szSession.__exit__c Cs²|jpi}t|tjƒst|ƒ}tttƒ|jƒ|ƒ}|j}|jrR|sR|jsRt |j ƒ}t ƒ}|j |j  ¡|j |j|j|jt|j|jtd�t|j|jƒt||jƒ|t|j|jƒd� |S)a‹Constructs a :class:`PreparedRequest ` for transmission and returns it. The :class:`PreparedRequest` has settings merged from the :class:`Request ` instance and those of the :class:`Session`. :param request: :class:`Request` instance to prepare with this session's settings. :rtype: requests.PreparedRequest )r2) rrSÚfilesÚdataÚjsonr<r‡r…rhr†)rhr/rZ CookieJarr rr r…rsr rSrZpreparerÚupperr�r�r‘r4r<rr‡r7r†)r>rrrhZmerged_cookiesr…Úpr(r(r,Úprepare_request°s.  ÿ    ö zSession.prepare_requestNTc Csxt| ¡||||pi||pi||| d� }| |¡}| p8i} | |j| | ||¡}| | dœ}| |¡|j|fi|¤Ž}|S)ax Constructs a :class:`Request `, prepares it and sends it. Returns :class:`Response ` object. :param method: method for the new :class:`Request` object. :param url: URL for the new :class:`Request` object. :param params: (optional) Dictionary or bytes to be sent in the query string for the :class:`Request`. :param data: (optional) Dictionary, list of tuples, bytes, or file-like object to send in the body of the :class:`Request`. :param json: (optional) json to send in the body of the :class:`Request`. :param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`. :param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`. :param files: (optional) Dictionary of ``'filename': file-like-objects`` for multipart encoding upload. :param auth: (optional) Auth tuple or callable to enable Basic/Digest/Custom HTTP Auth. :param timeout: (optional) How long to wait for the server to send data before giving up, as a float, or a :ref:`(connect timeout, read timeout) ` tuple. :type timeout: float or tuple :param allow_redirects: (optional) Set to True by default. :type allow_redirects: bool :param proxies: (optional) Dictionary mapping protocol or protocol and hostname to the URL of the proxy. :param stream: (optional) whether to immediately download the response content. Defaults to ``False``. :param verify: (optional) Either a boolean, in which case it controls whether we verify the server's TLS certificate, or a string, in which case it must be a path to a CA bundle to use. Defaults to ``True``. When set to ``False``, requests will accept any TLS certificate presented by the server, and will ignore hostname mismatches and/or expired certificates, which will make your application vulnerable to man-in-the-middle (MitM) attacks. Setting verify to ``False`` may be useful during local development or testing. :param cert: (optional) if String, path to ssl client cert file (.pem). If Tuple, ('cert', 'key') pair. :rtype: requests.Response ) rrSr<r�r�r‘r‡r…rhr†)rNrR)rr’r”Úmerge_environment_settingsrSr0rk)r>rrSr‡r�r<rhr�r…rNrRrQr†rMrOrPr‘rlZprepZsettingsZ send_kwargsr?r(r(r,rrØs..ö  ÿþ zSession.requestcKs | dd¡|jd|fi|¤ŽS)zåSends a GET request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param \*\*kwargs: Optional arguments that ``request`` takes. :rtype: requests.Response rRTr}©rwrr©r>rSÚkwargsr(r(r,r6$s z Session.getcKs | dd¡|jd|fi|¤ŽS)zéSends a OPTIONS request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param \*\*kwargs: Optional arguments that ``request`` takes. :rtype: requests.Response rRTZOPTIONSr–r—r(r(r,Úoptions/s zSession.optionscKs | dd¡|jd|fi|¤ŽS)zæSends a HEAD request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param \*\*kwargs: Optional arguments that ``request`` takes. :rtype: requests.Response rRFr|r–r—r(r(r,Úhead:s z Session.headcKs|jd|f||dœ|¤ŽS)aÈSends a POST request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param data: (optional) Dictionary, list of tuples, bytes, or file-like object to send in the body of the :class:`Request`. :param json: (optional) json to send in the body of the :class:`Request`. :param \*\*kwargs: Optional arguments that ``request`` takes. :rtype: requests.Response r~)r�r‘©rr)r>rSr�r‘r˜r(r(r,ÚpostEs z Session.postcKs|jd|fd|i|¤ŽS)auSends a PUT request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param data: (optional) Dictionary, list of tuples, bytes, or file-like object to send in the body of the :class:`Request`. :param \*\*kwargs: Optional arguments that ``request`` takes. :rtype: requests.Response ZPUTr�r›©r>rSr�r˜r(r(r,ÚputRs z Session.putcKs|jd|fd|i|¤ŽS)awSends a PATCH request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param data: (optional) Dictionary, list of tuples, bytes, or file-like object to send in the body of the :class:`Request`. :param \*\*kwargs: Optional arguments that ``request`` takes. :rtype: requests.Response ZPATCHr�r›r�r(r(r,Úpatch^s z Session.patchcKs|jd|fi|¤ŽS)zèSends a DELETE request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param \*\*kwargs: Optional arguments that ``request`` takes. :rtype: requests.Response ZDELETEr›r—r(r(r,ÚdeletejszSession.deletec Ks†| d|j¡| d|j¡| d|j¡| d|j¡t|tƒrJtdƒ‚| dd¡}|  d¡}|j }|j |j d�}t ƒ}|j|fi|¤Ž}t ƒ|} t| d �|_td ||fi|¤Ž}|jrÚ|jD]} t|j| j| jƒqÂt|j||jƒ|�r|j||fi|¤Ž} d d „| Dƒ} ng} | �r8|  d |¡|  ¡}| |_|�svz"t|j||fddi|¤Žƒ|_Wnt�ytYn0|�s‚|j|S)zISend a given PreparedRequest. :rtype: requests.Response rMrOrPrQz#You can only send PreparedRequests.rRT)rS)Zsecondsr5cSsg|]}|‘qSr(r()r)r?r(r(r,r-§r.z Session.send..rrm)rwrMrOrPrQr/rÚ ValueErrorrfr6r†Ú get_adapterrSÚpreferred_clockrkrÚelapsedrrVr rhrrrYrqÚinsertÚnextZ_nextÚ StopIterationrW) r>rrr˜rRrMr†ÚadapterÚstartÚrr¤r?ÚgenrVr(r(r,rktsF       "z Session.sendc Cs¬|jrn|dur| d¡nd}t||d�}| ¡D]\}} | || ¡q0|dusV|durntj d¡pltj d¡}t||jƒ}t||j ƒ}t||j ƒ}t||j ƒ}||||dœS)z^ Check the environment and merge it with some settings. :rtype: dict NrtruTZREQUESTS_CA_BUNDLEZCURL_CA_BUNDLE)rOrQrMrP) rsr6rr1rwÚosÚenvironr4rQrMrOrP) r>rSrQrMrOrPrtZ env_proxiesr*r+r(r(r,r•¿s    ÿ    ÿz"Session.merge_environment_settingscCs@|j ¡D]"\}}| ¡ | ¡¡r |Sq td |¡ƒ‚dS)z~ Returns the appropriate connection adapter for the given URL. :rtype: requests.adapters.BaseAdapter z*No connection adapters were found for {!r}N)rˆr1Úlowerr_rr])r>rSÚprefixr¨r(r(r,r¢Üs zSession.get_adaptercCs|j ¡D] }| ¡q dS)z+Closes all adapters and as such the sessionN)rˆÚvaluesr^)r>r+r(r(r,r^êsz Session.closecs>||jˆ<‡fdd„|jDƒ}|D]}|j |¡|j|<q"dS)zwRegisters a connection adapter to a prefix. Adapters are sorted in descending order by prefix length. cs g|]}t|ƒtˆƒkr|‘qSr()r[)r)r*©r¯r(r,r-õr.z!Session.mount..N)rˆrf)r>r¯r¨Z keys_to_mover3r(r±r,r‰ïs z Session.mountcs‡fdd„ˆjDƒ}|S)Ncsi|]}|tˆ|dƒ“qSr')Úgetattr)r)ÚattrrŠr(r,Ú ûr.z(Session.__getstate__..)Ú __attrs__)r>Ústater(rŠr,Ú __getstate__úszSession.__getstate__cCs"| ¡D]\}}t|||ƒqdSr')r1Úsetattr)r>r¶r³Úvaluer(r(r,Ú __setstate__þszSession.__setstate__)NNNNNNNTNNNNNN)NN)N)N)r�r‚rƒÚ__doc__rµr‹rŒrŽr”rrr6r™ršrœržrŸr rkr•r¢r^r‰r·rºr(r(r(r,r„Ss0>)ý L    K r„cCstƒS)aZ Returns a :class:`Session` for context-management. .. deprecated:: 1.0.0 This method has been deprecated since version 1.0.0 and is only kept for backwards compatibility. New code should use :class:`~requests.sessions.Session` to create a session. This may be removed at a future date. :rtype: Session )r„r(r(r(r,Úsessions r¼)?r»r¬ÚsysÚtimeZdatetimerÚ collectionsrr…rÚcompatrrrr r rhr r r rZmodelsrrrr†rrZ_internal_utilsrZutilsrrrÚ exceptionsrrrrZ structuresrrˆrrrr r!r"r#Z status_codesr$r%ÚplatformÚ perf_counterr£ÚAttributeErrorZclockr4r7Úobjectr8r„r¼r(r(r(r,ÚsB             t3