What does HTTP/1.1 302 mean exactly?

2019-01-10 05:23发布

Some article I read once said that it means jumping (from one URI to another), but I detected this "302" even when there was actually no jumping at all!

10条回答
迷人小祖宗
2楼-- · 2019-01-10 06:01

302 is a response indicating change of resource location - "Found".

The url where the resource should be now located should be in the response 'Location' header.

The "jump" should be done by the requesting client (make a new request to the resource url in the response Location header field).

查看更多
叼着烟拽天下
3楼-- · 2019-01-10 06:05

HTTP code 302 is for redirection see http://en.wikipedia.org/wiki/HTTP_302.

It tells the browse reading a page to go somewhere else and load another page. Its usage is very common.

查看更多
唯我独甜
4楼-- · 2019-01-10 06:09

A simple way of looking at HTTP 301 vs. 302 redirects is:

Suppose you have a bookmark to "http://sample.com/sample". You use a browser to go there.

A 302 redirect to a different URL at this point would mean that you should keep your bookmark to "http://sample.com/sample". This is because the destination URL may change in the future.

A 301 redirect to a different URL would mean that your bookmark should change to point to the new URL as it is a permanent redirect.

查看更多
迷人小祖宗
5楼-- · 2019-01-10 06:10

From RFC 2616 (the Hypertext Transfer Protocol Specification):

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).

Source:

http://www.ietf.org/rfc/rfc2616.txt

查看更多
登录 后发表回答