using urllib or httplib to post with ENCTYPE=mulitpart/form-data

John J Lee jjl at
Thu Jun 5 15:20:46 CEST 2003

On Wed, 4 Jun 2003, Kevin Carlson wrote:
> John J. Lee wrote:
> >Erm, I'm hesitant to suggest this module, because the version that
> >does INPUT TYPE=FILE file upload -- which I'm guessing is what you
> >want to do --
> >
> Thanks for the response, John.  Sorry, I should have been more
> specific.  I don't need to upload a file in this situation.  I need to
> post to a form that is hosted by a business partner and they require the
> multipart/form-data type.

I suppose I should support this anyway (but won't get around to it for a
while, probably).

> I actually only need to send a couple of text inputs to the form, but no
> matter what, the host system acts like I input nothing into the form.  I
> have tried this:
>   formData = "--AaB03x\r\n"

I can't remember what it's supposed to look like...

> When I examine the data object, the HTML that I receive includes an
> error message
> that I need to include inputs for field1 and field2.
> Any additional ideas?

Maybe the old webunit module will do the trick?  I don't remember.

The quickest solution ATM is probably just to watch what your browser does
and copy that.  Use ethereal, for example.  If it's HTTPS, use lynx -trace
and filter out the junk, or one of the browser plugins that let you sniff
HTTPS traffic (livehttpheaders for Mozilla, for


More information about the Python-list mailing list