| Server IP : 121.121.20.254 / Your IP : 216.73.217.51 Web Server : Microsoft-IIS/10.0 System : Windows NT WEB-SERVER 10.0 build 20348 (Windows Server 2022) AMD64 User : IUSR ( 0) PHP Version : 8.3.28 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/Python315/Lib/http/__pycache__/ |
Upload File : |
R
>lqjZ c � � Q s ] PHs] PHs] PHs] PHs, Q NsPO sQO sQO s Q Q\
2 s\O \O * Q* s\Q* s\ \ Q 2 2 \ \ \\2 2 *
T t- tF D
o U Q
U * aJ to s\O+ \ Q2 Q\ Q
2 Q-2 \O, Q\O. \2 * 2 O0 s\O, Q2 sQ sQ s\O, Q2 O: sQ sQ s , Q!Ns!, Q"Ns"] \!\"1Q ks# Q Q\$2 s%Qs&\&Q* s'\O, Q\&* Q* \'* Q* \OP \OR * 2 s* Q Q\$2 s+ Q Q\+2 s,P! t to h )#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=;";')
>>> print(C)
Set-Cookie: keebler="E=everybody; L=\"Loves\"; fudge=;"
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.
�CookieError�
BaseCookie�SimpleCookiez; � c � � \ sQ s]�sQsP! )r � )�__name__�
__module__�__qualname__�__firstlineno__�__static_attributes__r � �!C:\Python315\\Lib\http\cookies.pyr r � s � �r z!#$%&'*+-.^_`|~:z
()/<=>?@[]{}� z\%03o�"z\"�\z\\z[%s]+z[\x00-\x1F\x7F]c �j � [ 9PI c Q U 2 D % f J P ! P
! Q U 2 2 ! )z`Detects control characters within a value.
Supports any type, as header values can be any type.
c 3 �j � S F � D$ o[ O [ U2 2 w � J&