Parsing MIME-encoded data in an HTTP request
Michael Ströder
michael at stroeder.com
Sat Jul 5 05:11:33 EDT 2008
Ron Garret wrote:
> In article <rNOSPAMon-BDA88C.15302904072008 at news.gha.chartermi.net>,
> Ron Garret <rNOSPAMon at flownet.com> wrote:
>
>> 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()?
>>>
>> 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.
More information about the Python-list
mailing list