/opt/imh/python3.13/lib/python3.13/http/__pycache__
Edit: /opt/imh/python3.13/lib/python3.13/http/__pycache__/cookies.cpython-313.pyc (20986B)
eM S r SSKrSSKrSSKr/ SQrSR
rSR
rSR
r " S S\ 5 r
\R \R - S - r
\
S
- r\" \" S5 5 \" \" \\5 5 -
V s0 s H n U SU - _M sn r\R) \" S
5 S\" S5 S05 \R* " S\R, " \
5 - 5 R. rS r\R* " S5 R4 rS rS r/ SQr/ SQrS\\4S jr " S S\!5 r"Sr#\#S- r$\R* " S\#- S- \$- S- \RJ \RL - 5 r' " S S!\!5 r( " S" S#\(5 r)gs sn f )$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
BaseCookieSimpleCookie z; c \ rS rSrSrg)r N)__name__
__module____qualname____firstlineno____static_attributes__r
2/opt/imh/python3.13/lib/python3.13/http/cookies.pyr r s r r z!#$%&'*+-.^_`|~:z
()/<=>?@[]{} z\%03o"\"\z\\z[%s]+c b U b [ U 5 ( a U $ SU R [ 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 _quoter s1 {mC((
S]];//#55r z\\(?:([0-3][0-7][0-7])|(.))c P U S ( a [ [ U S S5 5 $ U S $ )N )chrint)ms r _unquote_replacer$ s' t3qtQ< tr c | U b [ U 5 S: a U $ U S S:w d U S S:w a U $ U SS n [ [ U 5 $ )Nr r r r )len_unquote_subr$ r s r _unquoter) sO {c#hl
1v}B3
a)C (#..r )MonTueWedThuFriSatSun)
NJanFebMarAprMayJunJulAugSepOctNovDecc \ SSK JnJ n U" 5 nU" XP- 5 u pgpppnSX XU XiX4- $ )Nr )gmtimetimez#%s, %02d %3s %4d %02d:%02d:%02d GMT)r? r> )futureweekdayname monthnamer> r? nowyearmonthdayhhmmsswdyzs r _getdaterM sE !
&C-3CL-A*D""0OSE"2DbEF Fr c
\ rS rSrSrSSSSSSS S
SS. rS
S1rS r\S 5 r \S 5 r
\S 5 rS rS"S jr
S r\R rS rS rS rS rS rS rS#S jr\rS rS"S jrS"S jr\" \R<