Re: POST with HEAD?

Daniel Stenberg <[email protected]>
Newsgroups gmane.comp.web.curl.php
Message-ID <[email protected]>
On Fri, 7 Aug 2009, Stephen Pynenburg wrote:

> I encountered this behaviour a while ago - not sure why, but it seems you're 
> correct in saying that CURLOPT_POST and _NOBODY don't go together well. The 
> solution that worked for me was very simple: just use curl_setopt($ch, 
> CURLOPT_CUSTOMREQUEST, "POST") instead of setting CURLOPT_POST.

Let me just warn you when doing this.

The NOBODY option implies a HEAD request when you do it with HTTP. A HEAD 
request MUST NOT have a response body and thus libcurl will not read any such.

A POST response almost always have a body, and you can tell libcurl to abort 
the reading of that by returning something appropriate from a callback or 
similar.

By using NOBODY but setting CUSTOMREQUEST to "POST", you're basically telling 
libcurl to do a HEAD but to replace the method name. This may work fine, but 
you should then remember that libcurl will still internally work as if it is 
indeed a HEAD request.

-- 

  / daniel.haxx.se
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.