cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Multipart posting (the hard way)

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 26 Feb 2002 06:57:03 +0100 (MET)

On Mon, 25 Feb 2002, Clarence Gardner wrote:

> I'm having a problem with a multipart form upload. I'm using the Python
> interface (pycurl), and this post works fine:
>
> setopt(pycurl.URL,
> 'https://login.postini.com/exec/Admin?action=change_orgRedir')
> setopt(pycurl.POSTFIELDS, 'targetgroupname=&redir=Batch')
> perform()
>
> Then I need to do a multipart upload. I have the entire multipart message
> body in a string, and I've added the multipart header. The server gets the
> header, but content-length is always zero, and the body is not sent.
>
> opt(pycurl.POST, 1)
> opt(pycurl.POSTFIELDS, f.read())
> opt(pycurl.URL, 'https://login.postini.com/exec/Admin?action=change_batch')
> opt(pycurl.HTTPHEADER, [MPHeader])

Does this pass the entire string to the POSTFIELDS input? (My Python skills
are a bit limited.)

Note that you might need to use CURLOPT_POSTFIELDSIZE too to set the size of
the entire POST, if you want to prevent libcurl from using strlen() to figure
it out by itself. It is very odd that you get content-length 0.

If you pass the full string and the correct size, it should work.

What libcurl version is this?

> I've also tried using READFUNCTION to supply the data with no effect. In
> fact, my read function is never called. (I thought maybe pycurl didn't
> implement it, but looking at the code, it seems that it does.)

As said in my previous mail, libcurl unfortunately doesn't support sending
POSTs with the READFUNCTION yet. I'm accepting patches from anyone that would
bring this functionality.

> The only documentation I have to go on is the guide, and the setopt option
> list from the C interface. They say that one should use formadd to do this.
> pycurl doesn't implement that.

Well, strictly speaking that isn't true. You should be able to make it "the
hard way" the way to decribe.

-- 
    Daniel Stenberg -- curl groks URLs -- http://curl.haxx.se/
Received on 2002-02-26