cURL / Mailing Lists / curl-library / Single Mail


Re: setting POSTFIELDS to NULL forces PUT instead of GET - please document

From: Chris MacGregor <>
Date: Sun, 27 Dec 2009 15:28:27 -0800

On 12/26/2009 1:17 PM, Daniel Stenberg wrote:
> On Sat, 26 Dec 2009, wrote:
>> So it seems that it would be quite valuable if the documentation were
>> as clear as the source comment is about the side-effects of setting
>> POSTFIELDS. And as there are a few other similar side-effects to
>> setting other options, it would be helpful to document those as well.
> What comment are you referring to?

In url.c:

      * A string with POST data. Makes curl HTTP POST. Even if it is NULL.
      * If needed, CURLOPT_POSTFIELDSIZE must have been set prior to
      * CURLOPT_COPYPOSTFIELDS and not altered later.
     data->set.httpreq = HTTPREQ_POST;

      * Like above, but use static data instead of copying it.
     data->set.httpreq = HTTPREQ_POST;

> What libcurl version are you using?


> In current libcurl, CURLOPT_POSTFIELDS set (to anything) implies a
> POST. Thus if you set POSTFIELDS to NULL _after_ setting HTTPGET to 1,
> it still will end up in a POST.

Yes, I see that. The comment shown above says that clearly. However,
the documentation (e.g., )
does NOT say that clearly. I am suggesting that it would be helpful to
add the same clear statement to the docs.

> I don't see anything in the docs that says setting POSTFIELDS to NULL
> is a good idea if you don't want to send a POST.

Neither do I. And I don't see anything in my email that says that the
docs say that. On the other hand, there are other libcurl options for
which setting to NULL *does* in fact disable the associated behavior.
So it is not a completely insane thing for someone to think.

> So, can you please tell us exactly how you suggest we alter/change the
> docs to make the behavior better described?

At a minimum, I suggest that you add a statement such as "Setting
has the side effect of setting the HTTP request type to be a POST,
similar to setting CURLOPT_POST to 1."

I see from the code in url.c that various other options have various
side effects. It would be great if all of them were documented
explicitly. It would also be helpful to document the initial values of
various options (many are not documented), when they are reset to those
values, and which values if any are "special" for various options (such
as the several options for which values like NULL or -1 have a special
meaning, such as disabling an associated behavior or requesting that
libcurl compute the value, etc.).

List admin:
Received on 2009-12-28