鍍金池/ 問答/PHP  C  HTML/ 關(guān)于面試中被問到計(jì)算機(jī)網(wǎng)絡(luò)狀態(tài)碼302和303的區(qū)別?(′?_?`)

關(guān)于面試中被問到計(jì)算機(jī)網(wǎng)絡(luò)狀態(tài)碼302和303的區(qū)別?(′?_?`)

看了很多文章,不同文章都有自己不同的見解。。。那么有沒有一個(gè)統(tǒng)一的回答?或者是面試管想要的回答?也可以聯(lián)系到http1.0和http1.1,狀態(tài)碼307一起講。

回答
編輯回答
久不遇

303和302狀態(tài)碼有著相同的功能,但是303明確表示客戶端應(yīng)當(dāng)采用get方法獲取資源,這點(diǎn)與302狀態(tài)碼有區(qū)別。

2017年8月3日 00:50
編輯回答
凝雅

RFC 7231

6.4.3.  302 Found

   The 302 (Found) status code indicates that the target resource
   resides temporarily under a different URI.  Since the redirection
   might be altered on occasion, the client ought to continue to use the
   effective request URI for future requests.

   The server SHOULD generate a Location header field in the response
   containing a URI reference for the different URI.  The user agent MAY
   use the Location field value for automatic redirection.  The server's
   response payload usually contains a short hypertext note with a
   hyperlink to the different URI(s).

      Note: For historical reasons, a user agent MAY change the request
      method from POST to GET for the subsequent request.  If this
      behavior is undesired, the 307 (Temporary Redirect) status code
      can be used instead.


6.4.4.  303 See Other

   The 303 (See Other) status code indicates that the server is
   redirecting the user agent to a different resource, as indicated by a
   URI in the Location header field, which is intended to provide an
   indirect response to the original request.  A user agent can perform
   a retrieval request targeting that URI (a GET or HEAD request if
   using HTTP), which might also be redirected, and present the eventual
   result as an answer to the original request.  Note that the new URI
   in the Location header field is not considered equivalent to the
   effective request URI.

   This status code is applicable to any HTTP method.  It is primarily
   used to allow the output of a POST action to redirect the user agent
   to a selected resource, since doing so provides the information
   corresponding to the POST response in a form that can be separately
   identified, bookmarked, and cached, independent of the original
   request.

   A 303 response to a GET request indicates that the origin server does
   not have a representation of the target resource that can be
   transferred by the server over HTTP.  However, the Location field
   value refers to a resource that is descriptive of the target
   resource, such that making a retrieval request on that other resource
   might result in a representation that is useful to recipients without
   implying that it represents the original target resource.  Note that
   answers to the questions of what can be represented, what
   representations are adequate, and what might be a useful description
   are outside the scope of HTTP.

   Except for responses to a HEAD request, the representation of a 303
   response ought to contain a short hypertext note with a hyperlink to
   the same URI reference provided in the Location header field.

https://tools.ietf.org/html/r...

2018年8月31日 23:04
編輯回答
愚念

推薦 《HTTP權(quán)威指南》,我記得狀態(tài)碼部分在附錄二,五百二十九頁還是多少。

2017年11月21日 22:48