*j U(SrSSKrSSKrSSKr/SQrSR rSR rSR r"SS\ 5r \R\R-S -r \ S -r\"\"S 55\"\"\\55- Vs0sH nUS U-_M snr\R)\"S 5S\"S5S05 \R*"S\R,"\ 5-5R.r\R*"S5rSrSr\R*"S5R8rSrSr/SQr /SQr!S\ \!4Sjr""SS\#5r$Sr%\%S-r&\R*"S\%-S -\&-S!-\RN\RP-5r)"S"S#\#5r*"S$S%\*5r+gs snf)&a% Here's a sample session to show how to use this module. At the moment, this is the only documentation. The Basics ---------- Importing is easy... >>> from http import cookies Most of the time you start by creating a cookie. >>> C = cookies.SimpleCookie() Once you've created your Cookie, you can add values just as if it were a dictionary. >>> C = cookies.SimpleCookie() >>> C["fig"] = "newton" >>> C["sugar"] = "wafer" >>> C.output() 'Set-Cookie: fig=newton\r\nSet-Cookie: sugar=wafer' Notice that the printable representation of a Cookie is the appropriate format for a Set-Cookie: header. This is the default behavior. You can change the header and printed attributes by using the .output() function >>> C = cookies.SimpleCookie() >>> C["rocky"] = "road" >>> C["rocky"]["path"] = "/cookie" >>> print(C.output(header="Cookie:")) Cookie: rocky=road; Path=/cookie >>> print(C.output(attrs=[], header="Cookie:")) Cookie: rocky=road The load() method of a Cookie extracts cookies from a string. In a CGI script, you would use this method to extract the cookies from the HTTP_COOKIE environment variable. >>> C = cookies.SimpleCookie() >>> C.load("chips=ahoy; vienna=finger") >>> C.output() 'Set-Cookie: chips=ahoy\r\nSet-Cookie: vienna=finger' The load() method is darn-tootin smart about identifying cookies within a string. Escaped quotation marks, nested semicolons, and other such trickeries do not confuse it. >>> C = cookies.SimpleCookie() >>> C.load('keebler="E=everybody; L=\\"Loves\\"; fudge=;";') >>> print(C) Set-Cookie: keebler="E=everybody; L=\"Loves\"; fudge=;" Each element of the Cookie also supports all of the RFC 2109 Cookie attributes. Here's an example which sets the Path attribute. >>> C = cookies.SimpleCookie() >>> C["oreo"] = "doublestuff" >>> C["oreo"]["path"] = "/" >>> print(C) Set-Cookie: oreo=doublestuff; Path=/ Each dictionary element has a 'value' attribute, which gives you back the value associated with the key. >>> C = cookies.SimpleCookie() >>> C["twix"] = "none for you" >>> C["twix"].value 'none for you' The SimpleCookie expects that all values should be standard strings. Just to be sure, SimpleCookie invokes the str() builtin to convert the value to a string, when the values are set dictionary-style. >>> C = cookies.SimpleCookie() >>> C["number"] = 7 >>> C["string"] = "seven" >>> C["number"].value '7' >>> C["string"].value 'seven' >>> C.output() 'Set-Cookie: number=7\r\nSet-Cookie: string=seven' Finis. N) CookieError BaseCookie SimpleCookiez;  c\rSrSrSrg)rN)__name__ __module__ __qualname____firstlineno____static_attributes__r 3/opt/alt/python313/lib64/python3.13/http/cookies.pyrrsrrz!#$%&'*+-.^_`|~:z ()/<=>?@[]{}z\%03o"z\"\z\\z[%s]+z[\x00-\x1F\x7F]c&[SU55$)z`Detects control characters within a value. Supports any type, as header values can be any type. c3^# UH#n[R[U55v M% g7fN)_control_character_researchstr).0vs r )_has_control_character..s#AS$++CF33Ss+-)any)vals r_has_control_characterr!s ASA AArcbUb[U5(aU$SUR[5-S-$)zQuote a string for use in a cookie header. If the string does not need to be double-quoted, then just return the string. Otherwise, surround the string in doublequotes and quote (with a \) special characters. r) _is_legal_key translate _Translatorrs r_quoter's1 {mC(( S]];//#55rz\\(?:([0-3][0-7][0-7])|(.))cPUS(a[[USS55$US$)N)chrint)ms r_unquote_replacer/s't3qtQ<  t rc|Ub[U5S:aU$USS:wd USS:waU$USSn[[U5$)Nr+rrr))len _unquote_subr/r&s r_unquoter4sO {c#hl  1v}B3 a)C (# ..r)MonTueWedThuFriSatSun) NJanFebMarAprMayJunJulAugSepOctNovDecc \SSKJnJn U"5nU"XP-5u pgpppnSXXUXiX4-$)Nr)gmtimetimez#%s, %02d %3s %4d %02d:%02d:%02d GMT)rJrI)future weekdayname monthnamerIrJnowyearmonthdayhhmmsswdyzs r_getdaterXsE! &C-3CL-A*D"" 0 OSE"2Db E FFrc \rSrSrSrSSSSSSS S S S . rS S1rSr\S5r \S5r \S5r Sr S#Sjr Sr\R rSrSrSrSrSrSrSrS$Sjr\rSrS#S jrS#S!jr\"\R>5r S"r!g)%Morsela/A class to hold ONE (key, value) pair. In a cookie, each such pair may have several attributes, so this class is used to keep the attributes associated with the appropriate key,value pair. This class also includes a coded_value attribute, which is used to hold the network representation of the value. expiresPathCommentDomainzMax-AgeSecureHttpOnlyVersionSameSite) r\pathcommentdomainmax-agesecurehttponlyversionsamesiterhricS=Ul=UlUlURHn[R XS5 M g)Nr)_key_value _coded_value _reserveddict __setitem__)selfkeys r__init__Morsel.__init__s86:: :DK$"3>>C   T +"rcUR$r)rmrss rrt Morsel.key s yyrcUR$r)rnrxs rvalue Morsel.value$s {{rcUR$r)rorxs r coded_valueMorsel.coded_value(s   rcUR5nXR;a[SU<35e[X5(a[SU<SU<35e[R XU5 gNzInvalid attribute .Control characters are not allowed in cookies r)lowerrprr!rqrr)rsKVs rrrMorsel.__setitem__,s\ GGINN";< < !! ' ' NqeSTUVTYZ[ [ !$rNcUR5nXR;a[SU<35e[X5(a[SU<SU<35e[R XU5$r)rrprr!rq setdefault)rsrtr s rrMorsel.setdefault4sSiik nn $=> > !# + +WZ\_ab bt#..rc"[U[5(d[$[R X5=(aY UR UR :H=(a9 UR UR :H=(a URUR:H$r) isinstancerZNotImplementedrq__eq__rnrmrorsmorsels rr Morsel.__eq__<sk&&))! ! D)9 v}},9 V[[(9!!V%8%88 :rc[5n[RX5 URRUR5 U$r)rZrqupdate__dict__rs rcopy Morsel.copyFs0 F!t}}- rc 0n[U5R5HZup4UR5nX0R;a[ SU<35e[ X45(a[ SU<SU<35eXBU'M\ [R X5 gr)rqitemsrrprr!r)rsvaluesdatartr s rr Morsel.updateLsV **,HC))+C..(!C"ABB%c//!#--0G1SG#=>>I- Drc(URU5 U$r)r)rsrs r__ior__Morsel.__ior__Xs F rc<UR5UR;$r)rrp)rsrs r isReservedKeyMorsel.isReservedKey\swwyDNN**rcUR5UR;a[SU<35e[U5(d[SU<35e[ XU5(a[SU<SU<SU<35eXlX lX0lg)NzAttempt to set a reserved key z Illegal key rr)rrprr#r!rmrnro)rsrtr coded_vals rset Morsel.set_su 99;$.. (CIJ JS!!#78 8 !#I 6 6LOQTV_ac c  %rcJURURURS.$)N)rtr{r~)rmrnrorxs r __getstate__Morsel.__getstate__ms#99[[,,  rcUSnUSnUSn[X#U5(a[SU<SU<SU<35eX lX0lX@lg)Nrtr{r~rr)r!rrmrnro)rsstatertr{r~s r __setstate__Morsel.__setstate__tsdElgM* !#k : :N!$q ;/CD D  'rc2U<SURU5<3$)Nr) OutputString)rsattrsheaders routput Morsel.outputs $"3"3E":;;rc\SURR<SUR5<S3$)N<: >) __class__r rrxs r__repr__Morsel.__repr__s !^^44d6G6G6IJJrcSSKnURU5n[U5(a [S5eURR USSS9nSU<S3$)Nr-Control characters are not allowed in cookiesrzutf-8)safeencodingzq ) urllib.parserr!rparsequote)rsrurllib output_stringoutput_encodeds r js_outputMorsel.js_outputsX))%0 !- 0 0MN N ++MW+U   rc$/nURnU"UR<SUR<35 Uc URn[ UR 55nUGH&upVUS:XaMXQ;aMUS:Xa<[ U[5(a'U"URU<S[U5<35 MWUS:Xa1[ U[5(aU"SURUU4-5 MUS:Xa<[ U[5(a'U"URU<S[U5<35 MXPR;a+U(a!U"[URU55 GMGM U"URU<SU<35 GM) [U5$)N=rr\rgz%s=%dre) appendrtr~rpsortedrrr-rXrr'_flags_semispacejoin)rsrresultrrrtr{s rrMorsel.OutputStringsB $((D$4$456 =NNEtzz|$JC{iJuc$:$:$.."5xGH !j&<&<w$.."5u!==> !j&<&<$.."5ve}EF #3t~~c234$.."5u=> $f%%r)rormrnr)N Set-Cookie:)"r r r r__doc__rprrupropertyrtr{r~rrrrobject__ne__rrrrrrrr__str__rrr classmethodtypes GenericAlias__class_getitem__rr rrrZrZs* I #F,!!%/:]]F  + &  (<GK "&B$E$6$67rrZz,\w\d!#%&'~_`><@,:/\$\*\+\-\.\^\|\)\(\?\}\{\=z\[\]z \s* # Optional whitespace at start of cookie (?P # Start of group 'key' [ax]+? # Any word of at least one letter ) # End of group 'key' ( # Optional group: there may not be a value. \s*=\s* # Equal Sign (?P # Start of group 'val' "(?:[^\\"]|\\.)*" # Any double-quoted string | # or # Special case for "expires" attr (\w{3,6}day|\w{3}),\s # Day of the week or abbreviated day [\w\d\s-]{9,11}\s[\d:]{8}\sGMT # Date and time in specific format | # or [a-]* # Any word or empty string ) # End of group 'val' )? # End of optional value group \s* # Any number of spaces. (\s+|;|$) # Ending either at space, semicolon, or EOS. cj\rSrSrSrSrSrSSjrSrSr SS jr \ r S r SS jr S r\4S jrSrg)riz'A container class for a set of Morsels.cX4$)zreal_value, coded_value = value_decode(STRING) Called prior to setting a cookie's value from the network representation. The VALUE is the value read from HTTP header. Override this function to modify the behavior of cookies. r rsr s r value_decodeBaseCookie.value_decodes xrc[U5nX"4$)zreal_value, coded_value = value_encode(VALUE) Called prior to setting a cookie's value from the dictionary representation. The VALUE is the value being assigned. Override this function to modify the behavior of cookies. r&rsr strvals r value_encodeBaseCookie.value_encodes S~rNc6U(aURU5 ggr)load)rsinputs rruBaseCookie.__init__s  IIe  rcURU[55nURXU5 [R XU5 g)z+Private method for setting a cookie's valueN)getrZrrqrr)rsrt real_valuer~Ms r__setBaseCookie.__sets2 HHS&( # c{+ A&rc[U[5(a[RXU5 gUR U5up4UR XU5 g)zDictionary style assignment.N)rrZrqrrr_BaseCookie__set)rsrtr{rvalcvals rrrBaseCookie.__setitem__s? eV $ $   T .**51JD JJs$ 'rc/n[UR55nUHBupgURX5n[U5(a [ S5eUR U5 MD UR U5$)z"Return a string suitable for HTTP.r)rrrr!rrjoin) rsrrseprrrtr{ value_outputs rrBaseCookie.outputsetzz|$JC <<6L%l33!"QRR MM, '  xxrc/n[UR55nUH0up4URU<S[UR5<35 M2 SUR R <S[U5<S3$)Nrrrr)rrrreprr{rr _spacejoin)rslrrtr{s rrBaseCookie.__repr__sV tzz|$JC HHT%++%67 8 !^^44jmDDrc/n[UR55nUH%upEURURU55 M' [ U5$)z(Return a string suitable for JavaScript.)rrrr _nulljoin)rsrrrrtr{s rrBaseCookie.js_outputsCtzz|$JC MM%//%0 1   rc[U[5(aURU5 gUR5H up#X0U'M g)zLoad cookies from a string (presumably HTTP_COOKIE) or from a dictionary. Loading cookies from a dictionary 'd' is equivalent to calling: map(Cookie.__setitem__, d.keys(), d.values()) N)rr_BaseCookie__parse_stringr)rsrawdatartr{s rrBaseCookie.load$sB gs # #    ( &mmo !S .rc2Sn[U5n/nSnSnSnSUs=::aU:Ga5O GO1URX5n U (dGOU RS5U RS5pU RS5nU SS:Xa U(dMpUR XzSSU 45 OU R 5[ R;a_U(dgU c7U R 5[ R;aUR XzS45 OGgUR Xz[U 545 O)U b%UR XURU 545 SnOgSUs=::a U:aGM/O Sn UH7upn X:Xa U ceXU 'MX:XdeU upURXU5 X n M9 g) NrFr)r+rtr $T) r2matchgroupendrrrZrprr4rr)rsrpattin parsed_items morsel_seenTYPE_ATTRIBUTE TYPE_KEYVALUErrtr{rtprrs r__parse_stringBaseCookie.__parse_string2s  H   1jqjjJJs&EU+U[[-? ! A1v}"##^We$DE 0 00"=yy{fmm3$++^$,GH ''huo(NO"##]9J9J59Q$RS" E1jqjjJ *NBU#}$}#***"  3d+I+rr r)Nrz )r r r rrrrrurrrrrrrr_CookiePatternrrr rrrrsD1' (  GE! (6:rrc$\rSrSrSrSrSrSrg)rioz SimpleCookie supports strings as cookie values. When setting the value using the dictionary assignment notation, SimpleCookie calls the builtin str() to convert the value to a string. Values received from HTTP are kept as strings. c[U5U4$r)r4rs rrSimpleCookie.value_decodevs}c!!rc2[U5nU[U54$r)rr'rs rrSimpleCookie.value_encodeysSvf~%%rr N)r r r rrrrrr rrrros "&rr),rrestringr__all__rrrr Exceptionr ascii_lettersdigits _LegalChars_UnescapedCharsrrangemapordr%rcompileescape fullmatchr#rr!r'subr3r/r4 _weekdayname _monthnamerXrqrZ_LegalKeyChars_LegalValueCharsASCIIVERBOSErrr)rs0rr+sNXz 7 GG  XX  ) """V]]25GG /E#J#c#.G*HHJH1(Q,HJ HeIv  7RYY{%;;<FF  #56B 6zz89==  /6A 8 <:FD8TD8`B!G+      & BJJ ' 2LL^ &: &UJsF