Parsing HTTP messages

Fredrik Lundh fredrik at pythonware.com
Wed Nov 19 17:09:39 EST 2003


Chris Gray wrote:

> My initial question is, what Python library do I use to parse HTTP
> messages?

mimetools.Message is a good choice.  httplib.HTTPHeader is a slightly
better choice (it's a subclass of mimetools.Message; see the httplib.py
source code for more info)

> But my understanding of RFC (2)822 is that there is no such thing as a
> "start-line" in that format, and so the "email" module is right in trying
> to treat the HTTP "start-line" as a header and that that start-line should
> be stripped out before feeding it the remainder of the message which _is_
> in (2)822 format.
>
> Am I (don't laugh) missing something here?

not really, as long as "stripped out" means "processed", not "ignored"
(the start line contains the HTTP method and the target URL)

</F>








More information about the Python-list mailing list