用 HEAD 替换 GET 请求

发布于 2024-10-06 06:56:28 字数 317 浏览 0 评论 0原文

我目前正在使用 cURL 发送 GET 请求。但是,我不需要返回值,因为请求更多的是命令,让我的服务器知道执行 php 文件或更改设置等。在这种情况下,使用 HEAD 而不是 GET 会更经济吗?我根本不需要退回的文件。我的第二个问题是我的服务器是否会将 HEAD 解释为 GET,并执行这些函数。

所以

GET /receiver.php?command=update_homepage

我想用:

HEAD /receiver.php?command=update_homepage

I'm currently using cURL to send GET requests. However, I do not need the returned value, as the requests are more of commands, to let my server know to execute a php file or change settings and such. In this case, would it be more economical to use HEAD instead of GET? I have no need for the returned document at all. My second concern is if my server will interpret HEAD the same as GET, and will execute the functions.

So instead of:

GET /receiver.php?command=update_homepage

I want to use:

HEAD /receiver.php?command=update_homepage

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夏末的微笑 2024-10-13 06:56:28

你肯定可以使用 HEAD。服务器将正常调用您的 PHP 脚本,并在 $_SERVER["REQUEST_METHOD"] 中使用“HEAD”。您的脚本可以采取相应的行动。

要使用 cURL 发送请求,请使用 curl_setopt() 设置选项 CURLOPT_NOBODY

You sure can use HEAD. The server will invoke your PHP script as normal, with "HEAD" in $_SERVER["REQUEST_METHOD"]. Your script can act accordingly.

To send the request with cURL, set the option CURLOPT_NOBODY with curl_setopt().

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文