On Jul 3, 3:59 pm, Ron Garret <[EMAIL PROTECTED]> 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.

To deal with messages of that kind, I've seen modules such as
'rfc822', and 'mimetools' (which apparently builds itself from
'rfc822', so it might be more complete). There's also 'mimetypes', in
case you need to deal with file extensions and their corresponding
MIME media type.

> 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
>

Email? Why does an HTTP server need to build an email message?

I remember doing things like that some time ago when building an HTTP
server myself (http://code.google.com/p/sws-d/). Incidentally, I
resisted the urge to use much of the Python's library facilities (most
things are done manually; am I a knucklehead or what!? :). You might
wanna take a look to get some ideas.

Sebastian

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

Reply via email to