Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Doc/library/cookie.rst

    r2 r391  
    99.. note::
    1010   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--------------
    1417
    1518The :mod:`Cookie` module defines classes for abstracting the concept of
     
    2023The module formerly strictly applied the parsing rules described in the
    2124: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.
     25MSIE 3.0x doesn't follow the character rules outlined in those specs and also
     26many current day browsers and servers have relaxed parsing rules when comes to
     27Cookie handling.  As a result, the parsing rules used are a bit less strict.
     28
     29The character set, :data:`string.ascii_letters`, :data:`string.digits` and
     30``!#$%&'*+-.^_`|~`` denote the set of valid characters allowed by this module
     31in Cookie name (as :attr:`~Morsel.key`).
     32
    2433
    2534.. note::
     
    192201.. method:: Morsel.set(key, value, coded_value)
    193202
    194    Set the *key*, *value* and *coded_value* members.
     203   Set the *key*, *value* and *coded_value* attributes.
    195204
    196205
     
    236245   >>> import Cookie
    237246   >>> C = Cookie.SimpleCookie()
    238    >>> C = Cookie.SerialCookie()
    239    >>> C = Cookie.SmartCookie()
    240247   >>> C["fig"] = "newton"
    241248   >>> C["sugar"] = "wafer"
     
    246253   Set-Cookie: fig=newton
    247254   Set-Cookie: sugar=wafer
    248    >>> C = Cookie.SmartCookie()
     255   >>> C = Cookie.SimpleCookie()
    249256   >>> C["rocky"] = "road"
    250257   >>> C["rocky"]["path"] = "/cookie"
     
    253260   >>> print C.output(attrs=[], header="Cookie:")
    254261   Cookie: rocky=road
    255    >>> C = Cookie.SmartCookie()
     262   >>> C = Cookie.SimpleCookie()
    256263   >>> C.load("chips=ahoy; vienna=finger") # load from a string (HTTP header)
    257264   >>> print C
    258265   Set-Cookie: chips=ahoy
    259266   Set-Cookie: vienna=finger
    260    >>> C = Cookie.SmartCookie()
     267   >>> C = Cookie.SimpleCookie()
    261268   >>> C.load('keebler="E=everybody; L=\\"Loves\\"; fudge=\\012;";')
    262269   >>> print C
    263270   Set-Cookie: keebler="E=everybody; L=\"Loves\"; fudge=\012;"
    264    >>> C = Cookie.SmartCookie()
     271   >>> C = Cookie.SimpleCookie()
    265272   >>> C["oreo"] = "doublestuff"
    266273   >>> C["oreo"]["path"] = "/"
    267274   >>> print C
    268275   Set-Cookie: oreo=doublestuff; Path=/
    269    >>> C = Cookie.SmartCookie()
    270276   >>> C["twix"] = "none for you"
    271277   >>> C["twix"].value
     
    281287   Set-Cookie: number=7
    282288   Set-Cookie: string=seven
     289   >>> # SerialCookie and SmartCookie are deprecated
     290   >>> # using it can cause security loopholes in your code.
    283291   >>> C = Cookie.SerialCookie()
    284292   >>> C["number"] = 7
Note: See TracChangeset for help on using the changeset viewer.