Internet Engineering Task Force (IETF)                        J. Reschke
Request for Comments: 7538                                    greenbytes
Obsoletes: 7238                                               April 2015
Category: Standards Track
ISSN: 2070-1721
        
Internet Engineering Task Force (IETF)                        J. Reschke
Request for Comments: 7538                                    greenbytes
Obsoletes: 7238                                               April 2015
Category: Standards Track
ISSN: 2070-1721
        

The Hypertext Transfer Protocol Status Code 308 (Permanent Redirect)

超文本传输协议状态代码308(永久重定向)

Abstract

摘要

This document specifies the additional Hypertext Transfer Protocol (HTTP) status code 308 (Permanent Redirect).

本文件规定了附加超文本传输协议(HTTP)状态代码308(永久重定向)。

Status of This Memo

关于下段备忘

This is an Internet Standards Track document.

这是一份互联网标准跟踪文件。

This document is a product of the Internet Engineering Task Force (IETF). It represents the consensus of the IETF community. It has received public review and has been approved for publication by the Internet Engineering Steering Group (IESG). Further information on Internet Standards is available in Section 2 of RFC 5741.

本文件是互联网工程任务组(IETF)的产品。它代表了IETF社区的共识。它已经接受了公众审查,并已被互联网工程指导小组(IESG)批准出版。有关互联网标准的更多信息,请参见RFC 5741第2节。

Information about the current status of this document, any errata, and how to provide feedback on it may be obtained at http://www.rfc-editor.org/info/rfc7538.

有关本文件当前状态、任何勘误表以及如何提供反馈的信息,请访问http://www.rfc-editor.org/info/rfc7538.

Copyright Notice

版权公告

Copyright (c) 2015 IETF Trust and the persons identified as the document authors. All rights reserved.

版权所有(c)2015 IETF信托基金和确定为文件作者的人员。版权所有。

This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (http://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.

本文件受BCP 78和IETF信托有关IETF文件的法律规定的约束(http://trustee.ietf.org/license-info)自本文件出版之日起生效。请仔细阅读这些文件,因为它们描述了您对本文件的权利和限制。从本文件中提取的代码组件必须包括信托法律条款第4.e节中所述的简化BSD许可证文本,并提供简化BSD许可证中所述的无担保。

Table of Contents

目录

   1.  Introduction  . . . . . . . . . . . . . . . . . . . . . . . .   2
   2.  Notational Conventions  . . . . . . . . . . . . . . . . . . .   2
   3.  308 Permanent Redirect  . . . . . . . . . . . . . . . . . . .   3
   4.  Deployment Considerations . . . . . . . . . . . . . . . . . .   3
   5.  Security Considerations . . . . . . . . . . . . . . . . . . .   4
   6.  IANA Considerations . . . . . . . . . . . . . . . . . . . . .   5
   7.  References  . . . . . . . . . . . . . . . . . . . . . . . . .   5
     7.1.  Normative References  . . . . . . . . . . . . . . . . . .   5
     7.2.  Informative References  . . . . . . . . . . . . . . . . .   5
   Acknowledgements  . . . . . . . . . . . . . . . . . . . . . . . .   6
   Author's Address  . . . . . . . . . . . . . . . . . . . . . . . .   6
        
   1.  Introduction  . . . . . . . . . . . . . . . . . . . . . . . .   2
   2.  Notational Conventions  . . . . . . . . . . . . . . . . . . .   2
   3.  308 Permanent Redirect  . . . . . . . . . . . . . . . . . . .   3
   4.  Deployment Considerations . . . . . . . . . . . . . . . . . .   3
   5.  Security Considerations . . . . . . . . . . . . . . . . . . .   4
   6.  IANA Considerations . . . . . . . . . . . . . . . . . . . . .   5
   7.  References  . . . . . . . . . . . . . . . . . . . . . . . . .   5
     7.1.  Normative References  . . . . . . . . . . . . . . . . . .   5
     7.2.  Informative References  . . . . . . . . . . . . . . . . .   5
   Acknowledgements  . . . . . . . . . . . . . . . . . . . . . . . .   6
   Author's Address  . . . . . . . . . . . . . . . . . . . . . . . .   6
        
1. Introduction
1. 介绍

HTTP defines a set of status codes for the purpose of redirecting a request to a different URI ([RFC3986]). The history of these status codes is summarized in Section 6.4 of [RFC7231], which also classifies the existing status codes into four categories.

HTTP定义了一组状态代码,用于将请求重定向到不同的URI([RFC3986])。[RFC7231]第6.4节总结了这些状态代码的历史,该节还将现有状态代码分为四类。

The first of these categories contains the status codes 301 (Moved Permanently), 302 (Found), and 307 (Temporary Redirect), which can be classified as below:

其中第一个类别包含状态代码301(永久移动)、302(找到)和307(临时重定向),可分为以下几类:

   +-------------------------------------------+-----------+-----------+
   |                                           | Permanent | Temporary |
   +-------------------------------------------+-----------+-----------+
   | Allows changing the request method from   | 301       | 302       |
   | POST to GET                               |           |           |
   | Does not allow changing the request       | -         | 307       |
   | method from POST to GET                   |           |           |
   +-------------------------------------------+-----------+-----------+
        
   +-------------------------------------------+-----------+-----------+
   |                                           | Permanent | Temporary |
   +-------------------------------------------+-----------+-----------+
   | Allows changing the request method from   | 301       | 302       |
   | POST to GET                               |           |           |
   | Does not allow changing the request       | -         | 307       |
   | method from POST to GET                   |           |           |
   +-------------------------------------------+-----------+-----------+
        

Section 6.4.7 of [RFC7231] states that it does not define a permanent variant of status code 307; this specification adds the status code 308, defining this missing variant (Section 3).

[RFC7231]第6.4.7节规定,其未定义状态代码307的永久变体;本规范添加了状态代码308,定义了该缺失变量(第3节)。

This specification contains no technical changes from the Experimental RFC 7238, which it obsoletes.

本规范不包含已废弃的实验性RFC 7238的技术变更。

2. Notational Conventions
2. 符号约定

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC2119].

本文件中的关键词“必须”、“不得”、“必需”、“应”、“不应”、“应”、“不应”、“建议”、“可”和“可选”应按照[RFC2119]中所述进行解释。

3. 308 Permanent Redirect
3. 308永久重定向

The 308 (Permanent Redirect) status code indicates that the target resource has been assigned a new permanent URI and any future references to this resource ought to use one of the enclosed URIs. Clients with link editing capabilities ought to automatically re-link references to the effective request URI (Section 5.5 of [RFC7230]) to one or more of the new references sent by the server, where possible.

308(永久重定向)状态代码表示已为目标资源分配了一个新的永久URI,将来对该资源的任何引用都应该使用其中一个附带的URI。具有链接编辑功能的客户端应尽可能自动将对有效请求URI的引用(RFC7230第5.5节)重新链接到服务器发送的一个或多个新引用。

The server SHOULD generate a Location header field ([RFC7231], Section 7.1.2) in the response containing a preferred URI reference for the new permanent 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 new URI(s).

服务器应在响应中生成一个位置头字段([RFC7231],第7.1.2节),其中包含新永久URI的首选URI引用。用户代理可以使用位置字段值进行自动重定向。服务器的响应负载通常包含一个简短的超文本注释,其中包含指向新URI的超链接。

A 308 response is cacheable by default; i.e., unless otherwise indicated by the method definition or explicit cache controls (see [RFC7234], Section 4.2.2).

308响应在默认情况下是可缓存的;i、 e.,除非方法定义或显式缓存控制另有说明(见[RFC7234],第4.2.2节)。

Note: This status code is similar to 301 (Moved Permanently) ([RFC7231], Section 6.4.2), except that it does not allow changing the request method from POST to GET.

注:此状态代码类似于301(永久移动)([RFC7231],第6.4.2节),只是不允许将请求方法从POST更改为GET。

4. Deployment Considerations
4. 部署注意事项

Section 6 of [RFC7231] requires recipients to treat unknown 3xx status codes the same way as status code 300 (Multiple Choices) ([RFC7231], Section 6.4.1). Thus, servers will not be able to rely on automatic redirection happening similar to status codes 301, 302, or 307.

[RFC7231]第6节要求收件人以与状态代码300(多选)相同的方式处理未知的3xx状态代码([RFC7231]第6.4.1节)。因此,服务器将无法依赖与状态代码301、302或307类似的自动重定向。

Therefore, the use of status code 308 is restricted to cases where the server has sufficient confidence in the client's understanding the new code or when a fallback to the semantics of status code 300 is not problematic. Server implementers are advised not to vary the status code based on characteristics of the request, such as the User-Agent header field ("User-Agent Sniffing") -- doing so usually results in code that is both hard to maintain and hard to debug and would also require special attention to caching (i.e., setting a "Vary" response header field, as defined in Section 7.1.4 of [RFC7231]).

因此,状态代码308的使用仅限于服务器对客户端理解新代码有足够信心的情况,或者当回退到状态代码300的语义没有问题时。建议服务器实现者不要根据请求的特征更改状态代码,例如用户代理标头字段(“用户代理嗅探”)——这样做通常会导致代码难以维护和调试,并且还需要特别注意缓存(即设置“vary”)响应标题字段,如[RFC7231]第7.1.4节所定义。

Note that many existing HTML-based user agents will emulate a refresh when encountering an HTML <meta> refresh directive ([HTML], Section 4.2.5.3). This can be used as another fallback. For example:

请注意,许多现有的基于HTML的用户代理在遇到HTML<meta>refresh指令([HTML],第4.2.5.3节)时将模拟刷新。这可以用作另一个后备方案。例如:

Client request:

客户请求:

GET / HTTP/1.1 Host: example.com

GET/HTTP/1.1主机:example.com

Server response:

服务器响应:

     HTTP/1.1 308 Permanent Redirect
     Content-Type: text/html; charset=UTF-8
     Location: http://example.com/new
     Content-Length: 356
        
     HTTP/1.1 308 Permanent Redirect
     Content-Type: text/html; charset=UTF-8
     Location: http://example.com/new
     Content-Length: 356
        
     <!DOCTYPE HTML>
     <html>
        <head>
           <title>Permanent Redirect</title>
           <meta http-equiv="refresh"
                 content="0; url=http://example.com/new">
        </head>
        <body>
           <p>
              The document has been moved to
              <a href="http://example.com/new"
              >http://example.com/new</a>.
           </p>
        </body>
     </html>
        
     <!DOCTYPE HTML>
     <html>
        <head>
           <title>Permanent Redirect</title>
           <meta http-equiv="refresh"
                 content="0; url=http://example.com/new">
        </head>
        <body>
           <p>
              The document has been moved to
              <a href="http://example.com/new"
              >http://example.com/new</a>.
           </p>
        </body>
     </html>
        
5. Security Considerations
5. 安全考虑

All security considerations that apply to HTTP redirects apply to the 308 status code as well (see Section 9 of [RFC7231]).

适用于HTTP重定向的所有安全注意事项也适用于308状态代码(参见[RFC7231]第9节)。

Unsecured communication over the Internet is subject to man-in-the-middle modification of messages, including changing status codes or redirect targets. Use of Transport Layer Security (TLS) is one way to mitigate those attacks. See Section 9 of [RFC7230] for related attacks on authority and message integrity.

互联网上的不安全通信会受到中间人修改消息的影响,包括更改状态代码或重定向目标。使用传输层安全性(TLS)是缓解这些攻击的一种方法。有关对权限和消息完整性的相关攻击,请参见[RFC7230]的第9节。

6. IANA Considerations
6. IANA考虑

The "Hypertext Transfer Protocol (HTTP) Status Code Registry" (defined in Section 8.2 of [RFC7231] and located at <http://www.iana.org/assignments/http-status-codes>) has been updated to reference this specification.

“超文本传输协议(HTTP)状态代码注册表”(定义见[RFC7231]第8.2节,位于<http://www.iana.org/assignments/http-status-codes>)已更新为参考本规范。

   +-------+--------------------+----------------------------------+
   | Value | Description        | Reference                        |
   +-------+--------------------+----------------------------------+
   | 308   | Permanent Redirect | Section 3 of this specification  |
   +-------+--------------------+----------------------------------+
        
   +-------+--------------------+----------------------------------+
   | Value | Description        | Reference                        |
   +-------+--------------------+----------------------------------+
   | 308   | Permanent Redirect | Section 3 of this specification  |
   +-------+--------------------+----------------------------------+
        
7. References
7. 工具书类
7.1. Normative References
7.1. 规范性引用文件

[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, March 1997, <http://www.rfc-editor.org/info/rfc2119>.

[RFC2119]Bradner,S.,“RFC中用于表示需求水平的关键词”,BCP 14,RFC 2119,1997年3月<http://www.rfc-editor.org/info/rfc2119>.

[RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform Resource Identifier (URI): Generic Syntax", STD 66, RFC 3986, January 2005, <http://www.rfc-editor.org/info/rfc3986>.

[RFC3986]Berners Lee,T.,Fielding,R.,和L.Masinter,“统一资源标识符(URI):通用语法”,STD 66,RFC 3986,2005年1月<http://www.rfc-editor.org/info/rfc3986>.

[RFC7230] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing", RFC 7230, June 2014, <http://www.rfc-editor.org/info/rfc7230>.

[RFC7230]Fielding,R.,Ed.和J.Reschke,Ed.,“超文本传输协议(HTTP/1.1):消息语法和路由”,RFC 7230,2014年6月<http://www.rfc-editor.org/info/rfc7230>.

[RFC7231] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content", RFC 7231, June 2014, <http://www.rfc-editor.org/info/rfc7231>.

[RFC7231]Fielding,R.,Ed.和J.Reschke,Ed.,“超文本传输协议(HTTP/1.1):语义和内容”,RFC 72312014年6月<http://www.rfc-editor.org/info/rfc7231>.

[RFC7234] Fielding, R., Ed., Nottingham, M., Ed., and J. Reschke, Ed., "Hypertext Transfer Protocol (HTTP/1.1): Caching", RFC 7234, June 2014, <http://www.rfc-editor.org/info/rfc7234>.

[RFC7234]Fielding,R.,Ed.,Nottingham,M.,Ed.,和J.Reschke,Ed.,“超文本传输协议(HTTP/1.1):缓存”,RFC 7234,2014年6月<http://www.rfc-editor.org/info/rfc7234>.

7.2. Informative References
7.2. 资料性引用

[HTML] Hickson, I., Berjon, R., Faulkner, S., Leithead, T., Doyle Navara, E., O'Connor, E., and S. Pfeiffer, "HTML5", W3C Recommendation REC-html5-20141028, October 2014, <http://www.w3.org/TR/2014/REC-html5-20141028/>.

[HTML]Hickson,I.,Berjon,R.,Faulkner,S.,Leithead,T.,Doyle Navara,E.,O'Connor,E.,和S.Pfeiffer,“HTML5”,W3C建议REC-HTML5-20141028,2014年10月<http://www.w3.org/TR/2014/REC-html5-20141028/>.

Latest version available at <http://www.w3.org/TR/html5/>.

最新版本可于<http://www.w3.org/TR/html5/>.

Acknowledgements

致谢

The definition for the new status code 308 reuses text from the HTTP/1.1 definitions of status codes 301 and 307.

新状态代码308的定义重用来自状态代码301和307的HTTP/1.1定义的文本。

Furthermore, thanks to Ben Campbell, Cyrus Daboo, Adrian Farrell, Eran Hammer-Lahav, Bjoern Hoehrmann, Barry Leiba, Subramanian Moonesamy, Kathleen Moriarty, Peter Saint-Andre, Robert Sparks, and Roy Fielding for feedback on this document.

此外,感谢Ben Campbell、Cyrus Daboo、Adrian Farrell、Eran Hammer Lahav、Bjoern Hoehrmann、Barry Leiba、Subramanian Moonesamy、Kathleen Moriarty、Peter Saint Andre、Robert Sparks和Roy Fielding对本文件的反馈。

Author's Address

作者地址

Julian F. Reschke greenbytes GmbH Hafenweg 16 Muenster, NW 48155 Germany

Julian F.Reschke greenbytes GmbH Hafenweg 16 Muenster,西北48155德国

   EMail: julian.reschke@greenbytes.de
   URI:   http://greenbytes.de/tech/webdav/
        
   EMail: julian.reschke@greenbytes.de
   URI:   http://greenbytes.de/tech/webdav/