multipart/form-data submission with httplib + MimeWriter?
stephen_purcell at yahoo.com
Sun Mar 4 16:11:46 CET 2001
Richard van de Stadt wrote:
> Steve Purcell wrote:
> > Can anyone point me towards some example code for performing
> > 'multipart/form-data' submissions of form values and file contents
> > using httplib and MimeWriter?
> I'm not sure what you mean.
> Are you asking about
> - how to *fill in* such webforms automatically, or
> - how to create a form with which a file can be uploaded, or
> - how to deal with the contents of such a form when submitted?
None of the above. I meant exactly what I said; making multipart/form-data
POST submissions programmatically using httplib and MimeWriter.
But thanks for the reply anyway.
I figured it out in the end, after some experimentation. The two libraries
don't work well together for various reasons. For intance, MimeWriter can't
provide a content-length, which POST requests require. Fortunately it's
trivial to write multipart MIME messages 'the long way'.
(Background; I'm working on a client-side web testing library that sits on
PyUnit, and which will soon be available at webunit.sourceforge.net)
Steve Purcell, Pythangelist
Get testing at http://pyunit.sourceforge.net/
Get servlets at http://pyserv.sourceforge.net/
"Even snakes are afraid of snakes." -- Steven Wright
More information about the Python-list