Changeset 391 for python/trunk/Doc/library/cookie.rst
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Doc/library/cookie.rst
r2 r391 9 9 .. note:: 10 10 The :mod:`Cookie` module has been renamed to :mod:`http.cookies` in Python 11 3.0. The :term:`2to3` tool will automatically adapt imports when converting 12 your sources to 3.0. 13 11 3. The :term:`2to3` tool will automatically adapt imports when converting 12 your sources to Python 3. 13 14 **Source code:** :source:`Lib/Cookie.py` 15 16 -------------- 14 17 15 18 The :mod:`Cookie` module defines classes for abstracting the concept of … … 20 23 The module formerly strictly applied the parsing rules described in the 21 24 :rfc:`2109` and :rfc:`2068` specifications. It has since been discovered that 22 MSIE 3.0x doesn't follow the character rules outlined in those specs. As a 23 result, the parsing rules used are a bit less strict. 25 MSIE 3.0x doesn't follow the character rules outlined in those specs and also 26 many current day browsers and servers have relaxed parsing rules when comes to 27 Cookie handling. As a result, the parsing rules used are a bit less strict. 28 29 The character set, :data:`string.ascii_letters`, :data:`string.digits` and 30 ``!#$%&'*+-.^_`|~`` denote the set of valid characters allowed by this module 31 in Cookie name (as :attr:`~Morsel.key`). 32 24 33 25 34 .. note:: … … 192 201 .. method:: Morsel.set(key, value, coded_value) 193 202 194 Set the *key*, *value* and *coded_value* members.203 Set the *key*, *value* and *coded_value* attributes. 195 204 196 205 … … 236 245 >>> import Cookie 237 246 >>> C = Cookie.SimpleCookie() 238 >>> C = Cookie.SerialCookie()239 >>> C = Cookie.SmartCookie()240 247 >>> C["fig"] = "newton" 241 248 >>> C["sugar"] = "wafer" … … 246 253 Set-Cookie: fig=newton 247 254 Set-Cookie: sugar=wafer 248 >>> C = Cookie.S martCookie()255 >>> C = Cookie.SimpleCookie() 249 256 >>> C["rocky"] = "road" 250 257 >>> C["rocky"]["path"] = "/cookie" … … 253 260 >>> print C.output(attrs=[], header="Cookie:") 254 261 Cookie: rocky=road 255 >>> C = Cookie.S martCookie()262 >>> C = Cookie.SimpleCookie() 256 263 >>> C.load("chips=ahoy; vienna=finger") # load from a string (HTTP header) 257 264 >>> print C 258 265 Set-Cookie: chips=ahoy 259 266 Set-Cookie: vienna=finger 260 >>> C = Cookie.S martCookie()267 >>> C = Cookie.SimpleCookie() 261 268 >>> C.load('keebler="E=everybody; L=\\"Loves\\"; fudge=\\012;";') 262 269 >>> print C 263 270 Set-Cookie: keebler="E=everybody; L=\"Loves\"; fudge=\012;" 264 >>> C = Cookie.S martCookie()271 >>> C = Cookie.SimpleCookie() 265 272 >>> C["oreo"] = "doublestuff" 266 273 >>> C["oreo"]["path"] = "/" 267 274 >>> print C 268 275 Set-Cookie: oreo=doublestuff; Path=/ 269 >>> C = Cookie.SmartCookie()270 276 >>> C["twix"] = "none for you" 271 277 >>> C["twix"].value … … 281 287 Set-Cookie: number=7 282 288 Set-Cookie: string=seven 289 >>> # SerialCookie and SmartCookie are deprecated 290 >>> # using it can cause security loopholes in your code. 283 291 >>> C = Cookie.SerialCookie() 284 292 >>> C["number"] = 7
Note:
See TracChangeset
for help on using the changeset viewer.