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

248 lines
27 KiB
Plaintext
Raw Normal View History

2025-06-23 17:55:02 -05:00
Ë
�»Yhwãó¨—dZddlZddlZddlZddlmZddlmZddlm Z ddl
m Z ddl m
Z
dd lmZmZmZmZdd
lmZmZmZmZdd lmZmZmZmZdd lmZmZdd
l m!Z!m"Z"m#Z#m$Z$ddl%m&Z&ddl'm(Z(ddl)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3ejhdk(r
ejjZ6n ejZ6efd„Z7efd„Z8Gd„d«Z9Gd„de9«Z:d„Z;y)z•
requests.sessions
~~~~~~~~~~~~~~~~~
This module provides a Session object to manage and persist settings across
requests (cookies, auth, proxies).
éN)Ú OrderedDict)Ú timedeltaé)Úto_native_string)Ú HTTPAdapter)Ú_basic_auth_str)ÚMappingÚ 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)Ú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Úwin32có—|€|S|€|St|t«rt|t«s|S|t|««}|jt|««|j «D��cgc]
\}}|�Œ |‘Œ }}}|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`
)Ú
isinstancer r&ÚupdateÚitems)Úrequest_settingÚsession_settingÚ
dict_classÚmerged_settingÚkÚvÚ none_keysÚkeys úZ/mnt/c/fieldcraft/witness-fracture/.venv/lib/python3.12/site-packages/requests/sessions.pyÚ
merge_settingr5=s¤€ð ÐØÐàÐØÐô �?¤GÔ,´¸OÌWÔ1UàÐá¤°Ó @ÓA€NØ×Ñœ/¨/Ó:Ô;ð"0×!5Ñ!5Ó!7×E‘v˜˜1¸1¹9’ÐE€IÑEØò ˆØ ˜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)Úgetr5)Ú
request_hooksÚ
session_hooksr.s r4Ú merge_hooksr;[sO€ð Р
× 1Ñ 1°*Ó =ÀÒ CØÐàР
× 1Ñ 1°*Ó =ÀÒ CØÐä ˜¨
°zÓ BÐBócó>—eZdZd„Zd„Z dd„Zd„Zd„Zd„Zy) ÚSessionRedirectMixincót—|jr,|jd}|jd«}t|d«Sy)z7Receives a Response. Returns a redirect URI or ``None``ÚlocationÚlatin1Úutf8N)Ú is_redirectÚheadersÚencoder)ÚselfÚrespr@s r4Úget_redirect_targetz(SessionRedirectMixin.get_redirect_targetks;€ð × Ò Ø—|‘| JÑ/ˆHð —‘ xÓ0ˆHÜ# H¨fÓ5Ð 5Ør<cóÊ—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)éPNÚhttps)i»NFN)r ÚhostnameÚschemeÚportrr8)rFÚold_urlÚnew_urlÚ
old_parsedÚ
new_parsedÚ changed_portÚchanged_schemeÚ default_ports r4Úshould_strip_authz&SessionRedirectMixin.should_strip_authsØ€ä˜gÓ&ˆ
ܘgÓ&ˆ
Ø × Ñ  *×"5Ñ"5Ò 5Øð
× Ñ  Ò 'Ø—‘ :Ñ-Ø×!Ñ! WÒ,Ø—‘ ;Ñ.àð"—‘¨*¯/©/Ñ9ˆ Ø#×*Ñ*¨j×.?Ñ.?Ñ?ˆÜ%×)Ñ)¨*×*;Ñ*;¸TÓBÀDÐIˆ áØ—‘ <Ñ/Ø—‘ <Ñ/àðÒ-˜~Ð-r<Nc
+óÜK—g}
|j|«} t|j«j} | �rü|j «}
|
j |«|
dd|_ |jt|j «|jk\rtd|j›d�|¬«‚|j!«| j#d«r;t|j«}d j%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«tE|
jF||j«tI|
jF|jJ«|
jM|
jF«|jO|
|«}|jQ|
|«|
jRduxr
d|vxsd|v}|r tU|
«|
}|r|–—nP|jV|f|||||ddœ| ¤Ž}tE|jJ|
|j«|j|«} |–—| r�Œûyy#tttf$r |jjd¬«Y�ŒøwxYw­w)zBReceives a Response. Returns a generator of Responses or Requests.rNF)Údecode_contentz Exceeded z redirects.)r7z//ú:Ú)Úfragment)úContent-Lengthz Content-TypeúTransfer-EncodingÚCookier]r^)ÚstreamÚtimeoutÚverifyÚcertÚproxiesÚallow_redirects),rHr Úurlr\ÚcopyÚappendÚhistoryÚcontentrrÚ RuntimeErrorÚrawÚreadÚlenÚ
max_redirectsrÚcloseÚ
startswithÚjoinrrNÚ_replaceÚgeturlÚnetlocr r"Úrebuild_methodÚ status_coderÚtemporary_redirectÚpermanent_redirectrDÚpopÚbodyrÚ_cookiesrÚcookiesÚprepare_cookiesÚrebuild_proxiesÚ rebuild_authÚ_body_positionr$Úsend)rFrGÚreqr`rarbrcrdÚyield_requestsÚadapter_kwargsÚhistrfÚprevious_fragmentÚprepared_requestÚ parsed_rurlÚparsedÚpurged_headersÚheaderrDÚ
rewindables r4Úresolve_redirectsz&SessionRedirectMixin.resolve_redirectsŸs2èø€ðˆà×&Ñ& tÓ,ˆÜ$ S§W¡WÓ-×6Ñ6ÐÚØ"Ÿx™x›zÐ ð
�K‰K˜Ô Ø  ˜8ˆDŒLð
4Ø— ’ ô�4—<‘<Ó  D×$6Ñ$6Ò6Ü&Ø × 2Ñ 2Ð3°;Ð?È$ôðð
�J‰JŒLð�~‰~˜dÔ#Ü& t§x¡xÓ0� Ø—h‘hÔ 0°×1CÑ1CÓ DÀcÐJÓK�ô˜c“]ˆFØ�‰ "Ò$Ñ):ØŸ™Ð2C˜ÓD‘Ø—’Ø$*§O¡OÐ!Ø—-‘-“/ˆCð
—=’=ܘdŸh™h¬ °CÓ(8Ó9‘ä! #Ó&�ä#3°CÓ#8Ð Ô à × Ñ Ð 0°$Ô 7ð×ÑÜ×(Ñ(Ü×(Ñ(ð(ñð
"Y�Ø,ò?�FØ$×,Ñ,×0Ñ0°¸Õ>ð?à(,Ð Ô%à&×.Ñ.ˆGØ �K‰K˜ $Ô 'ô
#Ð#3×#<Ñ#<¸cÀ4Ç8Á8Ô LÜ Ð*×3Ñ3°T·\±\Ô BØ × ,Ñ ,Ð-=×-FÑ-FÔ Gð×*Ñ*Ð+;¸WÓEˆGØ × Ñ Ð.°Ô 5ð
*×8Ñ8ÀÐDòØ  GÐ+ÒMÐ/BÀgÐ/Mð
ñ
ÜÐ,Ô-ð#ˆCáØ“ à �t—y‘yØð à!Ø#Ø!ØØ#Ø$)ñ ð%ñ �ô' t§|¡|Ð5EÀtÇxÁxÔPð×.Ñ.¨tÓ4�Ø’
õOøô)Ô*>Ä ÐMò
4Ø—‘—
‘
¨U�
×3ð
4üs1‚A!M,Á$ L5Á0KM,Ì3M,Ì50M)Í%M,Í(M)Í)M,cóè—|j}|j}d|vr)|j|jj|«r|d=|jr 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)rDrfrWÚrequestÚ trust_envr!Ú prepare_auth)rFrˆr7rDrfÚnew_auths r4r€z!SessionRedirectMixin.rebuild_authsw€ð
#×*Ñ*ˆØ×"Ñ"ˆà ˜gÑ %¨$×*@Ñ*@Ø × Ñ × Ñ  #ô+
ð
˜Ð(ð+/¯.ª.”> #Ô&¸dˆØ Ð Ø × )Ñ )¨(Õ 3ð r<có,—|j}t|j«j}t |||j
«}d|vr|d= t
||«\}}|jd«s|r|rt||«|d<|S#t$rd\}}YŒ6wxYw)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
zProxy-Authorization©NNrL)
rDr rfrNr#r’rÚKeyErrorrqr)rFrˆrdrDrNÚ new_proxiesÚusernameÚpasswords r4rz$SessionRedirectMixin.rebuild_proxies.sª€ð#×*Ñ*ˆÜÐ*×.Ñ.Ó/×6Ñ6ˆÜ%Ð&6¸ÀÇÁÓPˆ à  GÑ +ØÐ-Ð.ð ,Ü!2°;¸vÑ3FÓ!GÑ ˆH�hð × Ñ  Ô)©h¹8Ü-<¸XÀxÓ-PˆGÐ)Ñ *àÐøôò ,Ø!+Ñ ˆH’hð ,úsÁ BÂBÂBcó—|j}|jtjk(r|dk7rd}|jtjk(r|dk7rd}|jtj
k(r|dk(rd}||_y)z‚When being redirected we may want to change the method of the request
based on certain specs or browser behavior.
ÚHEADÚGETÚPOSTN)ÚmethodrwrÚ see_otherÚfoundÚmoved)rFrˆr7rŸs r4rvz#SessionRedirectMixin.rebuild_methodMsx€ð"×(Ñ(ˆð × Ñ ¤5§?¡?Ò 2°vÀÒ7G؈Fð × Ñ ¤5§;¡;Ò .°6¸VÒ3C؈Fð × Ñ ¤5§;¡;Ò .°6¸VÒ3C؈Fà"(ÐÕr<)FNTNNF) Ú__name__Ú
__module__Ú __qualname__rHrWrŽr€rrv©r<r4r>r>js7„òò(.ðHØØØ
ØØóyòv4ò(ó>)r<r>có®—eZdZdZgd¢Zd„Zd„Zd„Zd„Z dd„Z d „Z
d
„Z d „Z dd „Z
dd
„Zdd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zy)Ú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]>
) rDr}ÚauthrdÚhooksÚparamsrbrcÚadaptersr`r’rocó^—t«|_d|_i|_t «|_i|_d|_d|_d|_ t|_ d|_ ti«|_t«|_|j#dt%««|j#dt%««y)NFTzhttps://zhttp://)rrDr©rdrrªr«r`rbrcrror’rr}rr¬Úmountr©rFs r4Ú__init__zSession.__init__†s›€ô'Ó(ˆŒ ðˆŒ ð
ˆŒ ô#“_ˆŒ
ð
ˆŒ ðˆŒ ðˆŒ ðˆŒ ô 4ˆÔðˆŒô +¨2Ó.ˆŒ ô$›
ˆŒ
Ø �
‰
�:œ{›}Ô-Ø �
‰
�9œk›mÕ,r<có—|S©Nr¦r¯s r4Ú __enter__zSession.__enter__Ãs€Øˆ r<có$—|j«yr²)rp)rFÚargss r4Ú__exit__zSession.__exit__Æs €Ø �
‰
� r<cóè—|jxsi}t|tj«s t |«}t t t
«|j«|«}|j}|jr#|s!|jst|j«}t«}|j|jj«|j|j|j |j"t%|j&|j&t(¬«t%|j*|j*«t%||j«|t-|j.|j.«¬«
|S)a‹Constructs 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
)r.)
rŸrfÚfilesÚdataÚjsonrDr«r©r}rª)r}r)r
Ú CookieJarrrr
r©r’r!rfrÚpreparerŸÚupperr¸r¹rºr5rDrr«r;rª)rFr‘r}Úmerged_cookiesr©Úps r4Úprepare_requestzSession.prepare_requestÉs€ð—/‘/Ò' Rˆô˜'¤9×#6Ñ#6Ô7Ü)¨'Ó2ˆGô'Ü Ô+Ó-¨t¯|©|Ó <¸gó
ˆð
�|‰|ˆØ �>Š>¡$¨t¯yªyÜ! '§+¡+Ó.ˆDä Ó ˆØ � ‰ Ø—>‘>×'Ñ'Ó)Ø— ‘ Ø—-‘-Ø—‘Ø—‘Ü!Ø—‘ §¡Ô:Môô! §¡°·±Ó=ܘt T§Y¡YÓ/Ø"ܘgŸm™m¨T¯Z©ZÓ8ð ô
ðˆr<Nc ó—t|j«||||xsi||xsi||| ¬«
}|j|«}| 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 long 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
)
rŸrfrDr¸r¹rºr«r©r}rª)rare)rr½rÀÚmerge_environment_settingsrfr*r‚)rFrŸrfr«r¹rDr}r¸r©rarerdrªr`rbrcrºrƒÚprepÚsettingsÚ send_kwargsrGs r4r‘zSession.requestôs®€ô~Ø—<‘<“>ØØØØ’˜ØØ’<˜RØØØô 
ˆð×#Ñ# CÓ(ˆà’-˜Rˆà×2Ñ2Ø �H‰H�g˜v v¨tó
ˆð Ø.ñ
ˆ ð ×ј8Ô$؈t�y‰y˜Ñ- Ñ-ˆàˆ r<c óN—|jdd«|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
reTr�©Ú
setdefaultr‘©rFrfÚkwargss r4r8z Session.getQs-€ð ×ÑÐ+¨TÔ2؈t�|‰|˜E 3Ñ1¨&Ñ1Ð1r<c ó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
reTÚOPTIONSrÇrÉs r4ÚoptionszSession.options\s-€ð ×ÑÐ+¨TÔ2؈t�|‰|˜I sÑ5¨fÑ5Ð5r<c ó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
reFrœrÇrÉs r4Úheadz Session.headgs-€ð ×ÑÐ+¨UÔ3؈t�|‰|˜F CÑ2¨6Ñ2Ð2r<c ó0—|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º©r‘)rFrfr¹rºrÊs r4Úpostz Session.postrs#€ðˆt�|‰|˜F CÐH¨d¸ÑHÀÑHÐHr<c ó.—|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¹rÑ©rFrfr¹rÊs r4Úputz Session.puts!€ðˆt�|‰|˜E 3Ñ<¨TÐ<°VÑ<Ð<r<c ó.—|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¹rÑrÕs r4Úpatchz
Session.patch‹s!€ðˆt�|‰|˜G SÑ>¨tÐ>°vÑ>Ð>r<c ó*—|jd|fi|¤ŽS)zèSends a DELETE request. Returns :class:`Response` object.