Files
intellecton/venv/lib/python3.12/site-packages/requests/__pycache__/sessions.cpython-312.pyc
T

272 lines
31 KiB
Plaintext
Raw Normal View History

Ë
jÈ…ãóBdZddlmZddlZddlZddlZddlmZddlm Z m
Z
m Z ddl m
Z
ddlmZmZmZdd lmZdd
lmZdd lmZdd lmZdd
lmZmZmZddlm Z m!Z!m"Z"m#Z#ddl$m%Z%m&Z&m'Z'm(Z(ddl)m*Z*m+Z+ddl,m-Z-m.Z.m/Z/m0Z0m1Z1ddl2m3Z3ddl4m5Z5ddl6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@erddlAmBZBddlCmDZDmEZEddlFmZGddlmHZHejdk(r
ej”ZKn ej
ZKef d!dZLef d"dZMGdd«ZNGddeN«ZOd#d „ZPy)$z•
requests.sessions
~~~~~~~~~~~~~~~~~
This module provides a Session object to manage and persist settings across
requests (cookies, auth, proxies).
é)Ú annotationsN)Ú OrderedDict)Ú GeneratorÚMappingÚMutableMapping)Ú timedelta)Ú
TYPE_CHECKINGÚAnyÚcasté)Úto_native_string)Ú is_prepared)Ú HTTPAdapter)Ú_basic_auth_str)Ú cookielibÚurljoinÚurlparse)ÚRequestsCookieJarÚcookiejar_from_dictÚextract_cookies_to_jarÚ
merge_cookies)ÚChunkedEncodingErrorÚContentDecodingErrorÚ
InvalidSchemaÚTooManyRedirects)Ú
default_hooksÚ
dispatch_hook)ÚDEFAULT_REDIRECT_LIMITÚREDIRECT_STATIÚPreparedRequestÚRequestÚResponse)Úcodes)ÚCaseInsensitiveDict)
Ú
DEFAULT_PORTSÚdefault_headersÚget_auth_from_urlÚget_environ_proxiesÚget_netrc_authÚ requote_uriÚresolve_proxiesÚ rewind_bodyÚshould_bypass_proxiesÚto_key_val_list)Ú CookieJar)ÚSelfÚUnpack)Ú_types)Ú BaseAdapterÚwin32có||S||St|t«rt|t«s|S|t|««}|jt|««|j «Dcgc]
\}}|Œ |Œ }}}|D]}||=Œ|Scc}}w)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`
)Ú
isinstancerr.ÚupdateÚitems)Úrequest_settingÚsession_settingÚ
dict_classÚmerged_settingÚvÚ none_keysÚkeys úT/home/antigravity/intellecton/venv/lib/python3.12/site-packages/requests/sessions.pyÚ
merge_settingrBLðÐØÐàÐØÐô ?¤GÔ¸OÌWÔ1UàÐá¤°Ó @ÓA€NØ×Ñœ/¨/Ó"0×!5Ñ!5Ó!7×Ev˜˜1¸1¹9’ÐE€IÑò ˆØ ˜3Ñ ð ð Ðùó Fs Á)
BÁ4Bcó|||jd«gk(r|S||jd«gk(r|St|||«S)z©Properly merges both requests and session hooks.
This is necessary because when request_hooks == {'response': []}, the
merge breaks Session hooks entirely.
Úresponse)ÚgetrB)Ú
request_hooksÚ
session_hooksr;s rAÚ merge_hooksrHlsOðР
× 1Ñ 1°*Ó =ÀÒ CØÐàР
× 1Ñ 1°*Ó =ÀÒ CØÐä ˜¨
°zÓ có¼eZdZUded<ded<ded<ddZddZdd „Z d dd Z dd Z dd
Z ddZ
y
)ÚSessionRedirectMixinÚintÚ
max_redirectsÚboolÚ trust_envrÚcookiesc óy©)ÚselfÚrequestÚkwargss rAÚsendzSessionRedirectMixin.send„srIcót|jr,|jd}|jd«}t|d«Sy)z7Receives a Response. Returns a redirect URI or ``None``ÚlocationÚlatin1Úutf8N)Ú is_redirectÚheadersÚencoder
)rTÚresprYs rAÚget_redirect_targetz(SessionRedirectMixin.get_redirect_target†s;ð × Ò Ø—|‘| JÑ/ˆHð xÓ0ˆ# H¨fÓ rIcóÊt|«}t|«}|j|jk7ry|jdk(r,|jdvr|jdk(r|jdvry|j|jk7}|j|jk7}t j
|jd«df}|s|j|vr|j|vry|xs|S)zFDecide whether Authorization header should be removed when redirectingTÚhttp)éPhttps)NFN)rÚhostnameÚschemeÚportr%rE)rTÚold_urlÚnew_urlÚ
old_parsedÚ
new_parsedÚ changed_portÚchanged_schemeÚ default_ports rAÚshould_strip_authz&SessionRedirectMixin.should_strip_authšä˜&ˆ
ܘ&ˆ
Ø × Ñ  *×"5Ñ"5Ò ð
× Ñ  Ò  :Ñ×! WÒ ;Ñð"—¨*¯/©/Ñ9ˆ Ø*¨j×.?Ñ.?Ñ?ˆÜ%×)¨*×*;Ñ*;¸TÓBÀDÐIˆ áØ <Ñ <ÑðÒ-˜-rINc
+óÌKg}
|j|«} t|j«j} | rô|j «}
|
dd|_|
j
|« |jt|j
«|jk\rtd|jd|¬«|j!«| j#d«r;t|j«}dj%t'|j(«| g«} t| «}|jd k(r| r|j+| ¬
«}n|jr |j} |j-«} |j.s t1|jt3| ««} n t3| «} t'| «|
_|j5|
|«|j6t8j:t8j<fvr,d }|D]}|
j>jA|d«Œ d|
_!|
j>}|jAd d«tEd
|
jF«}tI|||j«tK||jL«|
jO|«|jQ|
|«}|jS|
|«|
jTduxr
d|vxsd|v}|r tW|
«|
}|r|nP|jX|f|||||ddœ| ¤Ž}tI|jL|
|j«|j|«} || rŒóyy#tttf$r |jjd¬«YŒðwxYw­w)zBReceives a Response. Returns a generator of Responses or Requests.NF)Údecode_contentz Exceeded z redirects.)rDz//ú)Úfragment)úContent-Lengthz Content-TypeúTransfer-EncodingÚCookier/rurv)ÚstreamÚtimeoutÚverifyÚcertÚproxiesÚallow_redirects)-r`rÚurlrtÚcopyÚhistoryÚappendÚcontentrrÚ RuntimeErrorÚrawÚreadÚlenrMrÚcloseÚ
startswithÚjoinr
rfÚ_replaceÚgeturlÚnetlocrr*Úrebuild_methodÚ status_coder#Útemporary_redirectÚpermanent_redirectr]ÚpopÚbodyr Ú_cookiesrrrPÚprepare_cookiesÚrebuild_proxiesÚ rebuild_authÚ_body_positionr,rW)rTr_Úreqrxryrzr{r|Úyield_requestsÚadapter_kwargsÚhistr~Úprevious_fragmentÚprepared_requestÚ parsed_rurlÚparsedÚpurged_headersÚheaderr]Ú
cookie_jarÚ
rewindables rAÚresolve_redirectsz&SessionRedirectMixin.resolve_redirectsºs.èø€ð "ˆà×& ,ˆÜ$ S§W¡WÓ-×ÚØ"Ÿx™x›zР𠡘7ˆDŒLØ K‰K˜Ô ð
 ô4—<  D×$6Ñ$6Ò × 2Ñ 2Ð3°;Ð?È$ôðð
J‰JŒLð~‰~˜& t§x¡xÓ0 Ø—hhÔ 0°×1CÑ1CÓ DÀcÐKô˜c“]ˆ "Ò$Ñ):ØŸÐ2C˜ÓD‘ØØ$*§O¡OЗ-‘-“/ˆCð
—=’=ܘdŸh™h¬ °CÓ(8Ó9ä! &ä#3°CÓ#8Ð Ô à × Ñ Ð 0°$Ô ×ÑÜ××(ñð
"YØ?$×,׸Õ?à(,Ð Ô&×.ˆ K‰K˜ 
˜kÐ+;×+DÑ+DÓEˆ " :¨s°D·H±HÔ ˜* d§l¡lÔ × ,¨ZÔ ×*Ð+;¸WÓEˆGØ × Ñ ÐÔ
ÐØ  MÐ/BÀgÐ/Mð
ñ
ÜÐ#ˆCáØ“ à t—y‘yØð àØ#Ø$)ñ ð ô' t§|¡|Ð5EÀtÇxÁxÔ×.¨tÓ4Ø
õOøô)Ô*>Ä Ð

¨U
×
4üs1A!M$Á$ L-Á0J9M$Ì+M$Ì-0M!ÍM$Í M!Í!M$có$|j}t|«sJt|«sJ|j}|j}|j}d|vr|j ||«r|d=|j
r t
|«nd}||j|«yy)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.
Ú
AuthorizationN)rUÚ _is_preparedr]r~rorOr)Ú prepare_auth)rTrrDÚoriginal_requestr]Ú original_urlr~Únew_auths rArz!SessionRedirectMixin.rebuild_auth5sð$×ÜÐÐ"×*ˆØ'×+ˆ Ø×"ˆà ˜ %¨$×*@Ñ*@ÀÈsÔ*Sð˜Ð+/¯.ª.”> &¸dˆØ Ð Ø × )¨(Õ  rIcóFt|«sJ|j}t|j«j}t |||j «}d|vr|d= t||«\}}|jd«s|r|rt||«|d<|S#t$rd\}}YŒ6wxYw)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
zProxy-Authorization©NNrd) r]rr~rfr+rOr'ÚKeyErrorrˆr)rTrr|r]rfÚ new_proxiesÚusernameÚpasswords rAr•z$SessionRedirectMixin.rebuild_proxiesNô Ð"×*ˆÜÐ*×/×Ü%Ð&6¸ÀÇÁÓ à  GÑ Ð ,Ü!2°;¸vÑ3FÓ!GÑ ˆH × Ñ  Ô)©h¹8Ü-<¸XÀxÓ-Pˆ Ðøôò ,Ø!+Ñ ˆH’hð ,úsÁBÂB ÂB có|j}|jtjk(r|dk7rd}|jtjk(r|dk7rd}|jtj
k(r|dk(rd}||_y)zWhen being redirected we may want to change the method of the request
based on certain specs or browser behavior.
ÚHEADÚGETÚPOSTN)ÚmethodrŽr#Ú see_otherÚfoundÚmoved)rTrrDs rArz#SessionRedirectMixin.rebuild_methodrsxð "×ð × Ñ ¤5§?¡?Ò 2°vÀÒ7G؈Fð × Ñ ¤5§;¡;Ò .°6¸VÒ3C؈Fð × Ñ ¤5§;¡;Ò .°6¸VÒ3C؈Fà"(ÐÕrI©rUr rVr
Úreturnr")r_r"z
str | None)rhÚstrrirN)FNTNNF)r_r"r˜r rxrNryú_t.TimeoutTyperzú
_t.VerifyTyper{ú _t.CertTyper|údict[str, str] | Noner™rNr
zGenerator[Response, None, None])rr rDr"ÚNone)rr r|údict[str, str]) Ú__name__Ú
__module__Ú __qualname__Ú__annotations__rWr`rorr•rrSrIrArKrKsØÓ؃OØ
Óãó(.ðHØ"&Ø $Ø Ø)-Øyàðyððyðð yð
 ð yð ð
yððyðyððyððyð
yðv4Ø /ð4Ø;Cð
ó4ð2"à"ð"ð
ó "ðH)Ø /ð)Ø;Cð
ô)rIrKcóúeZdZUdZded<ded<ded<ded <d
ed <d ed
<ded<ded<ded<d ed<ded<ded<gd¢Zded<d0dZd1dZd2dZd3dZ d4 d5d!„Z
d6 d7d"„Z d8d#„Z d8d$„Z
d9 d:d%„Z d6 d;d&„Z d6 d;d'„Zd8d(„Zd<d)„Z d=d*„Zd>d+„Zd0d,„Zd?d-„Zd@d.„ZdAd/„Zy )BÚSessiona€A Requests session.
Provides cookie persistence, connection-pooling, and configuration.
Basic Usage::
>>> import requests
>>> s = requests.Session()
>>> s.get('https://httpbin.org/get')
<Response [200]>
Or as a context manager::
>>> with requests.Session() as s:
... s.get('https://httpbin.org/get')
<Response [200]>
zCaseInsensitiveDict[str]r]ú _t.AuthTypeÚauthrÂr|zdict[str, list[_t.HookType]]ÚhookszMutableMapping[str, Any]ÚparamsrNrxrzr¿r{rLrMrOrrPz MutableMapping[str, BaseAdapter]Úadapters) r]rPr|rzr{rxrOrMz list[str]Ú __attrs__có^t«|_d|_i|_t «|_i|_d|_d|_d|_ t|_ d|_ ti«|_t«|_|j#dt%««|j#dt%««y)NFTzhttps://zhttp://)r&r]r|rrxrzr{rrMrOrrPrÚmountr©rTs rAÚ__init__zSession.__init__ºsôŒ ðˆŒ ð
ˆŒ ô#“_ˆŒ
ð
ˆŒ ðˆŒ ðˆŒ ðˆŒ ô ÔðˆŒô +¨2ÓŒ ô$›
ˆŒ
Ø
:œ{
9œk,rIcó|SrRrSs rAÚ __enter__zSession.__enter__ùs؈ rIcó$|j«yrR)r‡)rTÚargss rAÚ__exit__zSession.__exit__üs Ø
rIcó td|j«}tt|j«}|jxsi}t |t j«s t|«}ttt«|j«|«}|j}|jr|s|js t|«}t«}|j|j!«||j"|j$|j&t)|j*|j*t,¬«t)|j.|j.«t)||j«|t1|j2|j2«¬«
|S)aConstructs a :class:`PreparedRequest <PreparedRequest>` for
transmission and returns it. The :class:`PreparedRequest` has settings
merged from the :class:`Request <Request>` instance and those of the
:class:`Session`.
:param request: :class:`Request` instance to prepare with this
session's settings.
:rtype: requests.PreparedRequest
ú
_t.UriType)r;)
r~ÚfilesÚdataÚjsonr]rP)r r~rPr6rr/rrrrOr)r ÚprepareÚupperrÚrBr]r$rH)rTrUr~rPÚmerged_cookiesrÊÚps rAÚprepare_requestzSession.prepare_requestÿs"ô< §¡Ó-ˆÜ”c˜7Ÿ>™>Ó*ˆà—/' Rˆô˜'¤9×#6Ñ#6Ô)¨'Ó2ˆ Ô-¨t¯|©|Ó <¸
ˆð
|‰|ˆØ >Š>¡$¨t¯yªyÜ! &ˆ Ó ˆØ ‰ Ø—<<“>ØØ—-‘-ØØÜ §¡Ô:Môô§¡°·±Ó˜t T§Y¡YÓ˜gŸm™m¨T¯Z©ZÓ ô
ðˆrINc óvt|t«r|jd«}t|j «||||xsi||xsi||| ¬«
}|j |«}t
|«sJ| xsi} |j|j| |
||«}| |
dœ}|j|«|j|fi|¤Ž}|S)a
Constructs a :class:`Request <Request>`, prepares it and sends it.
Returns :class:`Response <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 many seconds to wait for the server to send
data before giving up, as a float, or a :ref:`(connect timeout,
read timeout) <timeouts>` 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 hooks: (optional) Dictionary mapping hook name to one event or
list of events, event must be callable.
: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
zutf-8)
r~r]rP)ryr}) r6ÚbytesÚdecoder!Úmerge_environment_settingsr~r7rW)rTr~r]rPryr}r|rxrzr{r˜ÚprepÚsettingsÚ send_kwargsr_s rArUzSession.request-ô| cœ5Ô —*‘*˜%ˆØ—<<“>ØØØØ˜ØØ’<˜RØØØô 
ˆð×# CÓä˜DÔ’-˜Rˆà× H‰Hg˜v v¨tó
ˆð Ø
ˆ ð ×ј8Ôˆty‰y˜ÑÑàˆ rIc óR|jdd«|jd|fd|i|¤ŽS)aiSends a GET request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param params: (optional) Dictionary, list of tuples or bytes to send
in the query string for the :class:`Request`.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
r}Tr´©Ú
setdefaultrU)rTr~rVs rArEz Session.gets2ð ×ÑÐ+¨TÔˆt|‰|˜E @¨vÐ@¸Ñ@rIc óN|jdd«|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
r}OPTIONSrê©rTr~rVs rAÚoptionszSession.options¡s-ð ×ÑÐ+¨TÔˆt|‰|˜I 5¨fÑ5rIc óN|jdd«|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
r}Fr³s rAÚheadz Session.head¬s-ð ×ÑÐ+¨UÔˆt|‰|˜F 2¨6Ñ2rIc ó0|jd|f||dœ|¤ŽS)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
)©rU)rTr~rVs rAÚpostz Session.post·s#ð"ˆt|‰|˜F H¨d¸ÑÑHrIc ó.|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
ÚPUTrÛ©rTr~rVs rAÚputz Session.putÊs!ðˆt|‰|˜E <¨TÐ<°VÑ<rIc ó.|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
ÚPATCHrÛs rAÚpatchz
Session.patchØs!ðˆt|‰|˜G >¨tÐ>°vÑ>rIc ó*|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
ÚDELETErós rAÚdeletezSession.deleteæsðˆt|‰|˜H 4¨VÑ4rIc ó€|jd|j«|jd|j«|jd|j«d|vr$t ||j
|j «|d<t|t«r td«t|«sJ|jdd«}|jd«}|j}|j|j¬«}t!«}|j"|fi|¤Ž}t!«|z
} t%| ¬ «|_t)d
||fi|¤Ž}|j*r<|j*D]-}
t-|j.|
j0|