CURLOPT_NOBODY仍然下载正文 - 使用带宽 [英] Does CURLOPT_NOBODY still download the body - using bandwidth

查看:253
本文介绍了CURLOPT_NOBODY仍然下载正文 - 使用带宽的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用PHP执行cURL文章,并尝试减少我使用的带宽量。我不需要任何回远远的网站,我发布,因为我控制远程网站所有我的跟踪,以确保邮件是成功的在接收端。



我的问题是...



当您将CURLOPT_NOBODY设置为TRUE时:





它是否忽略了主体而不是下载它?

解决方案

curl_setopt (强调我)的PHP手册:


CURLOPT_NOBODY :TRUE,以从输出中排除正文。然后将请求方法设置为 HEAD 。将此值更改为FALSE不会将其更改为GET。


因此,答案是否定的。它不会下载正文,因为它是一个 HTTP HEAD请求那么:


HEAD方法与GET相同,只是服务器不能在响应中返回消息体。响应于HEAD请求而包含在HTTP报头中的元信息应当与响应于GET请求而发送的信息相同。该方法可以用于获得关于请求所暗示的实体的元信息,而不传送实体体本身。此方法通常用于测试超文本链接的有效性,可访问性和最近的修改。



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?

解决方案

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.

这篇关于CURLOPT_NOBODY仍然下载正文 - 使用带宽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆