HTTP HEAD and GET different result

我是研究僧i 提交于 2019-12-23 12:53:25

问题


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?


回答1:


but shouldn't the HEAD then also ask you to redirect?

The key is the word SHOULD. From the HTTP method specification, RFC2616:

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 request SHOULD be identical to the information sent in response to a GET request.

The word SHOULD is further definied in 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.



来源:https://stackoverflow.com/questions/15477742/http-head-and-get-different-result

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!