Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
3a9582fb
Commit
3a9582fb
authored
Jan 18, 2001
by
Ka-Ping Yee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix the example (it didn't seem to reflect reality).
parent
6f477a6c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
12 deletions
+14
-12
Doc/lib/libcookie.tex
Doc/lib/libcookie.tex
+14
-12
No files found.
Doc/lib/libcookie.tex
View file @
3a9582fb
...
...
@@ -173,19 +173,21 @@ The meaning for \var{attrs} is the same as in \method{output()}.
\subsection
{
Example
\label
{
cookie-example
}}
The following example demonstrates how to open a can of spam using the
\module
{
spam
}
module.
The following example demonstrates how to use the
\module
{
Cookie
}
module.
\begin{verbatim}
>>> import Cookie
>>> C = Cookie.SimpleCookie()
>>> C = Cookie.SerialCookie()
>>> C = Cookie.SmartCookie()
>>> C = Cookie.Cookie() # backwards
compatible alias for SmartCookie
>>> C = Cookie.Cookie() # backwards
-
compatible alias for SmartCookie
>>> C = Cookie.SmartCookie()
>>> C["fig"] = "newton"
>>> C["sugar"] = "wafer"
>>> C # generate HTTP headers
>>> print C # generate HTTP headers
Set-Cookie: sugar=wafer;
Set-Cookie: fig=newton;
>>> print C.output() # same thing
Set-Cookie: sugar=wafer;
Set-Cookie: fig=newton;
>>> C = Cookie.SmartCookie()
...
...
@@ -197,18 +199,18 @@ Cookie: rocky=road; Path=/cookie;
Cookie: rocky=road;
>>> C = Cookie.SmartCookie()
>>> C.load("chips=ahoy; vienna=finger") # load from a string (HTTP header)
>>> C
>>>
print
C
Set-Cookie: vienna=finger;
Set-Cookie: chips=ahoy;
>>> C = Cookie.SmartCookie()
>>> C.load('keebler="E=everybody; L=
\
"
Loves
\"
; fudge=
\0
12;";')
>>> C
>>> C.load('keebler="E=everybody; L=
\
\
"Loves
\\
"; fudge=
\
\
012;";')
>>>
print
C
Set-Cookie: keebler="E=everybody; L=
\"
Loves
\"
; fudge=
\0
12;";
>>> C = Cookie.SmartCookie()
>>> C["oreo"] = "doublestuff"
>>> C["oreo"]["path"] = "/"
>>> C
Set-Cookie: oreo=
"doublestuff"
; Path=/;
>>>
print
C
Set-Cookie: oreo=
doublestuff
; Path=/;
>>> C = Cookie.SmartCookie()
>>> C["twix"] = "none for you"
>>> C["twix"].value
...
...
@@ -220,7 +222,7 @@ Set-Cookie: oreo="doublestuff"; Path=/;
'7'
>>> C["string"].value
'seven'
>>> C
>>>
print
C
Set-Cookie: number=7;
Set-Cookie: string=seven;
>>> C = Cookie.SerialCookie()
...
...
@@ -230,7 +232,7 @@ Set-Cookie: string=seven;
7
>>> C["string"].value
'seven'
>>> C
>>>
print
C
Set-Cookie: number="I7
\0
12.";
Set-Cookie: string="S'seven'
\0
12p1
\0
12.";
>>> C = Cookie.SmartCookie()
...
...
@@ -240,7 +242,7 @@ Set-Cookie: string="S'seven'\012p1\012.";
7
>>> C["string"].value
'seven'
>>> C
>>>
print
C
Set-Cookie: number="I7
\0
12.";
Set-Cookie: string=seven;
\end{verbatim}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment