In article <[EMAIL PROTECTED]>,
 Michael Ströder <[EMAIL PROTECTED]> wrote:

> Ron Garret wrote:
> > In article <[EMAIL PROTECTED]>,
> >  Ron Garret <[EMAIL PROTECTED]> wrote:
> > 
> >> In article <[EMAIL PROTECTED]>,
> >>  Michael Ströder <[EMAIL PROTECTED]> 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()?
> >>>
> >> 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.
> > 
> > Hm, it actually seems to work if I manually pass in the outerboundary 
> > parameter and environ={'REQUEST_METHOD':'POST'}  That seems like the 
> > Right Answer.
> 
> I'm also using it to parse form parameters in a message body received by 
> POST.
> 
> CIao, Michael.

Just for the record, here's the incantation I ended up with:


class post_handler(BaseHTTPRequestHandler):
  def do_POST(self):
    form = cgi.FieldStorage(fp=self.rfile, headers=self.headers,
                            environ={'REQUEST_METHOD':'POST'})
    ...


works like a charm.

rg
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to