cURL - 如何禁用它请求响应

发布于 2024-10-07 18:20:05 字数 203 浏览 0 评论 0原文

我使用 cURL 脚本将参数发布到我的其他网站上的页面作为客户端的更新,我的问题是我的curl 脚本在等待对一个网站的响应然后继续访问其他网站之前停止,即使一页时间需要很长时间才能进入下一个,我尝试使用curl_setopt将连接超时和超时设置为0,但这在我的问题的响应方面不起作用。那么,开始吧,在继续下一个服务器之前,如何停止curl 等待目标服务器的响应?

谢谢, 约翰

im using a cURL script to post parameters to pages on my others sites as a update for clients, my problem is that my curl script stops while its waiting from a response to one site before continuing on to the other sites, also if one page time outs it takes ages to get on to the next, ive tryed using curl_setopt to set connectiontimeout and timeout to 0 and that doesnt work on the responses side of my problem. So getting down to it, how do i stop curl waiting for a response from the target server before moving on to the next one?

Thanks,
John

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

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

发布评论

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

评论(1

北恋 2024-10-14 18:20:05

首先,您应该检查响应,了解是否一切正常或再试一次。解决方案可能是一次运行多个curl请求: curl_multi_init ,如果您确实不想等待,请设置较小的超时(但不要太小,给一些时间来获取 DNS 记录并发送请求,尝试使用 CURLOPT_CONNECTTIMEOUT_MS )并将 CURLOPT_NOBODY 设置为 true (或将 CURLOPT_CUSTOMREQUEST 设置为 HEAD),因此curl不会等待变得完整回复。

Firstly, you should check response, to know if everything went OK or give a second try. Solution might be to run multiple curl request at once: curl_multi_init, and if you really don't want to wait, set small timeout (but not too small, give some time to fetch DNS record and send request, try with CURLOPT_CONNECTTIMEOUT_MS) and set CURLOPT_NOBODY to true (or CURLOPT_CUSTOMREQUEST to HEAD), so curl won't wait to get whole response.

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