cURL / Mailing Lists / curl-library / Single Mail


Re: Differences between the buffer-oriented curl_fromadd() parameters

From: Holger Rauch <>
Date: Tue, 1 Oct 2002 20:12:11 +0200 (CEST)

Hi Daniel!

Thanks a lot for your quick reply!

What I'm actually trying to do is that I want to upload a buffer using
HTTP POST request. Basically, the buffer is similar to what's provided in
the example section of the man page:

char htmlbuffer[] = "<HTML>test buffer</HTML>";

but it's longer and contains XML instead of HTML data.

On Tue, 1 Oct 2002, Daniel Stenberg wrote:

> [...]
> I know the curl_formadd man page isn't very well structured. I'll welcome all
> kinds of improvements anyone can provide.

I would be willing to provide improvements, but first I've to understand
the matter myself ;-)

> [...]
> PTRCONTENTS means that you only pass the pointer to libcurl, and it'll refer
> to the same data you pointed to. COPYCONTENTS will make libcurl copy that
> data, and thus you can remove it immediately after having called
> curl_formadd(), if that's what you want.

Ok, so that covers the difference between PTRCONTENTS and COPYCONTENTS.

> Needless to say, PTRCONTENTS will be a lot faster and less resourse-hungry
> especially if you plan to send away large chunks of data.

Thanks a lot for that hint.

> [...]
> BUFFER sets a name for the buffer upload. This name is what the "filename"
> will be set to, as this is a "file upload" kind of form.

Why is there another CURLFORM_* option for this purpose? Why can't I just
CURLFORM_COPYNAME for that? I had the impression CURLFORM_COPYNAME is the
CURLFORM option used to set field names. Or am I wrong?
> [...]
> > curl_formadd(&post, &last,
> The only difference here is that this COPYCONTENTS copies the data part too.

Ok. So, in contrast to the example using CURLFORM_PTRCONTENTS, this
example will contain a field name whose data is contained in a buffer
named "data", whereas in the example using CURLFORM_PTRCONTENTS, the field
data for the field named "name" is just the string "data". Right?

> > curl_formadd(&post, &last,
> This makes it a file upload part, as that's what BUFFERPTR implies. I believe
> this particular use of the function will return an error code, as you haven't
> provided a BUFFER to name the file in this faked file upload.

Ok. I now understand what's wrong with the example given above.

The reason why all of this seems pretty confusing to me is that different
CURLFORM_* options are used to set the values of certain field name. Why
introduced, allowing you to set CURLFORM_COPYNAME to "filename" and
CURLFORM_COPYVALUE to "blah.txt"? I admit that this would probably not be
as flexible as the current approach, but (at least in some cases) a bit
more obvious.

> I hope this mail has clarified it somewhat.

Partly, yes :-)

Thanks a lot for taking your time to answer my questions.

Kind regards,


This email is sponsored by: DEDICATED SERVERS only $89!
Linux or FreeBSD, FREE setup, FAST network. Get your own server
today at
Received on 2002-10-01