Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
314 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...