是“未找到”吗? “HTTP/1.1 404 Not Found”中必需的
我发现 header('HTTP/1.1 404');
在 PHP 中与 header('HTTP/1.1 404 Not Found');
一样有效。所以我查看了规范,但找不到任何相关信息;
HTTP 状态标头描述是可选的吗?
I've found that header('HTTP/1.1 404');
works just as well as header('HTTP/1.1 404 Not Found');
in PHP. So I looked in the specification, but couldn't find anything about it;
Is the HTTP status header description optional?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
描述可以是任何人类可读的字符串。客户端可能不依赖于该字符串,他们只需检查代码。
然而,像往常一样,客户并不总是遵守。浏览器可能会做得很好,但您可以打赌,有专门检查该字符串的 HTTP 客户端。
HTTP/1.1 说:
http://www.w3.org /协议/rfc2616/rfc2616-sec6.html#sec6.1
但 HTTPbis 用更强硬的措辞澄清了这一点:
https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-p1-messaging-16#section-5.1.1
The description can be any human-readable string. Clients may not depend on the string and they must only check the code.
However, as usual clients aren't always complying. Browsers will probably do fine, but you can bet that there's HTTP clients out there that specifically check for the string.
HTTP/1.1 says:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6.1
But HTTPbis clarified it with stronger wording:
https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-p1-messaging-16#section-5.1.1