Mimetools and how to use it
Skip Montanaro
skip at pobox.com
Wed Nov 14 06:14:30 EST 2001
Ladislav> From a web server I receive headers that is an instance of the
Ladislav> class MIMETOOLS.MESSAGE. How can decode it ...
You need to call one of its header retrieval methods (there are several to
choose from). For more detail, check the mimetools library reference page:
http://www.python.org/doc/current/lib/module-mimetools.html
and the libref page of rfc822, its base class:
http://www.python.org/doc/current/lib/module-rfc822.html
Ladislav> and how to extract cookies then?
Assuming your mimetools.Message instance is referenced by the name "msg",
you'd retrieve the Set-Cookie headers with something like:
cookies = msg.getallmatchigheaders("Set-Cookie")
Note that you may need to put the actual headers back together. This method
returns the raw lines, including continuation lines, as separate list
elements.
--
Skip Montanaro (skip at pobox.com)
http://www.mojam.com/
http://www.musi-cal.com/
More information about the Python-list
mailing list