Internet Engineering Task Force (IETF)                        J. Reschke
Request for Comments: 7238                                    greenbytes
Category: Experimental                                         June 2014
ISSN: 2070-1721
        
Internet Engineering Task Force (IETF)                        J. Reschke
Request for Comments: 7238                                    greenbytes
Category: Experimental                                         June 2014
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 document is not an Internet Standards Track specification; it is published for examination, experimental implementation, and evaluation.

本文件不是互联网标准跟踪规范;它是为检查、实验实施和评估而发布的。

This document defines an Experimental Protocol for the Internet community. 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). Not all documents approved by the IESG are a candidate for any level of Internet Standard; see Section 2 of RFC 5741.

本文档为互联网社区定义了一个实验协议。本文件是互联网工程任务组(IETF)的产品。它代表了IETF社区的共识。它已经接受了公众审查,并已被互联网工程指导小组(IESG)批准出版。并非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/rfc7238.

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

Copyright Notice

版权公告

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

版权所有(c)2014 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  . . . . . . . . . . . . . . . . . . . . 2
   4.  Deployment Considerations . . . . . . . . . . . . . . . . . . . 3
   5.  Security Considerations . . . . . . . . . . . . . . . . . . . . 4
   6.  IANA Considerations . . . . . . . . . . . . . . . . . . . . . . 4
   7.  Acknowledgements  . . . . . . . . . . . . . . . . . . . . . . . 5
   8.  References  . . . . . . . . . . . . . . . . . . . . . . . . . . 5
     8.1.  Normative References  . . . . . . . . . . . . . . . . . . . 5
     8.2.  Informative References  . . . . . . . . . . . . . . . . . . 5
        
   1.  Introduction  . . . . . . . . . . . . . . . . . . . . . . . . . 2
   2.  Notational Conventions  . . . . . . . . . . . . . . . . . . . . 2
   3.  308 Permanent Redirect  . . . . . . . . . . . . . . . . . . . . 2
   4.  Deployment Considerations . . . . . . . . . . . . . . . . . . . 3
   5.  Security Considerations . . . . . . . . . . . . . . . . . . . . 4
   6.  IANA Considerations . . . . . . . . . . . . . . . . . . . . . . 4
   7.  Acknowledgements  . . . . . . . . . . . . . . . . . . . . . . . 5
   8.  References  . . . . . . . . . . . . . . . . . . . . . . . . . . 5
     8.1.  Normative References  . . . . . . . . . . . . . . . . . . . 5
     8.2.  Informative References  . . . . . . . . . . . . . . . . . . 5
        
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 HTTP 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节规定,HTTP未定义状态代码307的永久变体;本规范添加了状态代码308,定义了该缺失变量(第3节)。

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.

308(永久重定向)状态代码表示已为目标资源分配了一个新的永久URI,将来对该资源的任何引用都应该使用其中一个附带的URI。

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.

具有链接编辑功能的客户端应尽可能自动将对有效请求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, initial use of status code 308 will be 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]). This can be used as another fallback. For example:

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

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: 454
        
     HTTP/1.1 308 Permanent Redirect
     Content-Type: text/html; charset=UTF-8
     Location: http://example.com/new
     Content-Length: 454
        
     <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
                           "http://www.w3.org/TR/html4/strict.dtd">
     <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 PUBLIC "-//W3C//DTD HTML 4.01//EN"
                           "http://www.w3.org/TR/html4/strict.dtd">
     <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节)。

6. IANA Considerations
6. IANA考虑

The registration below has been added to 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>):

下面的注册已添加到“超文本传输协议(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. Acknowledgements
7. 致谢

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, Eran Hammer-Lahav, Bjoern Hoehrmann, Subramanian Moonesamy, Peter Saint-Andre, and Robert Sparks for feedback on this document.

此外,感谢Ben Campbell、Cyrus Daboo、Eran Hammer Lahav、Bjoern Hoehrmann、Subramanian Moonesay、Peter Saint Andre和Robert Sparks对本文件的反馈。

8. References
8. 工具书类
8.1. Normative References
8.1. 规范性引用文件

[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, March 1997.

[RFC2119]Bradner,S.,“RFC中用于表示需求水平的关键词”,BCP 14,RFC 2119,1997年3月。

[RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform Resource Identifier (URI): Generic Syntax", STD 66, RFC 3986, January 2005.

[RFC3986]Berners Lee,T.,Fielding,R.,和L.Masinter,“统一资源标识符(URI):通用语法”,STD 66,RFC 3986,2005年1月。

[RFC7230] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing", RFC 7230, June 2014.

[RFC7230]Fielding,R.,Ed.和J.Reschke,Ed.,“超文本传输协议(HTTP/1.1):消息语法和路由”,RFC 7230,2014年6月。

[RFC7231] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content", RFC 7231, June 2014.

[RFC7231]Fielding,R.,Ed.和J.Reschke,Ed.,“超文本传输协议(HTTP/1.1):语义和内容”,RFC 72312014年6月。

[RFC7234] Fielding, R., Ed., Nottingham, M., Ed., and J. Reschke, Ed., "Hypertext Transfer Protocol (HTTP/1.1): Caching", RFC 7234, June 2014.

[RFC7234]Fielding,R.,Ed.,Nottingham,M.,Ed.,和J.Reschke,Ed.,“超文本传输协议(HTTP/1.1):缓存”,RFC 7234,2014年6月。

8.2. Informative References
8.2. 资料性引用

[HTML] Raggett, D., Le Hors, A., and I. Jacobs, "HTML 4.01 Specification", W3C Recommendation REC-html401-19991224, December 1999, <http://www.w3.org/TR/1999/REC-html401-19991224>.

[HTML]Raggett,D.,Le Hors,A.,和I.Jacobs,“HTML 4.01规范”,W3C建议REC-html401-19991224,1999年12月<http://www.w3.org/TR/1999/REC-html401-19991224>.

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

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

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/