Parsing MIME-encoded data in an HTTP request
- From: Ron Garret <rNOSPAMon@xxxxxxxxxxx>
- Date: Thu, 03 Jul 2008 13:59:24 -0700
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. It seems I have to do the following:
1. Extract the content-length header from the HTTP request and use that
to read the payload.
2. Stick some artificial-looking headers onto the beginning of this
payload to make it look like an email message (including the
content-type and content-transfer-encoding headers)
3. Parse the resulting string into a email message
That works, but it feels way too hackish for my tastes. Surely there
must be a better/more standard way of doing this?
Thanks,
rg
.
- Follow-Ups:
- Re: Parsing MIME-encoded data in an HTTP request
- From: Michael Ströder
- Re: Parsing MIME-encoded data in an HTTP request
- From: s0suk3
- Re: Parsing MIME-encoded data in an HTTP request
- Prev by Date: Testing for an empty list
- Next by Date: Re: Testing for an empty list
- Previous by thread: Testing for an empty list
- Next by thread: Re: Parsing MIME-encoded data in an HTTP request
- Index(es):