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

curl-and-php

Re: POST with HEAD?

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Fri, 7 Aug 2009 08:59:22 +0200 (CEST)

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
Received on 2009-08-07