upload file via web form (Re: to Trent Mick's posting)
Aki Niimura
akineko at pacbell.net
Mon Jul 7 13:21:38 EDT 2003
Hello everyone,
Trent Mick wrote:
> """Some httplib helper methods."""
>
> def httprequest(url, postdata={}, headers={}):
> """A urllib.urlopen() replacement for http://... that gets the
> content-type right for multipart POST requests.
>
> "url" is the http URL to open.
> "postdata" is a dictionary describing data to post. If the dict is
> ... snip ...
I have tried the above script and found not working.
After comparing the contents of the packets (captured by tcpdump) between
the one generated by the above script and the one generated by Netscape,
I found the 'body' doesn't have CRLF ('\n\r') which some servers may
consider it as a line terminator (for MIMIE headers).
After I inserted the following line:
body = string.replace(body, '\n', '\r\n')
It is working correctly.
Thank you for providing such excellent script. I would like to see such
methods in the future Python standard distribution.
Best regards,
Aki Niimura
More information about the Python-list
mailing list