tags:

views:

23

answers:

1

I'm performing a cURL post with PHP and trying to reduce the amount of bandwidth I am using. I don't need anything back from the remote site I am posting to since I control the remote site all my tracking to make sure the post was successful is done on the receiving end.

My questions is...

When you set CURLOPT_NOBODY to TRUE:

Does it still download the body and simply not return it to you?

OR

Does it ignore the body and not download it at all?

+4  A: 

From the PHP manual on curl_setopt (emphasis mine):

CURLOPT_NOBODY: TRUE to exclude the body from the output. Request method is then set to HEAD. Changing this to FALSE does not change it to GET.

So, the answer is no. It won't download the body then because it is a HTTP HEAD request then:

The HEAD method is identical to GET except that the server MUST NOT return a message-body in the response. The metainformation contained in the HTTP headers in response to a HEAD request SHOULD be identical to the information sent in response to a GET request. This method can be used for obtaining metainformation about the entity implied by the request without transferring the entity-body itself. This method is often used for testing hypertext links for validity, accessibility, and recent modification.

Gordon