互联网工程任务组(IETF) R. Hamilton
请求注释:9220 Google
类别:标准轨道 2022年6月
ISSN:2070-1721

使用 HTTP/3 引导 WebSockets


摘要

在单个 HTTP/2 连接流上运行 WebSocket 协议的机制同样适用于 HTTP/3,但需要指定与 HTTP 版本相关的具体细节。本文档描述了该机制如何为 HTTP/3 进行适配。

本备忘录状态

这是一个互联网标准轨道文档。

本文档是互联网工程任务组(IETF)的产物。它代表了 IETF 社区的共识。该文档已接受公开审查并已获互联网工程指导组(IESG)批准发布。有关互联网标准的更多信息,请参阅 RFC 7841 第 2 节

有关本文件当前状态、任何勘误以及如何提供反馈的信息,可在 https://www.rfc-editor.org/info/rfc9220 获得。

Copyright Notice

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

This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://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 Revised BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Revised BSD License.


1. 引言

"使用 HTTP/2 引导 WebSockets" [RFC8441] 定义了一个对 HTTP/2 [HTTP/2] 的扩展,该扩展在 HTTP/3 [HTTP/3] 中同样有用。该扩展使用了一个 HTTP/2 设置。HTTP/3 的附录 A.3 对将设置从 HTTP/2 移植到 HTTP/3 时应做出的更改(如有)提供了一些指导。


2. 约定与定义

本文档中出现的关键字 "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", 和 "OPTIONAL" 应按 BCP 14 [RFC2119] [RFC8174] 中的描述来解释,且仅当这些词以全部大写形式出现时才适用,如此处所示。


3. 通过 HTTP/3 引导 WebSockets

[RFC8441] 定义了一种在 HTTP/2 连接的单一流上运行 WebSocket 协议 [RFC6455] 的机制。它定义了一个扩展的 CONNECT 方法,该方法指定了一个新的 ":protocol" 伪头字段及对 ":path" 和 ":authority" 伪头字段的新语义。它还定义了服务器发送的一个新的 HTTP/2 设置,以允许客户端使用扩展的 CONNECT。

伪头字段和该设置的语义与 [RFC8441] 中为 HTTP/2 定义的语义相同。HTTP/3 的附录 A.3 要求对 HTTP/3 的设置进行单独注册。SETTINGS_ENABLE_CONNECT_PROTOCOL 的值与 HTTP/2 相同,为 0x08(十进制 8)。

如果服务器声明支持扩展的 CONNECT,但收到的扩展 CONNECT 请求的 ":protocol" 值未知或不被支持,服务器 SHOULD 使用 501(Not Implemented)状态码响应该请求(参见 HTTP Semantics 第 15.6.2 节)。服务器 MAY 通过 "problem details" 响应 [RFC7807] 提供更多信息。

HTTP/3 的流关闭也类似于 [RFC6455] 中的 TCP 连接关闭。有序的 TCP 级关闭在流上表示为 FIN 位(参见 HTTP/3 第 4.4 节)。RST 异常在 HTTP/3 中表示为流错误(参见 HTTP/3 第 8 节),错误类型为 H3_REQUEST_CANCELLED(参见 HTTP/3 第 8.1 节)。


4. 安全性考虑

本文档未引入超出 [RFC8441] 中讨论的新的安全性考虑。


5. IANA 考量

本文档在“HTTP/3 设置”注册表中登记了一个新的设置(参见 HTTP/3 第 11.2.2 节)。

值:
0x08
设置名称:
SETTINGS_ENABLE_CONNECT_PROTOCOL
默认值:
0
状态:
permanent
规范:
本文件
变更控制者:
IETF
联系人:
HTTP Working Group (ietf-http-wg@w3.org)

6. 规范性参考文献

[HTTP]
Fielding, R., Ed., Nottingham, M., Ed., and J. Reschke, Ed., “HTTP Semantics”, STD 97, RFC 9110, DOI 10.17487/RFC9110, June 2022, <https://www.rfc-editor.org/info/rfc9110>.
[HTTP/2]
Thomson, M., Ed. and C. Benfield, Ed., “HTTP/2”, RFC 9113, DOI 10.17487/RFC9113, June 2022, <https://www.rfc-editor.org/info/rfc9113>.
[HTTP/3]
Bishop, M., Ed., “HTTP/3”, RFC 9114, DOI 10.17487/RFC9114, June 2022, <https://www.rfc-editor.org/info/rfc9114>.
[RFC2119]
Bradner, S., “Key words for use in RFCs to Indicate Requirement Levels”, BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997, <https://www.rfc-editor.org/info/rfc2119>.
[RFC6455]
Fette, I. and A. Melnikov, “The WebSocket Protocol”, RFC 6455, DOI 10.17487/RFC6455, December 2011, <https://www.rfc-editor.org/info/rfc6455>.
[RFC7807]
Nottingham, M. and E. Wilde, “Problem Details for HTTP APIs”, RFC 7807, DOI 10.17487/RFC7807, March 2016, <https://www.rfc-editor.org/info/rfc7807>.
[RFC8174]
Leiba, B., “Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words”, BCP 14, RFC 8174, DOI 10.17487/RFC8174, May 2017, <https://www.rfc-editor.org/info/rfc8174>.
[RFC8441]
McManus, P., “Bootstrapping WebSockets with HTTP/2”, RFC 8441, DOI 10.17487/RFC8441, September 2018, <https://www.rfc-editor.org/info/rfc8441>.

致谢

本文档得到了 IETF HTTP 和 QUIC 工作组中许多贡献者的审阅和输入,特别感谢 David Schinazi、Martin Thomson、Lucas Pardue、Mike Bishop、Dragana Damjanovic、Mark Nottingham 和 Julian Reschke 提供的实质性意见。


作者地址

Ryan Hamilton
Google
EMail: rch@google.com