Parsing HTTP messages

Chris Gray cpgray at library.uwaterloo.ca
Thu Nov 20 17:00:51 CET 2003


On Wed, 19 Nov 2003, Fredrik Lundh wrote:
> 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)

Thanks, Fredrik.  I'll look at those.

> > 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)

Granted.  I was being kind of flip.  I just meant that email.Message or
mimetools.Message can't process the HTTP start-line properly.

I also realized the source of my misunderstanding of the RFC.  The "Both"
refers to "both HTTP requests and responses" not to "both MIME and HTTP
messages".  All the lights are on now.

Thanks to all who responded,
Chris Gray




More information about the Python-list mailing list