Parsing MIME-encoded data in an HTTP request

Ron Garret rNOSPAMon at flownet.com
Fri Jul 4 18:30:30 EDT 2008


In article <3a11k5-al7.ln1 at nb2.stroeder.com>,
 Michael Ströder <michael at stroeder.com> wrote:

> Ron Garret wrote:
> > I'm writing a little HTTP server and need to parse request content that 
> > is mime-encoded.  All the MIME routines in the Python standard library 
> > seem to have been subsumed into the email package, which makes this 
> > operation a little awkward.
> 
> How about using cgi.parse_multipart()?
> 
> Ciao, Michael.

Unfortunately cgi.parse_multipart doesn't handle nested multiparts, 
which the requests I'm getting have.  You have to use a FieldStorage 
object to do that, and that only works if you're actually in a cgi 
environment, which I am not.  The server responds to these requests 
directly.

Anyway, thanks for the idea.

rg



More information about the Python-list mailing list