Http status 302 解惑

来源:互联网 发布:安卓查看网络频段band 编辑:程序博客网 时间:2024/05/18 01:07

302 的标准解释为:

10.3.3 302 Found

The requested resource resides temporarily under a different URI. Since the redirection might be altered on occasion, the client SHOULD continue to use the Request-URI for future requests. This response is only cacheable if indicated by a Cache-Control or Expires header field.

The temporary URI SHOULD be given by the Location field in the response. Unless the request method was HEAD, the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s).

If the 302 status code is received in response to a request other than GET or HEAD, the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user, since this might change the conditions under which the request was issued.

 

按照协议规定,应该在根据response中的header中的location的值重新发起一次请求。

 

实际发生时,我们的情景是:

url中参数之前的host部分没有以“/”结尾,返回的header中location添加了“/”。

比如请求url: http://192.168.1.111/client?key=123, 返回中的location为 http://192.168.1.111/client/?key=123

此时,要么按照协议,重新请求;要么请求时都加上“/”。

 

环境 nginx

原创粉丝点击