PyDocs

Nav

Internet Protocols and Support

Morsel

A 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.
Changed in 3.5, 3.7, 3.8, 3.14
  • 3.5: __eq__() now takes key and value into account.
  • 3.7: Attributes key, value and coded_value are read-only. Use set() for setting them.
  • 3.8: Added support for the samesite attribute.
  • 3.14: Added support for the partitioned attribute.
Members of Morsel

c

coded_value
The encoded value of the cookie — this is what should be sent.
copy
Return a shallow copy of the dict.

i

isReservedKey
Whether K is a member of the set of keys of a Morsel.

j

js_output
Return an embeddable JavaScript snippet, which, if run on a browser which supports JavaScript, will act the same as if the HTTP header was sent.

k

key
The name of the cookie.

o

output
Return a string representation of the Morsel, suitable to be sent as an HTTP header.
OutputString
Return a string representing the Morsel, without any surrounding HTTP or JavaScript.

s

set
Set the key, value and coded_value attributes.
setdefault
Insert key with a value of default if key is not in the dictionary.

u

update
If E is present and has a .keys() method, then does: for k in E.keys(): D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by:…

v

value
The value of the cookie.
0 Examples
No examples for http.cookies/Morsel.
See Also
No see-alsos for http.cookies/Morsel
0 Notes
No notes for Morsel