cURL / Mailing Lists / curl-and-php / Single Mail



From: Daniel Stenberg <>
Date: Mon, 31 Mar 2008 21:07:45 +0200 (CEST)

On Mon, 31 Mar 2008, Shailesh N. Humbad wrote:

First, a disclaimer: I'm a libcurl guy rather than a PHP/CURL guy.

> Setting CURLOPT_NOBODY to "true" with curl_setopt sets the request method to
> HEAD for HTTP(s) requests, and furthermore, cURL does not read any content
> even if a Content-Length header is found in the headers.

Right, since a HEAD response must not have any content...

BTW, "cURL" is just the name of the project that produces two things: the
command line tool and the library. The underlying library PHP/CURL uses is
called libcurl.

> However, setting CURLOPT_NOBODY back to "false" does *not* reset the request
> method back to GET. But because it is now "false", cURL will wait for
> content if the response contains a content-length header.

While I can agree with parts of your reactions, there's nothing in the libcurl
documentation that says how it behaves when you pass a FALSE to
CURLOPT_NOBODY. So perhaps the CURL binding should just not allow a FALSE

Let me also mention that libcurl is now almost eight years old and you're the
first person to point this out, so I don't consider this a major problem! ;-)

I'll certainly consider making libcurl ignore CURLOPT_NOBODY set to FALSE.

> From a usability standpoint, setting CURLOPT_NOBODY to "true" should NOT set
> the request method to HEAD if it is not going to reset it back when it is
> set to "false".

I'd reverse the logic and say that the FALSE behavior is the bad one. Or at
least the surprising one.

> The only way to reset the state of the cURL session is to set CURLOPT_HTTPGET
> to "true",

No. You can "reset" it several ways but if you want to use GET then

  Commercial curl and libcurl Technical Support:
Received on 2008-03-31