Internet Engineering Task Force (IETF)                     M. Nottingham
Request for Comments: 6585                                     Rackspace
Updates: 2616                                                R. Fielding
Category: Standards Track                                          Adobe
ISSN: 2070-1721                                               April 2012
        
Internet Engineering Task Force (IETF)                     M. Nottingham
Request for Comments: 6585                                     Rackspace
Updates: 2616                                                R. Fielding
Category: Standards Track                                          Adobe
ISSN: 2070-1721                                               April 2012
        

Additional HTTP Status Codes

其他HTTP状态代码

Abstract

摘要

This document specifies additional HyperText Transfer Protocol (HTTP) status codes for a variety of common situations.

本文档为各种常见情况指定了附加的超文本传输协议(HTTP)状态代码。

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/rfc6585.

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

Copyright Notice

版权公告

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

版权所有(c)2012 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. Requirements ....................................................2
   3. 428 Precondition Required .......................................2
   4. 429 Too Many Requests ...........................................3
   5. 431 Request Header Fields Too Large .............................4
   6. 511 Network Authentication Required .............................4
   7. Security Considerations .........................................6
   8. IANA Considerations .............................................7
   9. References ......................................................7
   Appendix A. Acknowledgements .......................................9
   Appendix B. Issues Raised by Captive Portals .......................9
        
   1. Introduction ....................................................2
   2. Requirements ....................................................2
   3. 428 Precondition Required .......................................2
   4. 429 Too Many Requests ...........................................3
   5. 431 Request Header Fields Too Large .............................4
   6. 511 Network Authentication Required .............................4
   7. Security Considerations .........................................6
   8. IANA Considerations .............................................7
   9. References ......................................................7
   Appendix A. Acknowledgements .......................................9
   Appendix B. Issues Raised by Captive Portals .......................9
        
1. Introduction
1. 介绍

This document specifies additional HTTP [RFC2616] status codes for a variety of common situations, to improve interoperability and avoid confusion when other, less precise status codes are used.

本文档为各种常见情况指定了额外的HTTP[RFC2616]状态代码,以提高互操作性,并避免在使用其他不太精确的状态代码时出现混淆。

Note that these status codes are optional; servers cannot be required to support them. However, because clients will treat unknown status codes as a generic error of the same class (e.g., 499 is treated as 400 if it is not recognized), they can be safely deployed by existing servers (see [RFC2616] Section 6.1.1 for more information).

请注意,这些状态代码是可选的;不能要求服务器来支持它们。但是,由于客户端将未知状态代码视为同一类的一般错误(例如,如果无法识别499,则将其视为400),因此可以由现有服务器安全部署它们(有关更多信息,请参阅[RFC2616]第6.1.1节)。

2. Requirements
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. 428 Precondition Required
3. 需要428个前提条件

The 428 status code indicates that the origin server requires the request to be conditional.

428状态代码表示原始服务器要求请求是有条件的。

Its typical use is to avoid the "lost update" problem, where a client GETs a resource's state, modifies it, and PUTs it back to the server, when meanwhile a third party has modified the state on the server, leading to a conflict. By requiring requests to be conditional, the server can assure that clients are working with the correct copies.

它的典型用途是避免“丢失更新”问题,即当第三方修改服务器上的状态时,客户机获取资源的状态,对其进行修改,并将其放回服务器,从而导致冲突。通过要求请求是有条件的,服务器可以确保客户端使用的是正确的副本。

Responses using this status code SHOULD explain how to resubmit the request successfully. For example:

使用此状态代码的响应应说明如何成功重新提交请求。例如:

   HTTP/1.1 428 Precondition Required
   Content-Type: text/html
        
   HTTP/1.1 428 Precondition Required
   Content-Type: text/html
        
   <html>
      <head>
         <title>Precondition Required</title>
      </head>
      <body>
         <h1>Precondition Required</h1>
         <p>This request is required to be conditional;
         try using "If-Match".</p>
      </body>
   </html>
        
   <html>
      <head>
         <title>Precondition Required</title>
      </head>
      <body>
         <h1>Precondition Required</h1>
         <p>This request is required to be conditional;
         try using "If-Match".</p>
      </body>
   </html>
        

Responses with the 428 status code MUST NOT be stored by a cache.

带有428状态代码的响应不得由缓存存储。

4. 429 Too Many Requests
4. 429请求太多

The 429 status code indicates that the user has sent too many requests in a given amount of time ("rate limiting").

429状态代码表示用户在给定的时间内发送了过多的请求(“速率限制”)。

The response representations SHOULD include details explaining the condition, and MAY include a Retry-After header indicating how long to wait before making a new request.

响应表示应该包括解释条件的详细信息,并且可能包括指示在发出新请求之前等待多长时间的Retry After标头。

For example:

例如:

   HTTP/1.1 429 Too Many Requests
   Content-Type: text/html
   Retry-After: 3600
        
   HTTP/1.1 429 Too Many Requests
   Content-Type: text/html
   Retry-After: 3600
        
   <html>
      <head>
         <title>Too Many Requests</title>
      </head>
      <body>
         <h1>Too Many Requests</h1>
         <p>I only allow 50 requests per hour to this Web site per
            logged in user.  Try again soon.</p>
      </body>
   </html>
        
   <html>
      <head>
         <title>Too Many Requests</title>
      </head>
      <body>
         <h1>Too Many Requests</h1>
         <p>I only allow 50 requests per hour to this Web site per
            logged in user.  Try again soon.</p>
      </body>
   </html>
        

Note that this specification does not define how the origin server identifies the user, nor how it counts requests. For example, an origin server that is limiting request rates can do so based upon counts of requests on a per-resource basis, across the entire server, or even among a set of servers. Likewise, it might identify the user by its authentication credentials, or a stateful cookie.

请注意,此规范没有定义源服务器如何标识用户,也没有定义它如何统计请求。例如,限制请求速率的源服务器可以基于每个资源、整个服务器甚至一组服务器之间的请求计数来限制请求速率。同样,它可能通过其身份验证凭据或有状态cookie来识别用户。

Responses with the 429 status code MUST NOT be stored by a cache.

带有429状态代码的响应不能由缓存存储。

5. 431 Request Header Fields Too Large
5. 431请求标头字段太大

The 431 status code indicates that the server is unwilling to process the request because its header fields are too large. The request MAY be resubmitted after reducing the size of the request header fields.

431状态代码表示服务器不愿意处理请求,因为其标头字段太大。在减小请求头字段的大小后,可以重新提交请求。

It can be used both when the set of request header fields in total is too large, and when a single header field is at fault. In the latter case, the response representation SHOULD specify which header field was too large.

它既可以在请求头字段集合太大时使用,也可以在单个头字段出错时使用。在后一种情况下,响应表示应该指定哪个标头字段太大。

For example:

例如:

   HTTP/1.1 431 Request Header Fields Too Large
   Content-Type: text/html
        
   HTTP/1.1 431 Request Header Fields Too Large
   Content-Type: text/html
        
   <html>
      <head>
         <title>Request Header Fields Too Large</title>
      </head>
      <body>
         <h1>Request Header Fields Too Large</h1>
         <p>The "Example" header was too large.</p>
      </body>
   </html>
        
   <html>
      <head>
         <title>Request Header Fields Too Large</title>
      </head>
      <body>
         <h1>Request Header Fields Too Large</h1>
         <p>The "Example" header was too large.</p>
      </body>
   </html>
        

Responses with the 431 status code MUST NOT be stored by a cache.

带有431状态代码的响应不能由缓存存储。

6. 511 Network Authentication Required
6. 511需要网络身份验证

The 511 status code indicates that the client needs to authenticate to gain network access.

511状态代码表示客户端需要进行身份验证才能获得网络访问。

The response representation SHOULD contain a link to a resource that allows the user to submit credentials (e.g., with an HTML form).

响应表示应包含指向资源的链接,该资源允许用户提交凭据(例如,使用HTML表单)。

Note that the 511 response SHOULD NOT contain a challenge or the login interface itself, because browsers would show the login interface as being associated with the originally requested URL, which may cause confusion.

请注意,511响应不应包含质询或登录接口本身,因为浏览器会将登录接口显示为与最初请求的URL关联,这可能会导致混淆。

The 511 status SHOULD NOT be generated by origin servers; it is intended for use by intercepting proxies that are interposed as a means of controlling access to the network.

511状态不应由源服务器生成;它用于拦截作为控制网络访问的手段插入的代理。

Responses with the 511 status code MUST NOT be stored by a cache.

带有511状态代码的响应不能由缓存存储。

6.1. The 511 Status Code and Captive Portals
6.1. 511状态代码和捕获门户

The 511 status code is designed to mitigate problems caused by "captive portals" to software (especially non-browser agents) that is expecting a response from the server that a request was made to, not the intervening network infrastructure. It is not intended to encourage deployment of captive portals -- only to limit the damage caused by them.

511状态代码旨在缓解软件(尤其是非浏览器代理)的“捕获门户”所导致的问题,该软件期望从请求所针对的服务器(而非干预网络基础设施)得到响应。它并不是为了鼓励捕获门户的部署——只是为了限制它们造成的损害。

A network operator wishing to require some authentication, acceptance of terms, or other user interaction before granting access usually does so by identifying clients who have not done so ("unknown clients") using their Media Access Control (MAC) addresses.

网络运营商希望在授予访问权之前要求进行某种身份验证、接受条款或其他用户交互,通常通过使用其媒体访问控制(MAC)地址识别尚未这样做的客户端(“未知客户端”)来实现。

Unknown clients then have all traffic blocked, except for that on TCP port 80, which is sent to an HTTP server (the "login server") dedicated to "logging in" unknown clients, and of course traffic to the login server itself.

然后,未知客户端会阻止所有通信量,TCP端口80上的通信量除外,TCP端口80被发送到专用于“登录”未知客户端的HTTP服务器(“登录服务器”),当然还有登录服务器本身的通信量。

For example, a user agent might connect to a network and make the following HTTP request on TCP port 80:

例如,用户代理可能连接到网络并在TCP端口80上发出以下HTTP请求:

GET /index.htm HTTP/1.1 Host: www.example.com

GET/index.htm HTTP/1.1主机:www.example.com

Upon receiving such a request, the login server would generate a 511 response:

在收到此类请求后,登录服务器将生成511响应:

   HTTP/1.1 511 Network Authentication Required
   Content-Type: text/html
        
   HTTP/1.1 511 Network Authentication Required
   Content-Type: text/html
        
   <html>
      <head>
         <title>Network Authentication Required</title>
         <meta http-equiv="refresh"
               content="0; url=https://login.example.net/">
      </head>
      <body>
         <p>You need to <a href="https://login.example.net/">
         authenticate with the local network</a> in order to gain
         access.</p>
      </body>
   </html>
        
   <html>
      <head>
         <title>Network Authentication Required</title>
         <meta http-equiv="refresh"
               content="0; url=https://login.example.net/">
      </head>
      <body>
         <p>You need to <a href="https://login.example.net/">
         authenticate with the local network</a> in order to gain
         access.</p>
      </body>
   </html>
        

Here, the 511 status code assures that non-browser clients will not interpret the response as being from the origin server, and the META HTML element redirects the user agent to the login server.

这里,511状态代码确保非浏览器客户端不会将响应解释为来自源服务器,并且META-HTML元素将用户代理重定向到登录服务器。

7. Security Considerations
7. 安全考虑
7.1. 428 Precondition Required
7.1. 需要428个前提条件

The 428 status code is optional; clients cannot rely upon its use to prevent "lost update" conflicts.

428状态代码是可选的;客户端不能依赖它的使用来防止“丢失更新”冲突。

7.2. 429 Too Many Requests
7.2. 429请求太多

When a server is under attack or just receiving a very large number of requests from a single party, responding to each with a 429 status code will consume resources.

当服务器受到攻击或仅从一方接收大量请求时,使用429状态码响应每个请求将消耗资源。

Therefore, servers are not required to use the 429 status code; when limiting resource usage, it may be more appropriate to just drop connections, or take other steps.

因此,服务器不需要使用429状态代码;在限制资源使用时,只断开连接或采取其他步骤可能更合适。

7.3. 431 Request Header Fields Too Large
7.3. 431请求标头字段太大

Servers are not required to use the 431 status code; when under attack, it may be more appropriate to just drop connections, or take other steps.

服务器不需要使用431状态代码;当受到攻击时,可能更适合直接断开连接或采取其他步骤。

7.4. 511 Network Authentication Required
7.4. 511需要网络身份验证

In common use, a response carrying the 511 status code will not come from the origin server indicated in the request's URL. This presents many security issues; e.g., an attacking intermediary may be inserting cookies into the original domain's name space, may be observing cookies or HTTP authentication credentials sent from the user agent, and so on.

通常,带有511状态代码的响应不会来自请求URL中指示的源服务器。这带来了许多安全问题;e、 例如,攻击中介可能正在将cookie插入原始域的名称空间,可能正在观察从用户代理发送的cookie或HTTP身份验证凭据,等等。

However, these risks are not unique to the 511 status code; in other words, a captive portal that is not using this status code introduces the same issues.

然而,这些风险并非511状态代码所独有;换句话说,不使用此状态代码的捕获门户也会出现同样的问题。

Also, note that captive portals using this status code on a Secure Socket Layer (SSL) or Transport Layer Security (TLS) connection (commonly, port 443) will generate a certificate error on the client.

另外,请注意,在安全套接字层(SSL)或传输层安全性(TLS)连接(通常为端口443)上使用此状态代码的捕获门户将在客户端上生成证书错误。

8. IANA Considerations
8. IANA考虑

The HTTP Status Codes registry has been updated with the following entries:

HTTP状态代码注册表已更新为以下条目:

Value: 428 Description: Precondition Required Reference: [RFC6585]

值:428说明:前提条件所需参考:[RFC6585]

Value: 429 Description: Too Many Requests Reference: [RFC6585]

值:429说明:请求太多参考:[RFC6585]

Value: 431 Description: Request Header Fields Too Large Reference: [RFC6585]

值:431说明:请求标头字段太大引用:[RFC6585]

Value: 511 Description: Network Authentication Required Reference: [RFC6585]

值:511说明:需要网络身份验证参考:[RFC6585]

9. References
9. 工具书类
9.1. Normative References
9.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月。

[RFC2616] Fielding, R., Gettys, J., Mogul, J., Frystyk, H., Masinter, L., Leach, P., and T. Berners-Lee, "Hypertext Transfer Protocol -- HTTP/1.1", RFC 2616, June 1999.

[RFC2616]菲尔丁,R.,盖蒂斯,J.,莫卧儿,J.,弗莱斯蒂克,H.,马斯特,L.,利奇,P.,和T.伯纳斯李,“超文本传输协议——HTTP/1.1”,RFC 2616,1999年6月。

9.2. Informative References
9.2. 资料性引用

[CORS] van Kesteren, A., Ed., "Cross-Origin Resource Sharing", W3C Working Draft WD-cors-20100727, July 2010, <http://www.w3.org/TR/cors/>.

[CORS]van Kesteren,A.,Ed.,“跨来源资源共享”,W3C工作草案WD-CORS-20100727,2010年7月<http://www.w3.org/TR/cors/>.

[Favicon] Wikipedia, "Favicon", March 2012, <http://en.wikipedia.org/w/ index.php?title=Favicon&oldid=484627550>.

[Favicon]维基百科,“Favicon”,2012年3月<http://en.wikipedia.org/w/ index.php?title=Favicon&oldid=484627550>。

[OAuth2.0] Hammer-Lahav, E., Ed., Recordon, D., and D. Hardt, "The OAuth 2.0 Authorization Protocol", Work in Progress, March 2012.

[OAuth2.0]Hammer Lahav,E.,Ed.,Recordon,D.和D.Hardt,“OAuth2.0授权协议”,正在进行的工作,2012年3月。

[P3P] Marchiori, M., Ed., "The Platform for Privacy Preferences 1.0 (P3P1.0) Specification", W3C Recommendation REC-P3P-20020416, April 2002, <http://www.w3.org/TR/P3P/>.

[P3P]Marchiori,M.,Ed.“隐私偏好平台1.0(P3P1.0)规范”,W3C建议REC-P3P-20020416,2002年4月<http://www.w3.org/TR/P3P/>.

[RFC4791] Daboo, C., Desruisseaux, B., and L. Dusseault, "Calendaring Extensions to WebDAV (CalDAV)", RFC 4791, March 2007.

[RFC4791]Daboo,C.,Desruisseaux,B.,和L.Dusseault,“WebDAV(CalDAV)的日历扩展”,RFC 47912007年3月。

[RFC4918] Dusseault, L., Ed., "HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV)", RFC 4918, June 2007.

[RFC4918]Dusseault,L.,Ed.“Web分布式创作和版本控制(WebDAV)的HTTP扩展”,RFC4918,2007年6月。

[WIDGETS] Caceres, M., Ed., "Widget Packaging and XML Configuration", W3C Recommendation REC-widgets-20110927, September 2011, <http://www.w3.org/TR/widgets/>.

[WIDGETS]Caceres,M.,Ed.,“Widget包装和XML配置”,W3C建议REC-WIDGETS-20110927,2011年9月<http://www.w3.org/TR/widgets/>.

[WebFinger] WebFinger Project, "WebFingerProtocol (Draft)", January 2010, <http://code.google.com/p/webfinger/wiki/ WebFingerProtocol>.

[WebFinger]WebFinger项目,“WebFingerProtocol(草案)”,2010年1月<http://code.google.com/p/webfinger/wiki/ WebFingerProtocol>。

Appendix A. Acknowledgements
附录A.确认书

Thanks to Jan Algermissen and Julian Reschke for their suggestions and feedback.

感谢Jan Algermissen和Julian Reschke的建议和反馈。

Appendix B. Issues Raised by Captive Portals
附录B.专属门户提出的问题

Since clients cannot differentiate between a portal's response and that of the HTTP server that they intended to communicate with, a number of issues arise. The 511 status code is intended to help mitigate some of them.

由于客户端无法区分门户的响应和它们打算与之通信的HTTP服务器的响应,因此出现了许多问题。511状态代码旨在帮助缓解其中一些问题。

One example is the "favicon.ico" [Favicon] commonly used by browsers to identify the site being accessed. If the favicon for a given site is fetched from a captive portal instead of the intended site (e.g., because the user is unauthenticated), it will often "stick" in the browser's cache (most implementations cache favicons aggressively) beyond the portal session, so that it seems as if the portal's favicon has "taken over" the legitimate site.

一个例子是浏览器常用的“favicon.ico”[favicon]来识别正在访问的站点。如果给定站点的favicon是从捕获门户而非预期站点获取的(例如,因为用户未经身份验证),则它通常会在门户会话之外“粘滞”在浏览器缓存中(大多数实现都会主动缓存favicon),因此门户的favicon似乎已经“接管”了合法站点。

Another browser-based issue comes about when the Platform for Privacy Preferences [P3P] is supported. Depending on how it is implemented, it's possible a browser might interpret a portal's response for the p3p.xml file as the server's, resulting in the privacy policy (or lack thereof) advertised by the portal being interpreted as applying to the intended site. Other Web-based protocols such as WebFinger [WebFinger], Cross-Origin Resource Sharing [CORS], and Open Authorization [OAuth2.0] may also be vulnerable to such issues.

另一个基于浏览器的问题是,当支持隐私偏好平台[P3P]时。根据实现方式的不同,浏览器可能会将门户对p3p.xml文件的响应解释为服务器的响应,从而导致门户发布的隐私策略(或缺乏隐私策略)被解释为适用于预期站点。其他基于Web的协议,如WebFinger[WebFinger]、跨源资源共享[CORS]和开放授权[OAuth2.0]也可能容易受到此类问题的攻击。

Although HTTP is most widely used with Web browsers, a growing number of non-browsing applications use it as a substrate protocol. For example, Web Distributed Authoring and Versioning (WebDAV) [RFC4918] and Calendaring Extensions to WebDAV (CalDAV) [RFC4791] both use HTTP as the basis (for remote authoring and calendaring, respectively). Using these applications from behind a captive portal can result in spurious errors being presented to the user, and might result in content corruption, in extreme cases.

虽然HTTP在Web浏览器中使用最为广泛,但越来越多的非浏览应用程序将其用作底层协议。例如,Web分布式创作和版本控制(WebDAV)[RFC4918]和WebDAV的日历扩展(CalDAV)[RFC4791]都使用HTTP作为基础(分别用于远程创作和日历)。从捕获门户后面使用这些应用程序可能会导致向用户呈现虚假错误,在极端情况下可能会导致内容损坏。

Similarly, other non-browser applications using HTTP can be affected as well, e.g., widgets [WIDGETS], software updates, and other specialized software such as Twitter clients and the iTunes Music Store.

类似地,使用HTTP的其他非浏览器应用程序也会受到影响,例如小部件、软件更新和其他专用软件,如Twitter客户端和iTunes音乐商店。

It should be noted that it's sometimes believed that using HTTP redirection to direct traffic to the portal addresses these issues. However, since many of these uses "follow" redirects, this is not a good solution.

应该注意的是,有时认为使用HTTP重定向将流量定向到门户可以解决这些问题。然而,由于其中许多使用“跟随”重定向,这不是一个好的解决方案。

Authors' Addresses

作者地址

Mark Nottingham Rackspace

马克诺丁汉货架空间

   EMail: mnot@mnot.net
   URI:   http://www.mnot.net/
        
   EMail: mnot@mnot.net
   URI:   http://www.mnot.net/
        

Roy T. Fielding Adobe Systems Incorporated 345 Park Ave. San Jose, CA 95110 USA

Roy T.Fielding Adobe Systems Incorporated美国加利福尼亚州圣何塞公园大道345号,邮编95110

   EMail: fielding@gbiv.com
   URI:   http://roy.gbiv.com/
        
   EMail: fielding@gbiv.com
   URI:   http://roy.gbiv.com/