HTTP HEAD方法的可靠性 [英] Reliability of HTTP HEAD method

查看:144
本文介绍了HTTP HEAD方法的可靠性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试自动检测断开的链接,我惊讶地看到HTTP HEAD方法并不总是可靠的。例如网址: http://www.youtube.com/mit - 可以使用以下网址访问该网址GET方法但尝试使用HEAD方法联系URL最终会收到404错误(未找到)。

I'm trying to automate detection of broken links and I was startled to see that HTTP HEAD method is not always reliable. For example the URL: http://www.youtube.com/mit -- the URL is accessible with GET method but trying to contact the URL with HEAD method ends up with receiving 404 error (not found).

注意:可以通过以下网址轻松查看该示例: http://web-sniffer.net/
(我不以任何方式与网页挂钩)

Note: The example can be easily checked online via: http://web-sniffer.net/ (I'm not affiliated with the webpage in any way)

那么HEAD方法到底有多可靠?

So how reliable is the HEAD method in the end?

作为一个合理的解决方案,我看到不要使用HEAD总是使用GET方法,但它是浪费带宽。

As a reasonable solution I see just don't use HEAD and always use GET method always but it is wastes bandwidth.

推荐答案

HEAD 需要按照 RFC 中的说明进行操作;但是,它的实现总是受任何特定站点的开发人员的支配,并且不可能强制执行RFC兼容性。您可以相当确信任何网站都可能支持 HEAD ,但正如您已经发现的那样,没有任何保证。

HEAD is required to work as described in the RFC; however, its implementation is always at the mercy of the developers of any specific site, and it is not possible to enforce RFC-compliance. You could be fairly confident that any site is likely to support HEAD reasonably well, but as you have already discovered, there are no guarantees.

这篇关于HTTP HEAD方法的可靠性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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