代码之家  ›  专栏  ›  技术社区  ›  GilliVilla

HTTP302是如何工作的?

  •  44
  • GilliVilla  · 技术社区  · 14 年前

    HTTP302是如何工作的?我想知道里面的东西

    5 回复  |  直到 14 年前
        1
  •  54
  •   Michael Mrozek    14 年前

    你是说浏览器怎么处理?服务器发送 302 代码与 Location 头,浏览器请求 位置 而不是标题。

    301 (Moved Permanently) ,浏览器继续使用原始URI执行请求,以防 密码消失了

        2
  •  22
  •   Tyler McHenry    14 年前

    服务器返回带有代码的HTTP响应 302 Location: 指示新URI的头,例如。

    HTTP/1.1 302 Found
    Location: http://some-other-url
    

    以及可能由服务器决定的其他标头。

    浏览器通常将此作为一个指令,自动对location头指定的另一个URI发出新的、单独的请求。客户端(浏览器)不可用 强迫 要做到这一点(理论上,它可以只向用户显示一条消息,或者做它想做的任何事情),但这就是HTTP客户机通常的行为方式。

    暂时的

        3
  •  10
  •   xgMz    14 年前

    发件人: http://www.ietf.org/rfc/rfc2616.txt http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

    10.3.3 找到302个

    请求的资源临时驻留在不同的URI下。 由于重定向有时可能会被更改,因此客户端应该 继续为将来的请求使用请求URI。这种反应 仅当由缓存控件或Expires标头指示时才可缓存 现场。

    回应。除非请求方法是HEAD,否则 响应应包含一个简短的超文本注释,并带有指向的超链接 新URI。

    而不是GET或HEAD,用户代理不能自动重定向 更改发出请求的条件。

      Note: RFC 1945 and RFC 2068 specify that the client is not allowed
      to change the method on the redirected request.  However, most
      existing user agent implementations treat 302 as if it were a 303
      response, performing a GET on the Location field-value regardless
      of the original request method. The status codes 303 and 307 have
      been added for servers that wish to make unambiguously clear which
      kind of reaction is expected of the client.
    
        4
  •  2
  •   James Antill    14 年前

    应该 但在现实世界中,主流浏览器对301、302、303和307的处理方式是相同的。

        5
  •  1
  •   A.T.    11 年前

    只是个插件-