Home | History | Annotate | Download | only in python2.7

Lines Matching defs:Cookie

29 # Id: Cookie.py,v 2.29 2000/08/23 05:28:49 timo Exp
32 # Cookie.py is a Python module for the handling of HTTP
51 >>> import Cookie
53 Most of the time you start by creating a cookie. Cookies come in
57 >>> C = Cookie.SimpleCookie()
58 >>> C = Cookie.SerialCookie()
59 >>> C = Cookie.SmartCookie()
61 [Note: Long-time users of Cookie.py will remember using
62 Cookie.Cookie() to create an Cookie object. Although deprecated, it
66 Once you've created your Cookie, you can add values just as if it were
69 >>> C = Cookie.SmartCookie()
73 'Set-Cookie: fig=newton\r\nSet-Cookie: sugar=wafer'
75 Notice that the printable representation of a Cookie is the
76 appropriate format for a Set-Cookie: header. This is the
80 >>> C = Cookie.SmartCookie()
82 >>> C["rocky"]["path"] = "/cookie"
83 >>> print C.output(header="Cookie:")
84 Cookie: rocky=road; Path=/cookie
85 >>> print C.output(attrs=[], header="Cookie:")
86 Cookie: rocky=road
88 The load() method of a Cookie extracts cookies from a string. In a
92 >>> C = Cookie.SmartCookie()
95 'Set-Cookie: chips=ahoy\r\nSet-Cookie: vienna=finger'
101 >>> C = Cookie.SmartCookie()
104 Set-Cookie: keebler="E=everybody; L=\"Loves\"; fudge=\012;"
106 Each element of the Cookie also supports all of the RFC 2109
107 Cookie attributes. Here's an example which sets the Path
110 >>> C = Cookie.SmartCookie()
114 Set-Cookie: oreo=doublestuff; Path=/
119 >>> C = Cookie.SmartCookie()
128 As mentioned before, there are three different flavors of Cookie
138 >>> C = Cookie.SimpleCookie()
146 'Set-Cookie: number=7\r\nSet-Cookie: string=seven'
154 value, and recover the exact same object when the cookie has been
155 returned. (SerialCookie can yield some strange-looking cookie
158 >>> C = Cookie.SerialCookie()
166 'Set-Cookie: number="I7\\012."\r\nSet-Cookie: string="S\'seven\'\\012p1\\012."'
182 >>> C = Cookie.SmartCookie()
190 'Set-Cookie: number="I7\\012."\r\nSet-Cookie: string=seven'
196 In order to keep compatibilty with earlier versions of Cookie.py,
197 it is still possible to use Cookie.Cookie() to create a Cookie. In
200 >>> C = Cookie.Cookie()
223 "SmartCookie","Cookie"]
376 # the cookie's HTTP header. By default, _getdate() returns the
378 # Set-Cookie header. The one optional argument is an offset from
399 # In a cookie, each such pair may have several attributes.
468 def output(self, attrs=None, header = "Set-Cookie:"):
482 document.cookie = \"%s\";
524 # Pattern for finding cookie
550 # At long last, here is the cookie class.
560 Called prior to setting a cookie's value from the network
570 Called prior to setting a cookie's value from the dictionary
583 """Private method for setting a cookie's value"""
595 def output(self, attrs=None, header="Set-Cookie:", sep="\015\012"):
629 map(Cookie.__setitem__, d.keys(), d.values())
646 # Start looking for a cookie
655 # We ignore attributes which pertain to the cookie
672 SimpleCookie supports strings as cookie values. When setting
686 SerialCookie supports arbitrary objects as cookie values. All
692 Note: Large cookie values add overhead because they must be
695 Note: HTTP has a 2k limit on the size of a cookie. This class
712 SmartCookie supports arbitrary objects as cookie values. If the
717 Note: Large cookie values add overhead because they must be
720 Note: HTTP has a 2k limit on the size of a cookie. This class
724 warnings.warn("Cookie/SmartCookie class is insecure; do not use it",
745 # We provide Cookie() as an alias for SmartCookie()
746 Cookie = SmartCookie
752 import doctest, Cookie
753 return doctest.testmod(Cookie)