eMSrSSKrSSKrSSKr/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.rSr\R*"S5R4rSrSr/SQr/SQrS\\4Sjr "SS\!5r"Sr#\#S-r$\R*"S\#-S-\$-S-\RJ\RL-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=\\012;";') >>> print(C) Set-Cookie: keebler="E=everybody; L=\"Loves\"; fudge=\012;" 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 2/opt/imh/python3.13/lib/python3.13/http/cookies.pyrrsrrz!#$%&'*+-.^_`|~:z ()/<=>?@[]{}z\%03o"\"\z\\z[%s]+cbUb[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 _Translatorstrs r_quoters1 {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$rs r_unquoter)sO {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)r?r>)future weekdayname monthnamer>r?nowyearmonthdayhhmmsswdyzs r_getdaterMsE! &C-3CL-A*D"" 0 OSE"2Db E FFrc \rSrSrSrSSSSSSS S S S . rS S1rSr\S5r \S5r \S5r Sr S"Sjr Sr\R rSrSrSrSrSrSrS#Sjr\rSrS"SjrS"S jr\"\R<5rS!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) rQpathcommentdomainmax-agesecurehttponlyversionsamesiter]r^cS=Ul=UlUlURHn[R XS5 M g)Nr)_key_value _coded_value _reserveddict __setitem__)selfkeys r__init__Morsel.__init__s86:: :DK$"3>>C   T +"rcUR$N)rbrhs rri Morsel.keys yyrcUR$rm)rcrns rvalue Morsel.values {{rcUR$rm)rdrns r coded_valueMorsel.coded_values   rcUR5nXR;a[SU<35e[R XU5 gNzInvalid attribute )lowerrerrfrg)rhKVs rrgMorsel.__setitem__#s5 GGINN";< < !$rNcUR5nXR;a[SU<35e[R XU5$rw)rxrerrf setdefault)rhrivals rr}Morsel.setdefault)s6iik nn $=> >t#..rc"[U[5(d[$[R X5=(aY UR UR :H=(a9 UR UR :H=(a URUR:H$rm) isinstancerONotImplementedrf__eq__rcrbrdrhmorsels rr Morsel.__eq__/sk&&))! ! D)9 v}},9 V[[(9!!V%8%88 :rc[5n[RX5 URRUR5 U$rm)rOrfupdate__dict__rs rcopy Morsel.copy9s0 F!t}}- rc0n[U5R5H7up4UR5nX0R;a[ SU<35eXBU'M9 [R X5 grw)rfitemsrxrerr)rhvaluesdatarir~s rr Morsel.update?sXV **,HC))+C..(!C"ABBI - Drc<UR5UR;$rm)rxre)rhrys r isReservedKeyMorsel.isReservedKeyHswwyDNN**rcUR5UR;a[SU<35e[U5(d[SU<35eXlX lX0lg)NzAttempt to set a reserved key z Illegal key )rxrerrrbrcrd)rhrir~ coded_vals rset Morsel.setKsM 99;$.. (CIJ JS!!#78 8  %rcJURURURS.$)N)rirqrtrbrcrdrns r __getstate__Morsel.__getstate__Vs#99[[,,  rc@USUlUSUlUSUlg)Nrirqrtr)rhstates r __setstate__Morsel.__setstate__]s%%L Gn !-0rc2U<SURU5<3$)Nr) OutputString)rhattrsheaders routput Morsel.outputbs $"3"3E":;;rc\SURR<SUR5<S3$)N<: >) __class__r rrns r__repr__Morsel.__repr__gs !^^44d6G6G6IJJrcJSURU5RSS5-$)Nz rr)rreplace)rhrs r js_outputMorsel.js_outputjs.   '//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=rrQr\z%s=%drZ) appendrirtresortedrrr"rMrr_flags_semispacejoin)rhrresultrrrirqs rrMorsel.OutputStringtsB $((D$4$456 =NNEtzz|$JC{iJuc$:$:$.."5xGH !j&<&<w$.."5u!==> !j&<&<$.."5ve}EF #3t~~c234$.."5u=> $f%%r)rdrbrcrm)N Set-Cookie:)!r r r r__doc__rerrjpropertyrirqrtrgr}robject__ne__rrrrrrr__str__rrr classmethodtypes GenericAlias__class_getitem__rr rrrOrOs* I #F,!!% / :]]F  + & 1 <GK=&B$E$6$67rrOz,\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 rhr~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. rrhr~strvals r value_encodeBaseCookie.value_encodes S~rNc6U(aURU5 ggrm)load)rhinputs rrjBaseCookie.__init__s  IIe  rcURU[55nURXU5 [R XU5 g)z+Private method for setting a cookie's valueN)getrOrrfrg)rhri real_valuertMs r__setBaseCookie.__sets2 HHS&( # c{+ A&rc[U[5(a[RXU5 gUR U5up4UR XU5 g)zDictionary style assignment.N)rrOrfrgr_BaseCookie__set)rhrirqrvalcvals rrgBaseCookie.__setitem__s? eV $ $   T .**51JD JJs$ 'rc/n[UR55nUH%upgURURX55 M' UR U5$)z"Return a string suitable for HTTP.)rrrrjoin)rhrrseprrrirqs rrBaseCookie.outputsGtzz|$JC MM%,,u5 6 xxrc/n[UR55nUH0up4URU<S[UR5<35 M2 SUR R <S[U5<S3$)Nrrrr)rrrreprrqrr _spacejoin)rhlrrirqs rrBaseCookie.__repr__sV tzz|$JC HHT%++%67 8 !^^44jmDDrc/n[UR55nUH%upEURURU55 M' [ U5$)z(Return a string suitable for JavaScript.)rrrr _nulljoin)rhrrrrirqs 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)rhrawdatarirqs rrBaseCookie.loadsB 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) NrFrr rir~$T) r'matchgroupendrrxrOrerr)rr)rhrpattin parsed_items morsel_seenTYPE_ATTRIBUTE TYPE_KEYVALUErrirqrtprrs r__parse_stringBaseCookie.__parse_string s  H   1jqjjJJs&EU+U[[-? ! A1v}"##^We$DE 0 00"=yy{fmm3$++^$,GH ''huo(NO"##]9J9J59Q$RS" E1jqjjJ *NBU#}$}#***"  3d+I+rr rm)Nrz )r r r rrrrrjrrgrrrrr_CookiePatternrrr rrrrsD1' ( GE! (6:rrc$\rSrSrSrSrSrSrg)riHz 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$rm)r)rs rrSimpleCookie.value_decodeOs}c!!rc2[U5nU[U54$rm)rrrs rrSimpleCookie.value_encodeRsSvf~%%rr N)r r r rrrrrr rrrrHs "&rr)*rrestringr__all__rrrr Exceptionr ascii_lettersdigits _LegalChars_UnescapedCharsrrangemapordrrcompileescape fullmatchrrsubr(r$r) _weekdayname _monthnamerMrfrO_LegalKeyChars_LegalValueCharsASCIIVERBOSErrr)rs0rrsNXz 7 GG  XX  ) """V]]25GG /E#J#c#.G*HHJH1(Q,HJ HeIv  7RYY{%;;<FF  6zz89==  /6A 8 <:Fi8Ti8jB!G+      & BJJ ' 2IIX &: &G JsE: