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

224 lines
28 KiB
Plaintext
Raw Normal View History

Ë
j-Tã ódZddlmZddlZddlZddlZddlmZmZddl m
Z
m Z m Z ddl
mZmZmZmZddlmZdd lmZdd
lmZmZmZmZer dd lmZdd lmZddl Z Gd
d«Z!Gdd«Z" d!dZ#d"dZ$ d# d$dZ%Gdde&«Z'Gdde ee(e(dzf«Z)d%dZ*d&dZ+d'dZ,ede ¬«Z-e d( d)d«Z.e d* d+d«Z. d( d,dZ. d-d „Z/y).z²
requests.cookies
~~~~~~~~~~~~~~~~
Compatibility code to be able to use `http.cookiejar.CookieJar` with requests.
requests.utils imports from here, so be careful with imports.
é)Ú annotationsN)ÚIteratorÚMutableMapping)ÚCookieÚ CookieJarÚ CookiePolicy)Ú
TYPE_CHECKINGÚAnyÚTypeVarÚoverloadé)Úto_native_string)Ú is_prepared)ÚMorselÚ cookielibÚurlparseÚ
urlunparse)ÚSupportsKeysAndGetItem)ÚPreparedRequestcó¬eZdZUdZded<ddZddZddZddZddZ dd „Z
dd
Z ddd Z dd
Z
ddZddZedd«Zedd«Zedd«Zy )Ú MockRequestaÿWraps a `requests.PreparedRequest` to mimic a `urllib2.Request`.
The code in `http.cookiejar.CookieJar` expects this interface in order to correctly
manage cookie policies, i.e., determine whether a cookie can be set, given the
domains of the request and the cookie.
The original request object is read-only. The client is responsible for collecting
the new headers via `get_new_headers()` and interpreting them appropriately. You
probably want `get_cookie_header`, defined below.
ÚstrÚtypecó–t|«sJ||_i|_t|jj«j
|_y©N)Ú _is_preparedÚ_rÚ _new_headersrÚurlÚschemer)ÚselfÚrequests úS/home/antigravity/intellecton/venv/lib/python3.12/site-packages/requests/cookies.pyÚ__init__zMockRequest.__init__-s9ܘˆŒØ,.ˆÔܘTŸW™WŸ[™[Ó ócó|jSr)r©r!s r#Úget_typezMockRequest.get_type3s Øy‰yÐr%cóTt|jj«jSr)rrrÚnetlocr's r#Úget_hostzMockRequest.get_host6sܘŸŸ Ó+r%có"|j«Sr©r+r's r#Úget_origin_req_hostzMockRequest.get_origin_req_host9sØ}‰}Ðr%có„|jjjd«s|jjSt |jjdd¬«}t |jj«}t
|j||j|j|j|jg«S)Hostzutf-8)Úencoding) rÚheadersÚgetrrrrr ÚpathÚparamsÚqueryÚfragment)r!ÚhostÚparseds r#Ú get_full_urlzMockRequest.get_full_url<sðw‰w×" —77—;‘;Ð ä §¡§¡°Ñ 7À'ÔJˆÜ˜$Ÿ'™'Ÿ+™+Ó&ˆäà
ØØ Ø
Ø Øð

ó 
ð
r%cóy©NT©r's r#Úis_unverifiablezMockRequest.is_unverifiablePsØr%cóR||jjvxs||jvSr)rr2r©r!Únames r#Ú
has_headerzMockRequest.has_headerSs%Øt—ww—ÐC¨$°$×2CÑ2CÐ*CÐCr%Ncó‚|jjj||jj||««Sr)rr2r3r)r!rAÚdefaults r#Ú
get_headerzMockRequest.get_headerVs0Øw‰w×" ×):Ñ):×)>Ñ)>¸tÀWÓ)MÓNr%cótd«)zMcookiejar has no legitimate use for this method; add it back if you find one.z=Cookie headers should be added with add_unredirected_header())ÚNotImplementedError)r!ÚkeyÚvals r#Ú
add_headerzMockRequest.add_headerYsä 
ð
r%có"||j|<yr©r©r!rAÚvalues r#Úadd_unredirected_headerz#MockRequest.add_unredirected_header_sØ"'ˆ×јr%có|jSrrLr's r#Úget_new_headerszMockRequest.get_new_headersbsØ× Ñ Ð r%có"|j«Sr)r>r's r#Ú unverifiablezMockRequest.unverifiableesà×%r%có"|j«Sr)r.r's r#Úorigin_req_hostzMockRequest.origin_req_hostisà×)r%có"|j«Srr-r's r#r8zMockRequest.hostmsà}‰}Ðr%)r"rÚreturnÚNone)rWr©rWÚbool)rArrWrZr)rArrDú
str | NonerWr[)rHrrIrrWrX)rArrNrrWrX)rWzdict[str, str])Ú__name__Ú
__module__Ú __qualname__Ú__doc__Ú__annotations__r$r(r+r.r:r>rBrErJrOrQÚpropertyrSrUr8r=r%r#rrñ ð ƒIó óó
ó(óDôOó
ó òðòðòóñr%rcó(eZdZdZddZddZddZy) Ú MockResponsezÅWraps a `httplib.HTTPMessage` to mimic a `urllib.addinfourl`.
...what? Basically, expose the parsed HTTP headers from the server response
the way `http.cookiejar` expects to see them.
có||_y)z†Make a MockResponse for `cookiejar` to read.
:param headers: a httplib.HTTPMessage or analogous carrying the headers
Ú_headers)r!r2s r#r$zMockResponse.__init__ys ð
 ˆ
r%có|jSrrer's r#ÚinfozMockResponse.info€s Ø}‰}Ðr%có:|jj|«yr)rfÚ
getheadersr@s r#rjzMockResponse.getheadersƒsØ
× Ñ  Õ&r%N)r2r
rWrX)rWr
)rArrWr
)r\r]r^r_r$rhrjr=r%r#rcrcrsñó  óô'r%rccó®t|d«r |jsyt|«}t|jj«}|j ||«y)zñExtract the cookies from the response into a CookieJar.
:param jar: http.cookiejar.CookieJar (not necessarily a RequestsCookieJar)
:param request: our own requests.Request object
:param response: urllib3.HTTPResponse object
Ú_original_responseN)ÚhasattrrlrrcÚmsgÚextract_cookies)Újarr"ÚresponseÚreqÚress r#Úextract_cookies_to_jarrtsJô
 3¸×8SÒ8SØä

€Cä
x×2×
7€CØ×ј˜SÕ!r%cóxt|«}|j|«|j«jd«S)zj
Produce an appropriate Cookie header string to be sent with `request`, or None.
:rtype: str
r)rÚadd_cookie_headerrQr3)rpr"Úrs r#Úget_cookie_headerrxs6ô €AØ×ј!ÔØ × Ñ Ó × "  ,r%cóg}|D]h}|j|k7rŒ|||jk7rŒ%|||jk7rŒ7|j|j|j|jf«Œj|D]\}}}|j |||«Œy)zkUnsets a cookie by name, by default over all domains and paths.
Wraps CookieJar.clear(), is O(n).
N)rAÚdomainr4ÚappendÚclear)Ú cookiejarrArzr4Ú
clearablesÚcookies r#Úremove_cookie_by_namer€¤ð.0€JØòEˆØ ;‰;˜$Ò Ø Ø Ð  &¨F¯M©MÒ"9Ø Ø Ð  ¨¯ © Ò 3Ø Ø×ј6Ÿ=™=¨&¯+©+°v·{±{ÐEðˆ˜  dÕ,r%cóeZdZdZy)ÚCookieConflictErrorz£There are two cookies that meet the criteria specified in the cookie jar.
Use .get and .set and include domain and path args in order to be more specific.
N)r\r]r^r_r=r%r#rr¹sòr%rcóleZdZUdZded< d ddZ ddZd dZd!dZd"dZ d#d „Z
d$d
Z d%d Z d!d Z
d!d
Zd&dZ d' d(dZd)ˆfd Zd*ˆfd Zd+dZ d,dZd-dZd.ˆfd Z d/ˆfd Z d' d0dZ d' d1dZd2dZd3dZd4dZd5dZˆxZS)6ÚRequestsCookieJara¶Compatibility class; is a http.cookiejar.CookieJar, but exposes a dict
interface.
This is the CookieJar we create by default for requests and sessions that
don't specify one, since some clients may expect response.cookies and
session.cookies to support dict operations.
Requests does not use the dict interface internally; it's just for
compatibility with external client code. All requests code should work
out of the box with externally provided instances of ``CookieJar``, e.g.
``LWPCookieJar`` and ``FileCookieJar``.
Unlike a regular CookieJar, this class is pickleable.
.. warning:: dictionary operations that are normally O(1) may be O(n).
rÚ_policycóL |j|||«S#t$r|cYSwxYw)zãDict-like get() that also supports optional domain and path args in
order to resolve naming collisions from using one cookie jar over
multiple domains.
.. warning:: operation is O(n), not O(1).
)Ú_find_no_duplicatesÚKeyError)r!rArDrzr4s r#r3zRequestsCookieJar.getÓs0ð Ø×+¨D°&¸ ?øÜò ØŠNð ús  #¢#c óÚ|€.t|||jd«|jd«¬«yt|t«r t |«}n
t ||fi|¤Ž}|j
|«|S)z°Dict-like set() that also supports optional domain and path args in
order to resolve naming collisions from using one cookie jar over
multiple domains.
Nrzr4)rzr4)r€r3Ú
isinstancerÚmorsel_to_cookieÚ
create_cookieÚ
set_cookie)r!rArNÚkwargsÚcs r#ÚsetzRequestsCookieJar.setåsgð ˆ d 6§:¡:¨hÓ#7¸f¿j¹jÈÓ>Põ
ð
ä eœVÔ   Ó'‰Aä˜d 4¨VÑ4ˆAØ ˜Ô؈r%c#óHKt|«D]}|jŒy­w)z”Dict-like iterkeys() that returns an iterator of names of cookies
from the jar.
.. seealso:: itervalues() and iteritems().
N)ÚiterrA©r!rs r#ÚiterkeyszRequestsCookieJar.iterkeysús%èø€ô ˜4“jò ˆFØ—+‘+Ó ñ ùó "có4t|j««S)zƒDict-like keys() that returns a list of names of cookies from the
jar.
.. seealso:: values() and items().
)Úlistr”r's r#ÚkeyszRequestsCookieJar.keyssô D—MM“OÓ$r%c#óHKt|«D]}|jŒy­w)z•Dict-like itervalues() that returns an iterator of values of cookies
from the jar.
.. seealso:: iterkeys() and iteritems().
N)rrNr“s r#Ú
itervalueszRequestsCookieJar.itervalues s%èø€ô ˜4“jò ˆFØ—,‘,Ó ñ ùr•có4t|j««S)z„Dict-like values() that returns a list of values of cookies from the
jar.
.. seealso:: keys() and items().
)r—r's r#ÚvalueszRequestsCookieJar.valuessô D—O&r%c#ó`Kt|«D]}|j|jfŒy­w)z•Dict-like iteritems() that returns an iterator of name-value tuples
from the jar.
.. seealso:: iterkeys() and itervalues().
N)rrArNr“s r#Ú iteritemszRequestsCookieJar.iteritemss.èø€ô ˜4“jò ,ˆFØ—+‘+˜vŸ|™|Ð  ,ùs,.có4t|j««S)zõDict-like items() that returns a list of name-value tuples from the
jar. Allows client-code to call ``dict(RequestsCookieJar)`` and get a
vanilla python dict of key value pairs.
.. seealso:: keys() and values().
)r—r's r#ÚitemszRequestsCookieJar.items%sôD—N%r%có~g}t|«D],}|j|vsŒ|j|j«Œ.|S)z2Utility method to list all the domains in the jar.©rrzr{©r!Údomainsrs r#Ú list_domainszRequestsCookieJar.list_domains.s=àˆÜ˜4“jò .ˆFØ}‰} GÒ˜vŸ}™}Õˆr%có~g}t|«D],}|j|vsŒ|j|j«Œ.|S)z0Utility method to list all the paths in the jar.)rr4r{)r!Úpathsrs r#Ú
list_pathszRequestsCookieJar.list_paths6s=àˆÜ˜4“jò *ˆ{‰{  ˜VŸ[™[Õˆ r%có–g}t|«D]9}|j|j|vry|j|j«Œ;y)zvReturns True if there are multiple domains in the jar.
Returns False otherwise.
:rtype: bool
TFr¢s r#Úmultiple_domainsz"RequestsCookieJar.multiple_domains>sIð  ˆÜ˜4“jò *ˆFØ}‰}Ð(¨V¯]©]¸gÑ-EÙØ N‰N˜6Ÿ=™=Õ r%có¤i}t|«D]?}||j|k(sŒ||j|k(sŒ'|j||j<ŒA|S)z¾Takes as an argument an optional domain and path and returns a plain
old Python dict of name-value pairs of cookies that meet the
requirements.
:rtype: dict
)rrzr4rNrA)r!rzr4Ú
dictionaryrs r#Úget_dictzRequestsCookieJar.get_dictKsVð-/ˆ
ܘ4“jò 7ˆ &§-¡-°6Ó"9Ø  § ¡ ¨tÓ 3à*0¯,©,
˜6Ÿ;™;Ò
Ðr%có t|«S)zDRequestCookieJar's __iter__ comes from CookieJar not MutableMapping.)ÚsuperÚ__iter__)r!Ú __class__s €r#zRequestsCookieJar.__iter__\sø€ä‰wÑÓ!r%cóB t||«S#t$rYywxYwr<)Ú __contains__r)r!rAs €r#zRequestsCookieJar.__contains__`s*ø€ð ÜÓ -øÜ Ùð ús ƒcó$|j|«S)zÿDict-like __getitem__() for compatibility with client code. Throws
exception if there are more than one cookie with name. In that case,
use the more explicit get() method instead.
.. warning:: operation is O(n), not O(1).
)r‡r@s r#Ú __getitem__zRequestsCookieJar.__getitem__fsð×Ó-r%có(|j||«y)zÓDict-like __setitem__ for compatibility with client code. Throws
exception if there is already a cookie of that name in the jar. In that
case, use the more explicit set() method instead.
N)rrMs r#Ú __setitem__zRequestsCookieJar.__setitem__osð
r%cót||«y)zqDeletes a cookie given a name. Wraps ``http.cookiejar.CookieJar``'s
``remove_cookie_by_name()``.
N)r€r@s r#Ú __delitem__zRequestsCookieJar.__delitem__xsô ˜d )r%có¸|jx}9|jd«r(|jd«r|jdd«|_t ||g|¢­i|¤ŽS)"z\"Ú)rNÚ
startswithÚendswithÚreplacer¯r)r!rÚargsrŽrNs €r#rzRequestsCookieJar.set_cookie~sXø€à—l
"ˆ × Ñ  Ô˜sÔ Ÿ=™=¨°Ó3ˆFŒL܉wÑ! :¨4Ò:°6Ñ:r%có°t|tj«r,|D]&}|jt j|««Œ(yt
||«y)zAUpdates this jar with cookies from another CookieJar or dict-likeN)rrrÚcopyr¯Úupdate)r!Úotherrs €r#zRequestsCookieJar.update‡sGø€ô eœY× ò
3ؤ§ ¡ ¨&Ó 1Õ

‰G‰N˜ !r%cóÌt|«D]C}|j|k(sŒ||j|k(sŒ%||j|k(sŒ7|jcSt d|d|d|«)Requests uses this method internally to get cookie values.
If there are conflicting cookies, _find arbitrarily chooses one.
See _find_no_duplicates if you want an exception thrown if there are
conflicting cookies.
:param name: a string containing name of cookie
:param domain: (optional) string containing domain of cookie
:param path: (optional) string containing path of cookie
:return: cookie.value
úname=ú , domain=ú, path=)rrArzr4rNrˆ)r!rArzr4rs r#Ú_findzRequestsCookieJar._findsmô˜4“jò ,ˆ{‰{˜> V§]¡]°fÓ%<Ø| v§{¡{°dÓ':Ø%Ÿ|™|Ò ˜˜t˜h i°¨z¸ÀÀÐJr%cóöd}t|«D]R}|j|k(sŒ||j|k(sŒ%||j|k(sŒ7|t d|«|j
}ŒT||St
d|d|d|«)Both ``__get_item__`` and ``get`` call this function: it's never
used elsewhere in Requests.
:param name: a string containing name of cookie
:param domain: (optional) string containing domain of cookie
:param path: (optional) string containing path of cookie
:raises KeyError: if cookie is not found
:raises CookieConflictError: if there are multiple cookies
that match name and optionally domain and path
:return: cookie.value
Nz&There are multiple cookies with name, rÆ)rrArzr4rrNrˆ)r!rArzr4ÚtoReturnrs r#r‡z%RequestsCookieJar._find_no_duplicates§sðˆÜ˜4“jò
0ˆ{‰{˜> V§]¡]°fÓ%<Ø| v§{¡{°dÓ':Ø/ä"5Ø"HÈÈÐ Qó#ðð$*§<¡<™ð
 Р؈Oܘ˜t˜h i°¨z¸ÀÀÐJr%có\|jj«}|jd«|S)ú4Unlike a normal CookieJar, this class is pickleable.Ú
_cookies_lock)Ú__dict__rÂÚpop©r!Ústates r#Ú __getstate__zRequestsCookieJar.__getstate__Æs%à
×$ˆà
ˆ r%cóŠ|jj|«d|jvrtj«|_yy)N)Ú threadingÚRLockrÎs r#Ú __setstate__zRequestsCookieJar.__setstate__Ís4à
×јUÔ  $§-¡-Ñ /Ü!*§¡Ó!2ˆ ð 0r%cózt«}|j|j««|j|«|S)z(Return a copy of this RequestsCookieJar.)r„Ú
set_policyÚ
get_policyrÃ)r!Únew_cjs r#zRequestsCookieJar.copyÓs0ä$ˆØ×ј$Ÿ/™/Ó
؈
r%có|jS)z&Return the CookiePolicy instance used.)r…r's r#zRequestsCookieJar.get_policyÚs à|‰|Ðr%)NNN)
rArrDr[rzr[r4r[rWr[)rArrNú#str | Morsel[dict[str, str]] | NonerŽr
rWz
Cookie | None)rWz
Iterator[str])rWz list[str])rWzIterator[str | None])rWzlist[str | None])rWz Iterator[tuple[str, str | None]])rWzlist[tuple[str, str | None]]rY©NN)rzr[r4r[rWzdict[str, str | None])rWzIterator[Cookie])rAÚobjectrWrZ)rArrWr[)rArrNrWrX)rArrWrX)rrr
r
rWrX)z,CookieJar | SupportsKeysAndGetItem[str, str]rWrX)rArrzr[r4r[rWr[)rArrzr[r4r[rWr)rWúdict[str, Any])rWrX)rWr„)rWr)r\r]r^r_r`r3rr”r˜r r­rr‡Ú
__classcell__)s@r#r„r„¿s†ø…ñð"Óð
ð àððððð ð
ð ð
ó
ð$ØðØ CðØORðà óó*óóóó ð=AðØ ðØ/9ðà óõ"ó ØðØ Cðà
óó 
õHLðKØðKØ!+ðKØ:DðKà óKð.HLðKØðKØ!+ðKØ:DðKà óKó>ó ÷r%r„cóØ|yt|dd«x}r|«Stj|«}|j«|D]&}|jtj|««Œ(|S)NrÂ)ÚgetattrrÂr|r)rpÚ copy_methodÚnew_jarrs r#Ú_copy_cookie_jarræßsgØ
€{Øä˜c 6¨4Ó0€{Ћ}Ðäi‰i˜‹n€GØ ‡MM„OØòØ×Ñœ4Ÿ9™9 VÓ €Nr%c ófd||ddddddddddiddœ
}t|«t|«z