HTTP HEAD和GET结果不同 [英] HTTP HEAD and GET different result
问题描述
HEAD
和 GET
方法是否应返回相同的状态代码?更具体地说,当我们执行 HEAD
时,我们遇到客户网站返回 200
的情况,但是当我们执行 GET
时,返回 303
。它与根据位置重定向到特定于语言的页面有关,但不应该 HEAD
然后还要求您重定向?
Should the HEAD
and GET
methods return the same status code? More specifically, we have run into the situation where a client website is returning a 200
when we do a HEAD
, but returns a 303
when we do a GET
. It has to do with redirecting to a language specific page based on location, but shouldn't the HEAD
then also ask you to redirect?
推荐答案
但是HEAD不应该要求你重定向吗?
关键是单词应该
。来自 HTTP方法规范,RFC2616 :
9.4 HEAD
除了服务器<$ c外,HEAD方法与GET相同$ c>绝不能在响应中返回一个消息体。响应HEAD请求的HTTP标头中包含的元信息
SHOULD
与响应GET请求时发送的信息相同。
9.4 HEAD
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 requestSHOULD
be identical to the information sent in response to a GET request.
单词应该
进一步明确 RFC2119 :
应该
这个词,或形容词推荐,意味着
可能存在有效理由,在特殊情况下忽略
特殊项目,但必须理解全部含义,并在选择不同的课程之前仔细权衡
。
SHOULD
This word, or the adjective "RECOMMENDED", mean that there may exist valid reasons in particular circumstances to ignore a particular item, but the full implications must be understood and carefully weighed before choosing a different course.
所以,案例你描述的是合法的,但不推荐。您可能需要向网站维护者询问此路径的原因。
So, the case you described is legit, but not recommended. You may want to ask the site maintainer for the reasoning of this path.
这篇关于HTTP HEAD和GET结果不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!