R
Ron Garret
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
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