Viewing File: /opt/alt/python-internal/lib64/python3.11/http/__pycache__/cookies.cpython-311.pyc



!A?hMdZddlZddlZddlZgdZdjZdjZdjZGdde	Z
ejejzd	zZ
e
d
zZdeedeeeez
DZeed
deddiejdeje
zjZdZejdjZdZdZgdZgdZdeefdZ Gdde!Z"dZ#e#dzZ$ejde#zdze$zdzej%ej&zZ'Gd d!e!Z(Gd"d#e(Z)dS)$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=\\012;";')
   >>> print(C)
   Set-Cookie: keebler="E=everybody; L=\"Loves\"; fudge=\012;"

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.
N)CookieError
BaseCookieSimpleCookiez;  ceZdZdS)rN)__name__
__module____qualname__9/opt/alt/python-internal/lib64/python3.11/http/cookies.pyrrsDr
rz!#$%&'*+-.^_`|~:z
 ()/<=>?@[]{}ci|]}|d|z	S)z\%03or).0ns  r
<dictcomp>rs4JJJ(Q,JJJr
"\"\z\\z[%s]+ch|t|r|Sd|tzdzS)zQuote a string for use in a cookie header.

    If the string does not need to be double-quoted, then just return the
    string.  Otherwise, surround the string in doublequotes and quote
    (with a \) special characters.
    Nr)
_is_legal_key	translate_Translatorstrs r_quoters6{mC(({
S]];///#55r
z\\(?:([0-3][0-7][0-7])|(.))ch|dr#tt|ddS|dS)N)chrint)ms r_unquote_replacer%s1t3qtQ<<   tr
c|t|dkr|S|ddks|ddkr|S|dd}tt|S)Nr!rrr)len_unquote_subr%rs r_unquoter*s\{c#hhll

1v}}B3
ad)C(#...r
)MonTueWedThuFriSatSun)
NJanFebMarAprMayJunJulAugSepOctNovDecc	ddlm}m}|}|||z\	}}}}	}
}}}
}d|||||||	|
|fzS)Nr)gmtimetimez#%s, %02d %3s %4d %02d:%02d:%02d GMT)r@r?)futureweekdayname	monthnamer?r@nowyearmonthdayhhmmsswdyzs               r_getdaterNsu!!!!!!!!
$&&C-3VC&L-A-A*D%b"b"a0OS)E"2D"b"EFFr
c
eZdZdZdddddddd	d
d	Zdd
hZdZedZedZ	edZ
dZd!dZdZ
ejZdZdZdZdZdZdZd"dZeZdZd!dZd!d ZeejZdS)#MorselaCA class to hold ONE (key, value) pair.

    In a cookie, each such pair may have several attributes, so this class is
    used to keep the attributes associated with the appropriate key,value pair.
    This class also includes a coded_value attribute, which is used to hold
    the network representation of the value.
    expiresPathCommentDomainzMax-AgeSecureHttpOnlyVersionSameSite)	rQpathcommentdomainmax-agesecurehttponlyversionsamesiter]r^c|dx|_x|_|_|jD]}t||ddS)Nr)_key_value_coded_value	_reserveddict__setitem__)selfkeys  r__init__zMorsel.__init__sP6::	:DK$"3>	,	,CT3++++	,	,r
c|jSN)rbrhs rriz
Morsel.keys
yr
c|jSrl)rcrms rvaluezMorsel.values
{r
c|jSrl)rdrms rcoded_valuezMorsel.coded_values  r
c|}||jvrtd|t|||dSNzInvalid attribute )lowerrerrfrg)rhKVs   rrgzMorsel.__setitem__#sO
GGIIDN""+;<<<q!$$$$$r
Nc|}||jvrtd|t|||Srs)rtrerrf
setdefault)rhrivals   rrxzMorsel.setdefault)sGiikkdn$$+=>>>tS#...r
ct|tstSt||o/|j|jko|j|jko|j|jkSrl)
isinstancerPNotImplementedrf__eq__rcrbrdrhmorsels  rr}z
Morsel.__eq__/sg&&))	"!!D&))9v},9	V[(9!V%88	:r
ct}t|||j|j|Srl)rPrfupdate__dict__r~s  rcopyzMorsel.copy9s<FD!!!t}---
r
ci}t|D]9\}}|}||jvrt	d||||<:t||dSrs)rfitemsrtrerr)rhvaluesdatarirys     rrz
Morsel.update?sV**,,		HC))++C$.((!kCC"ABBBDIID$r
c8||jvSrl)rtre)rhrus  r
isReservedKeyzMorsel.isReservedKeyHswwyyDN**r
c||jvrtd|t|std|||_||_||_dS)NzAttempt to set a reserved key zIllegal key )rtrerrrbrcrd)rhriry	coded_vals    rsetz
Morsel.setKso99;;$.((+CCIJJJS!!	9+##7888	%r
c,|j|j|jdS)N)rirorqrbrcrdrms r__getstate__zMorsel.__getstate__Vs!9[,

	
r
cT|d|_|d|_|d|_dS)Nrirorqr)rhstates  r__setstate__zMorsel.__setstate__]s+%L	Gn!-0r
Set-Cookie:c6|d||S)Nr)OutputString)rhattrsheaders   routputz
Morsel.outputbs" &&$"3"3E":":":;;r
cLd|jjd|dS)N<: >)	__class__r	rrms r__repr__zMorsel.__repr__gs,!^444d6G6G6I6I6I6IJJr
cZd||ddzS)Nz
        <script type="text/javascript">
        <!-- begin hiding
        document.cookie = "%s";
        // end hiding -->
        </script>
        rr)rreplace)rhrs  r	js_outputzMorsel.js_outputjs4  ''//U;;
=	=r
cg}|j}||jd|j||j}t	|}|D]\}}|dkr
||vr|dkr>t
|tr)||j|dt|V|dkr1t
|tr|d|j||fz|dkr>t
|tr)||j|dt|||jvr'|r#|t|j|||j|d|t|S)N=rrQr\z%s=%drZ)
appendrirqresortedrr{r#rNrr_flags_semispacejoin)rhrresultrrriros       rrzMorsel.OutputStringts	$(((D$4$45666=NEtzz||$$	?	?JC{{%iJuc$:$:$."5"5"5xGHHHH	!!j&<&<!w$."5u!==>>>>	!!j&<&<!$."5"5"5ve}}}EFFFF##5F3t~c233444$."5"5"5uu=>>>>f%%%r
rl)Nr)r	r
r__doc__rerrjpropertyrirorqrgrxr}object__ne__rrrrrrr__str__rrrclassmethodtypesGenericAlias__class_getitem__rr
rrPrPs*

I

#F,,,XX!!X!%%%////:::]F   +++	&	&	&


111
<<<<GKKK====&&&&B$E$677r
rPz,\w\d!#%&'~_`><@,:/\$\*\+\-\.\^\|\)\(\?\}\{\=z\[\]z
    \s*                            # Optional whitespace at start of cookie
    (?P<key>                       # Start of group 'key'
    [a	]+?   # Any word of at least one letter
    )                              # End of group 'key'
    (                              # Optional group: there may not be a value.
    \s*=\s*                          # Equal Sign
    (?P<val>                         # Start of group 'val'
    "(?:[^\\"]|\\.)*"                  # Any doublequoted string
    |                                  # or
    \w{3},\s[\w\d\s-]{9,11}\s[\d:]{8}\sGMT  # Special case for "expires" attr
    |                                  # or
    [a-]*      # Any word or empty string
    )                                # End of group 'val'
    )?                             # End of optional value group
    \s*                            # Any number of spaces.
    (\s+|;|$)                      # Ending either at space, semicolon, or EOS.
    c\eZdZdZdZdZddZdZdZdd
Z	e	Z
dZddZd
Z
efdZdS)rz'A container class for a set of Morsels.c
||fS)a
real_value, coded_value = value_decode(STRING)
        Called prior to setting a cookie's value from the network
        representation.  The VALUE is the value read from HTTP
        header.
        Override this function to modify the behavior of cookies.
        rrhrys  rvalue_decodezBaseCookie.value_decodes
Cxr
c(t|}||fS)zreal_value, coded_value = value_encode(VALUE)
        Called prior to setting a cookie's value from the dictionary
        representation.  The VALUE is the value being assigned.
        Override this function to modify the behavior of cookies.
        rrhrystrvals   rvalue_encodezBaseCookie.value_encodesSv~r
Nc8|r||dSdSrl)load)rhinputs  rrjzBaseCookie.__init__s,	IIe		r
c||t}||||t|||dS)z+Private method for setting a cookie's valueN)getrPrrfrg)rhri
real_valuerqMs     r__setzBaseCookie.__setsMHHS&((##	c:{+++sA&&&&&r
ct|trt|||dS||\}}||||dS)zDictionary style assignment.N)r{rPrfrgr_BaseCookie__set)rhrirorvalcvals     rrgzBaseCookie.__setitem__seeV$$	(T3.....**511JD$JJsD$'''''r
r
cg}t|}|D].\}}||||/||S)z"Return a string suitable for HTTP.)rrrrjoin)rhrrseprrriros        rrzBaseCookie.outputsdtzz||$$	7	7JCMM%,,uf556666xxr
cg}t|}|D]1\}}||dt|j2d|jjdt|dS)Nrrrr)rrrreprrorr	
_spacejoin)rhlrriros     rrzBaseCookie.__repr__stzz||$$	9	9JC
HHT%+%6%6%678888	9!^444jmmmmDDr
cg}t|}|D]-\}}|||.t	|S)z(Return a string suitable for JavaScript.)rrrr	_nulljoin)rhrrrriros      rrzBaseCookie.js_outputs^tzz||$$	2	2JCMM%//%001111   r
ct|tr||n|D]
\}}|||<dS)zLoad cookies from a string (presumably HTTP_COOKIE) or
        from a dictionary.  Loading cookies from a dictionary 'd'
        is equivalent to calling:
            map(Cookie.__setitem__, d.keys(), d.values())
        N)r{r_BaseCookie__parse_stringr)rhrawdatariros    rrzBaseCookie.loadsZgs##	"((((&mmoo
"
"
U!S		r
cd}t|}g}d}d}d}d|cxkr|krVnnR|||}	|	sn8|	d|	d}}
|	d}|
ddkr$|sz|||
dd|fn|
tjvrg|sdS|;|
tjvr|||
dfnZdS|||
t|fn2|.|||
|
|fd}ndSd|cxkr|kPnd}|D]B\}
}
}|
|kr
|J|||
<|
|ksJ|\}}||
||||
}CdS)	NrFrr!riry$T)r(matchgroupendrrtrPrerr*rr)rhrpattirparsed_itemsmorsel_seenTYPE_ATTRIBUTE
TYPE_KEYVALUErrirortprrs                r__parse_stringzBaseCookie.__parse_string	s-
HH
1jjjjqjjjjjJJsA&&E
U++U[[-?-?C		!A1v}}"##^SWe$DEEEE 000"F=yy{{fm33$++^S$,GHHHH ''huoo(NOOOO"##]C9J9J59Q9Q$RSSS"E1jjjjqjjjjJ
*		NBU^##}}}#]****"
d

3d+++I		r
rl)Nrr)r	r
rrrrrjrrgrrrrr_CookiePatternrrr
rrrs11'''(((    GEEE!!!!(6::::::r
rceZdZdZdZdZdS)rz
    SimpleCookie supports strings as cookie values.  When setting
    the value using the dictionary assignment notation, SimpleCookie
    calls the builtin str() to convert the value to a string.  Values
    received from HTTP are kept as strings.
    c$t||fSrl)r*rs  rrzSimpleCookie.value_decodeMs}}c!!r
cBt|}|t|fSrl)rrrs   rrzSimpleCookie.value_encodePsSvf~~%%r
N)r	r
rrrrrr
rrrFs<"""&&&&&r
r)*rrestringr__all__rrrr	Exceptionr
ascii_lettersdigits_LegalChars_UnescapedCharsrrangemapordrrcompileescape	fullmatchrrsubr)r%r*_weekdayname
_monthnamerNrfrP_LegalKeyChars_LegalValueCharsASCIIVERBOSErrrrr
r<module>rsNXXz
			




7
7
7G	
X

					)			""V]25GG/JJEE#JJ##cc#.G.G*H*HHJJJCHHeCIIv

7YRY{%;%;;<<F

6
6
6rz899=///6A@@888
<:FFFFi8i8i8i8i8Ti8i8i8jB!G+				"
BJ	#  .IIIIIIIIX&&&&&:&&&&&r
Back to Directory File Manager