idnits 2.17.00 (12 Aug 2021) /tmp/idnits13459/draft-ietf-httpbis-http2-13.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- ** The abstract seems to contain references ([2], [3], [1]), which it shouldn't. Please replace those with straight textual mentions of the documents in question. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (June 17, 2014) is 2894 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) -- Looks like a reference, but probably isn't: '1' on line 3618 -- Looks like a reference, but probably isn't: '2' on line 3620 -- Looks like a reference, but probably isn't: '3' on line 3623 -- Looks like a reference, but probably isn't: '4' on line 2394 -- Looks like a reference, but probably isn't: '5' on line 3585 -- Looks like a reference, but probably isn't: '6' on line 3825 -- Looks like a reference, but probably isn't: '7' on line 3833 == Outdated reference: draft-ietf-httpbis-header-compression has been published as RFC 7541 ** Downref: Normative reference to an Informational RFC: RFC 2818 ** Obsolete normative reference: RFC 5226 (Obsoleted by RFC 8126) ** Obsolete normative reference: RFC 5246 (ref. 'TLS12') (Obsoleted by RFC 8446) == Outdated reference: draft-ietf-tls-applayerprotoneg has been published as RFC 7301 == Outdated reference: draft-ietf-httpbis-alt-svc has been published as RFC 7838 -- Obsolete informational reference (is this intentional?): RFC 1323 (Obsoleted by RFC 7323) -- Obsolete informational reference (is this intentional?): RFC 2518 (Obsoleted by RFC 4918) -- Obsolete informational reference (is this intentional?): RFC 4492 (Obsoleted by RFC 8422) Summary: 4 errors (**), 0 flaws (~~), 4 warnings (==), 11 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 HTTPbis Working Group M. Belshe 3 Internet-Draft Twist 4 Intended status: Standards Track R. Peon 5 Expires: December 19, 2014 Google, Inc 6 M. Thomson, Ed. 7 Mozilla 8 June 17, 2014 10 Hypertext Transfer Protocol version 2 11 draft-ietf-httpbis-http2-13 13 Abstract 15 This specification describes an optimized expression of the syntax of 16 the Hypertext Transfer Protocol (HTTP). HTTP/2 enables a more 17 efficient use of network resources and a reduced perception of 18 latency by introducing header field compression and allowing multiple 19 concurrent messages on the same connection. It also introduces 20 unsolicited push of representations from servers to clients. 22 This specification is an alternative to, but does not obsolete, the 23 HTTP/1.1 message syntax. HTTP's existing semantics remain unchanged. 25 Editorial Note (To be removed by RFC Editor) 27 Discussion of this draft takes place on the HTTPBIS working group 28 mailing list (ietf-http-wg@w3.org), which is archived at [1]. 30 Working Group information can be found at [2]; that specific to 31 HTTP/2 are at [3]. 33 The changes in this draft are summarized in Appendix A. 35 Status of This Memo 37 This Internet-Draft is submitted in full conformance with the 38 provisions of BCP 78 and BCP 79. 40 Internet-Drafts are working documents of the Internet Engineering 41 Task Force (IETF). Note that other groups may also distribute 42 working documents as Internet-Drafts. The list of current Internet- 43 Drafts is at http://datatracker.ietf.org/drafts/current/. 45 Internet-Drafts are draft documents valid for a maximum of six months 46 and may be updated, replaced, or obsoleted by other documents at any 47 time. It is inappropriate to use Internet-Drafts as reference 48 material or to cite them other than as "work in progress." 49 This Internet-Draft will expire on December 19, 2014. 51 Copyright Notice 53 Copyright (c) 2014 IETF Trust and the persons identified as the 54 document authors. All rights reserved. 56 This document is subject to BCP 78 and the IETF Trust's Legal 57 Provisions Relating to IETF Documents 58 (http://trustee.ietf.org/license-info) in effect on the date of 59 publication of this document. Please review these documents 60 carefully, as they describe your rights and restrictions with respect 61 to this document. Code Components extracted from this document must 62 include Simplified BSD License text as described in Section 4.e of 63 the Trust Legal Provisions and are provided without warranty as 64 described in the Simplified BSD License. 66 Table of Contents 68 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 4 69 2. HTTP/2 Protocol Overview . . . . . . . . . . . . . . . . . . 5 70 2.1. Document Organization . . . . . . . . . . . . . . . . . . 6 71 2.2. Conventions and Terminology . . . . . . . . . . . . . . . 6 72 3. Starting HTTP/2 . . . . . . . . . . . . . . . . . . . . . . . 7 73 3.1. HTTP/2 Version Identification . . . . . . . . . . . . . . 8 74 3.2. Starting HTTP/2 for "http" URIs . . . . . . . . . . . . . 9 75 3.2.1. HTTP2-Settings Header Field . . . . . . . . . . . . . 10 76 3.3. Starting HTTP/2 for "https" URIs . . . . . . . . . . . . 11 77 3.4. Starting HTTP/2 with Prior Knowledge . . . . . . . . . . 11 78 3.5. HTTP/2 Connection Preface . . . . . . . . . . . . . . . . 11 79 4. HTTP Frames . . . . . . . . . . . . . . . . . . . . . . . . . 12 80 4.1. Frame Format . . . . . . . . . . . . . . . . . . . . . . 12 81 4.2. Frame Size . . . . . . . . . . . . . . . . . . . . . . . 13 82 4.3. Header Compression and Decompression . . . . . . . . . . 14 83 5. Streams and Multiplexing . . . . . . . . . . . . . . . . . . 15 84 5.1. Stream States . . . . . . . . . . . . . . . . . . . . . . 15 85 5.1.1. Stream Identifiers . . . . . . . . . . . . . . . . . 20 86 5.1.2. Stream Concurrency . . . . . . . . . . . . . . . . . 21 87 5.2. Flow Control . . . . . . . . . . . . . . . . . . . . . . 21 88 5.2.1. Flow Control Principles . . . . . . . . . . . . . . . 21 89 5.2.2. Appropriate Use of Flow Control . . . . . . . . . . . 22 90 5.3. Stream priority . . . . . . . . . . . . . . . . . . . . . 23 91 5.3.1. Stream Dependencies . . . . . . . . . . . . . . . . . 24 92 5.3.2. Dependency Weighting . . . . . . . . . . . . . . . . 25 93 5.3.3. Reprioritization . . . . . . . . . . . . . . . . . . 25 94 5.3.4. Prioritization State Management . . . . . . . . . . . 26 95 5.3.5. Default Priorities . . . . . . . . . . . . . . . . . 27 96 5.4. Error Handling . . . . . . . . . . . . . . . . . . . . . 27 97 5.4.1. Connection Error Handling . . . . . . . . . . . . . . 27 98 5.4.2. Stream Error Handling . . . . . . . . . . . . . . . . 28 99 5.4.3. Connection Termination . . . . . . . . . . . . . . . 28 100 5.5. Extending HTTP/2 . . . . . . . . . . . . . . . . . . . . 28 101 6. Frame Definitions . . . . . . . . . . . . . . . . . . . . . . 29 102 6.1. DATA . . . . . . . . . . . . . . . . . . . . . . . . . . 29 103 6.2. HEADERS . . . . . . . . . . . . . . . . . . . . . . . . . 31 104 6.3. PRIORITY . . . . . . . . . . . . . . . . . . . . . . . . 33 105 6.4. RST_STREAM . . . . . . . . . . . . . . . . . . . . . . . 34 106 6.5. SETTINGS . . . . . . . . . . . . . . . . . . . . . . . . 35 107 6.5.1. SETTINGS Format . . . . . . . . . . . . . . . . . . . 36 108 6.5.2. Defined SETTINGS Parameters . . . . . . . . . . . . . 36 109 6.5.3. Settings Synchronization . . . . . . . . . . . . . . 37 110 6.6. PUSH_PROMISE . . . . . . . . . . . . . . . . . . . . . . 38 111 6.7. PING . . . . . . . . . . . . . . . . . . . . . . . . . . 40 112 6.8. GOAWAY . . . . . . . . . . . . . . . . . . . . . . . . . 41 113 6.9. WINDOW_UPDATE . . . . . . . . . . . . . . . . . . . . . . 43 114 6.9.1. The Flow Control Window . . . . . . . . . . . . . . . 44 115 6.9.2. Initial Flow Control Window Size . . . . . . . . . . 45 116 6.9.3. Reducing the Stream Window Size . . . . . . . . . . . 46 117 6.10. CONTINUATION . . . . . . . . . . . . . . . . . . . . . . 47 118 7. Error Codes . . . . . . . . . . . . . . . . . . . . . . . . . 47 119 8. HTTP Message Exchanges . . . . . . . . . . . . . . . . . . . 49 120 8.1. HTTP Request/Response Exchange . . . . . . . . . . . . . 49 121 8.1.1. Informational Responses . . . . . . . . . . . . . . . 50 122 8.1.2. HTTP Header Fields . . . . . . . . . . . . . . . . . 51 123 8.1.3. Examples . . . . . . . . . . . . . . . . . . . . . . 55 124 8.1.4. Request Reliability Mechanisms in HTTP/2 . . . . . . 58 125 8.2. Server Push . . . . . . . . . . . . . . . . . . . . . . . 59 126 8.2.1. Push Requests . . . . . . . . . . . . . . . . . . . . 59 127 8.2.2. Push Responses . . . . . . . . . . . . . . . . . . . 60 128 8.3. The CONNECT Method . . . . . . . . . . . . . . . . . . . 61 129 9. Additional HTTP Requirements/Considerations . . . . . . . . . 62 130 9.1. Connection Management . . . . . . . . . . . . . . . . . . 62 131 9.1.1. Connection Reuse . . . . . . . . . . . . . . . . . . 63 132 9.1.2. The 421 (Not Authoritative) Status Code . . . . . . . 64 133 9.2. Use of TLS Features . . . . . . . . . . . . . . . . . . . 64 134 9.2.1. TLS Features . . . . . . . . . . . . . . . . . . . . 64 135 9.2.2. TLS Cipher Suites . . . . . . . . . . . . . . . . . . 65 136 10. Security Considerations . . . . . . . . . . . . . . . . . . . 65 137 10.1. Server Authority . . . . . . . . . . . . . . . . . . . . 65 138 10.2. Cross-Protocol Attacks . . . . . . . . . . . . . . . . . 66 139 10.3. Intermediary Encapsulation Attacks . . . . . . . . . . . 66 140 10.4. Cacheability of Pushed Responses . . . . . . . . . . . . 67 141 10.5. Denial of Service Considerations . . . . . . . . . . . . 67 142 10.5.1. Limits on Header Block Size . . . . . . . . . . . . 68 143 10.6. Use of Compression . . . . . . . . . . . . . . . . . . . 69 144 10.7. Use of Padding . . . . . . . . . . . . . . . . . . . . . 69 145 10.8. Privacy Considerations . . . . . . . . . . . . . . . . . 70 146 11. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 70 147 11.1. Registration of HTTP/2 Identification Strings . . . . . 70 148 11.2. Frame Type Registry . . . . . . . . . . . . . . . . . . 71 149 11.3. Settings Registry . . . . . . . . . . . . . . . . . . . 72 150 11.4. Error Code Registry . . . . . . . . . . . . . . . . . . 72 151 11.5. HTTP2-Settings Header Field Registration . . . . . . . . 73 152 11.6. PRI Method Registration . . . . . . . . . . . . . . . . 74 153 11.7. The 421 Not Authoritative HTTP Status Code . . . . . . . 74 154 12. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 74 155 13. References . . . . . . . . . . . . . . . . . . . . . . . . . 75 156 13.1. Normative References . . . . . . . . . . . . . . . . . . 75 157 13.2. Informative References . . . . . . . . . . . . . . . . . 76 158 13.3. URIs . . . . . . . . . . . . . . . . . . . . . . . . . . 77 159 Appendix A. Change Log (to be removed by RFC Editor before 160 publication) . . . . . . . . . . . . . . . . . . . . 78 161 A.1. Since draft-ietf-httpbis-http2-12 . . . . . . . . . . . . 78 162 A.2. Since draft-ietf-httpbis-http2-11 . . . . . . . . . . . . 78 163 A.3. Since draft-ietf-httpbis-http2-10 . . . . . . . . . . . . 78 164 A.4. Since draft-ietf-httpbis-http2-09 . . . . . . . . . . . . 79 165 A.5. Since draft-ietf-httpbis-http2-08 . . . . . . . . . . . . 79 166 A.6. Since draft-ietf-httpbis-http2-07 . . . . . . . . . . . . 79 167 A.7. Since draft-ietf-httpbis-http2-06 . . . . . . . . . . . . 79 168 A.8. Since draft-ietf-httpbis-http2-05 . . . . . . . . . . . . 80 169 A.9. Since draft-ietf-httpbis-http2-04 . . . . . . . . . . . . 80 170 A.10. Since draft-ietf-httpbis-http2-03 . . . . . . . . . . . . 80 171 A.11. Since draft-ietf-httpbis-http2-02 . . . . . . . . . . . . 81 172 A.12. Since draft-ietf-httpbis-http2-01 . . . . . . . . . . . . 81 173 A.13. Since draft-ietf-httpbis-http2-00 . . . . . . . . . . . . 82 174 A.14. Since draft-mbelshe-httpbis-spdy-00 . . . . . . . . . . . 82 176 1. Introduction 178 The Hypertext Transfer Protocol (HTTP) is a wildly successful 179 protocol. However, the HTTP/1.1 message format ([RFC7230], 180 Section 3) was designed to be implemented with the tools at hand in 181 the 1990s, not modern Web application performance. As such it has 182 several characteristics that have a negative overall effect on 183 application performance today. 185 In particular, HTTP/1.0 only allows one request to be outstanding at 186 a time on a given connection. HTTP/1.1 pipelining only partially 187 addressed request concurrency and suffers from head-of-line blocking. 188 Therefore, clients that need to make many requests typically use 189 multiple connections to a server in order to reduce latency. 191 Furthermore, HTTP/1.1 header fields are often repetitive and verbose, 192 which, in addition to generating more or larger network packets, can 193 cause the small initial TCP [TCP] congestion window to quickly fill. 194 This can result in excessive latency when multiple requests are made 195 on a single new TCP connection. 197 This specification addresses these issues by defining an optimized 198 mapping of HTTP's semantics to an underlying connection. 199 Specifically, it allows interleaving of request and response messages 200 on the same connection and uses an efficient coding for HTTP header 201 fields. It also allows prioritization of requests, letting more 202 important requests complete more quickly, further improving 203 performance. 205 The resulting protocol is designed to be more friendly to the 206 network, because fewer TCP connections can be used in comparison to 207 HTTP/1.x. This means less competition with other flows, and longer- 208 lived connections, which in turn leads to better utilization of 209 available network capacity. 211 Finally, this encapsulation also enables more efficient processing of 212 messages through use of binary message framing. 214 2. HTTP/2 Protocol Overview 216 HTTP/2 provides an optimized transport for HTTP semantics. HTTP/2 217 supports all of the core features of HTTP/1.1, but aims to be more 218 efficient in several ways. 220 The basic protocol unit in HTTP/2 is a frame (Section 4.1). Each 221 frame type serves a different purpose. For example, HEADERS and DATA 222 frames form the basis of HTTP requests and responses (Section 8.1); 223 other frame types like SETTINGS, WINDOW_UPDATE, and PUSH_PROMISE are 224 used in support of other HTTP/2 features. 226 Multiplexing of requests is achieved by having each HTTP request- 227 response exchanged assigned to a single stream (Section 5). Streams 228 are largely independent of each other, so a blocked or stalled 229 request does not prevent progress on other requests. 231 Flow control and prioritization ensure that it is possible to 232 properly use multiplexed streams. Flow control (Section 5.2) helps 233 to ensure that only data that can be used by a receiver is 234 transmitted. Prioritization (Section 5.3) ensures that limited 235 resources can be directed to the most important requests first. 237 HTTP/2 adds a new interaction mode, whereby a server can push 238 responses to a client (Section 8.2). Server push allows a server to 239 speculatively send a client data that the server anticipates the 240 client will need, trading off some network usage against a potential 241 latency gain. The server does this by synthesizing a request, which 242 it sends as a PUSH_PROMISE frame. The server is then able to send a 243 response to the synthetic request on a separate stream. 245 Frames that contain HTTP header fields are compressed (Section 4.3). 246 HTTP requests can be highly redundant, so compression can reduce the 247 size of requests and responses significantly. 249 2.1. Document Organization 251 The HTTP/2 specification is split into four parts: 253 o Starting HTTP/2 (Section 3) covers how an HTTP/2 connection is 254 initiated. 256 o The framing (Section 4) and streams (Section 5) layers describe 257 the way HTTP/2 frames are structured and formed into multiplexed 258 streams. 260 o Frame (Section 6) and error (Section 7) definitions include 261 details of the frame and error types used in HTTP/2. 263 o HTTP mappings (Section 8) and additional requirements (Section 9) 264 describe how HTTP semantics are expressed using frames and 265 streams. 267 While some of the frame and stream layer concepts are isolated from 268 HTTP, the intent is not to define a completely generic framing layer. 269 The framing and streams layers are tailored to the needs of the HTTP 270 protocol and server push. 272 2.2. Conventions and Terminology 274 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 275 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 276 document are to be interpreted as described in RFC 2119 [RFC2119]. 278 All numeric values are in network byte order. Values are unsigned 279 unless otherwise indicated. Literal values are provided in decimal 280 or hexadecimal as appropriate. Hexadecimal literals are prefixed 281 with "0x" to distinguish them from decimal literals. 283 The following terms are used: 285 client: The endpoint initiating the HTTP/2 connection. 287 connection: A transport-level connection between two endpoints. 289 connection error: An error that affects the entire HTTP/2 290 connection. 292 endpoint: Either the client or server of the connection. 294 frame: The smallest unit of communication within an HTTP/2 295 connection, consisting of a header and a variable-length sequence 296 of bytes structured according to the frame type. 298 peer: An endpoint. When discussing a particular endpoint, "peer" 299 refers to the endpoint that is remote to the primary subject of 300 discussion. 302 receiver: An endpoint that is receiving frames. 304 sender: An endpoint that is transmitting frames. 306 server: The endpoint which did not initiate the HTTP/2 connection. 308 stream: A bi-directional flow of frames across a virtual channel 309 within the HTTP/2 connection. 311 stream error: An error on the individual HTTP/2 stream. 313 Finally, the terms "gateway", "intermediary", "proxy", and "tunnel" 314 are defined in Section 2.3 of [RFC7230]. 316 3. Starting HTTP/2 318 An HTTP/2 connection is an application level protocol running on top 319 of a TCP connection ([TCP]). The client is the TCP connection 320 initiator. 322 HTTP/2 uses the same "http" and "https" URI schemes used by HTTP/1.1. 323 HTTP/2 shares the same default port numbers: 80 for "http" URIs and 324 443 for "https" URIs. As a result, implementations processing 325 requests for target resource URIs like "http://example.org/foo" or 326 "https://example.com/bar" are required to first discover whether the 327 upstream server (the immediate peer to which the client wishes to 328 establish a connection) supports HTTP/2. 330 The means by which support for HTTP/2 is determined is different for 331 "http" and "https" URIs. Discovery for "http" URIs is described in 332 Section 3.2. Discovery for "https" URIs is described in Section 3.3. 334 3.1. HTTP/2 Version Identification 336 The protocol defined in this document has two identifiers. 338 o The string "h2" identifies the protocol where HTTP/2 uses TLS 339 [TLS12]. This identifier is used in the TLS application layer 340 protocol negotiation extension (ALPN) [TLSALPN] field and any 341 place that HTTP/2 over TLS is identified. 343 The "h2" string is serialized into an ALPN protocol identifier as 344 the two octet sequence: 0x68, 0x32. 346 o The string "h2c" identifies the protocol where HTTP/2 is run over 347 cleartext TCP. This identifier is used in the HTTP/1.1 Upgrade 348 header field and any place that HTTP/2 over TCP is identified. 350 Negotiating "h2" or "h2c" implies the use of the transport, security, 351 framing and message semantics described in this document. 353 [[CREF1: RFC Editor's Note: please remove the remainder of this 354 section prior to the publication of a final version of this 355 document.]] 357 Only implementations of the final, published RFC can identify 358 themselves as "h2" or "h2c". Until such an RFC exists, 359 implementations MUST NOT identify themselves using these strings. 361 Examples and text throughout the rest of this document use "h2" as a 362 matter of editorial convenience only. Implementations of draft 363 versions MUST NOT identify using this string. 365 Implementations of draft versions of the protocol MUST add the string 366 "-" and the corresponding draft number to the identifier. For 367 example, draft-ietf-httpbis-http2-11 over TLS is identified using the 368 string "h2-11". 370 Non-compatible experiments that are based on these draft versions 371 MUST append the string "-" and an experiment name to the identifier. 372 For example, an experimental implementation of packet mood-based 373 encoding based on draft-ietf-httpbis-http2-09 might identify itself 374 as "h2-09-emo". Note that any label MUST conform to the "token" 375 syntax defined in Section 3.2.6 of [RFC7230]. Experimenters are 376 encouraged to coordinate their experiments on the ietf-http-wg@w3.org 377 mailing list. 379 3.2. Starting HTTP/2 for "http" URIs 381 A client that makes a request to an "http" URI without prior 382 knowledge about support for HTTP/2 uses the HTTP Upgrade mechanism 383 (Section 6.7 of [RFC7230]). The client makes an HTTP/1.1 request 384 that includes an Upgrade header field identifying HTTP/2 with the 385 "h2c" token. The HTTP/1.1 request MUST include exactly one 386 HTTP2-Settings (Section 3.2.1) header field. 388 For example: 390 GET / HTTP/1.1 391 Host: server.example.com 392 Connection: Upgrade, HTTP2-Settings 393 Upgrade: h2c 394 HTTP2-Settings: 396 Requests that contain an entity body MUST be sent in their entirety 397 before the client can send HTTP/2 frames. This means that a large 398 request entity can block the use of the connection until it is 399 completely sent. 401 If concurrency of an initial request with subsequent requests is 402 important, a small request can be used to perform the upgrade to 403 HTTP/2, at the cost of an additional round-trip. 405 A server that does not support HTTP/2 can respond to the request as 406 though the Upgrade header field were absent: 408 HTTP/1.1 200 OK 409 Content-Length: 243 410 Content-Type: text/html 412 ... 414 A server MUST ignore a "h2" token in an Upgrade header field. 415 Presence of a token with "h2" implies HTTP/2 over TLS, which is 416 instead negotiated as described in Section 3.3. 418 A server that supports HTTP/2 can accept the upgrade with a 101 419 (Switching Protocols) response. After the empty line that terminates 420 the 101 response, the server can begin sending HTTP/2 frames. These 421 frames MUST include a response to the request that initiated the 422 Upgrade. 424 HTTP/1.1 101 Switching Protocols 425 Connection: Upgrade 426 Upgrade: h2c 428 [ HTTP/2 connection ... 430 The first HTTP/2 frame sent by the server is a SETTINGS frame 431 (Section 6.5). Upon receiving the 101 response, the client sends a 432 connection preface (Section 3.5), which includes a SETTINGS frame. 434 The HTTP/1.1 request that is sent prior to upgrade is assigned stream 435 identifier 1 and is assigned default priority values (Section 5.3.5). 436 Stream 1 is implicitly half closed from the client toward the server, 437 since the request is completed as an HTTP/1.1 request. After 438 commencing the HTTP/2 connection, stream 1 is used for the response. 440 3.2.1. HTTP2-Settings Header Field 442 A request that upgrades from HTTP/1.1 to HTTP/2 MUST include exactly 443 one "HTTP2-Settings" header field. The "HTTP2-Settings" header field 444 is a hop-by-hop header field that includes parameters that govern the 445 HTTP/2 connection, provided in anticipation of the server accepting 446 the request to upgrade. 448 HTTP2-Settings = token68 450 A server MUST reject an attempt to upgrade if this header field is 451 not present. A server MUST NOT send this header field. 453 The content of the "HTTP2-Settings" header field is the payload of a 454 SETTINGS frame (Section 6.5), encoded as a base64url string (that is, 455 the URL- and filename-safe Base64 encoding described in Section 5 of 456 [RFC4648], with any trailing '=' characters omitted). The ABNF 457 [RFC5234] production for "token68" is defined in Section 2.1 of 458 [RFC7235]. 460 As a hop-by-hop header field, the "Connection" header field MUST 461 include a value of "HTTP2-Settings" in addition to "Upgrade" when 462 upgrading to HTTP/2. 464 A server decodes and interprets these values as it would any other 465 SETTINGS frame. Acknowledgement of the SETTINGS parameters 466 (Section 6.5.3) is not necessary, since a 101 response serves as 467 implicit acknowledgment. Providing these values in the Upgrade 468 request ensures that the protocol does not require default values for 469 the above SETTINGS parameters, and gives a client an opportunity to 470 provide other parameters prior to receiving any frames from the 471 server. 473 3.3. Starting HTTP/2 for "https" URIs 475 A client that makes a request to an "https" URI without prior 476 knowledge about support for HTTP/2 uses TLS [TLS12] with the 477 application layer protocol negotiation extension [TLSALPN]. 479 HTTP/2 over TLS uses the "h2" application token. The "h2c" token 480 MUST NOT be sent by a client or selected by a server. 482 Once TLS negotiation is complete, both the client and the server send 483 a connection preface (Section 3.5). 485 3.4. Starting HTTP/2 with Prior Knowledge 487 A client can learn that a particular server supports HTTP/2 by other 488 means. For example, [ALT-SVC] describes a mechanism for advertising 489 this capability. 491 A client MAY immediately send HTTP/2 frames to a server that is known 492 to support HTTP/2, after the connection preface (Section 3.5). A 493 server can identify such a connection by the use of the "PRI" method 494 in the connection preface. This only affects the establishment of 495 HTTP/2 connections over cleartext TCP; implementations that support 496 HTTP/2 over TLS MUST use protocol negotiation in TLS [TLSALPN]. 498 Prior support for HTTP/2 is not a strong signal that a given server 499 will support HTTP/2 for future connections. It is possible for 500 server configurations to change; for configurations to differ between 501 instances in clustered server; or network conditions to change. 503 3.5. HTTP/2 Connection Preface 505 Upon establishment of a TCP connection and determination that HTTP/2 506 will be used by both peers, each endpoint MUST send a connection 507 preface as a final confirmation and to establish the initial SETTINGS 508 parameters for the HTTP/2 connection. 510 The client connection preface starts with a sequence of 24 octets, 511 which in hex notation are: 513 0x505249202a20485454502f322e300d0a0d0a534d0d0a0d0a 515 (the string "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"). This sequence is 516 followed by a SETTINGS frame (Section 6.5). The SETTINGS frame MAY 517 be empty. The client sends the client connection preface immediately 518 upon receipt of a 101 Switching Protocols response (indicating a 519 successful upgrade), or as the first application data octets of a TLS 520 connection. If starting an HTTP/2 connection with prior knowledge of 521 server support for the protocol, the client connection preface is 522 sent upon connection establishment. 524 The client connection preface is selected so that a large 525 proportion of HTTP/1.1 or HTTP/1.0 servers and intermediaries do 526 not attempt to process further frames. Note that this does not 527 address the concerns raised in [TALKING]. 529 The server connection preface consists of a potentially empty 530 SETTINGS frame (Section 6.5) that MUST be the first frame the server 531 sends in the HTTP/2 connection. 533 To avoid unnecessary latency, clients are permitted to send 534 additional frames to the server immediately after sending the client 535 connection preface, without waiting to receive the server connection 536 preface. It is important to note, however, that the server 537 connection preface SETTINGS frame might include parameters that 538 necessarily alter how a client is expected to communicate with the 539 server. Upon receiving the SETTINGS frame, the client is expected to 540 honor any parameters established. 542 Clients and servers MUST terminate the TCP connection if either peer 543 does not begin with a valid connection preface. A GOAWAY frame 544 (Section 6.8) can be omitted if it is clear that the peer is not 545 using HTTP/2. 547 4. HTTP Frames 549 Once the HTTP/2 connection is established, endpoints can begin 550 exchanging frames. 552 4.1. Frame Format 554 All frames begin with a fixed 8-octet header followed by a payload of 555 between 0 and 16,383 octets. 557 0 1 2 3 558 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 559 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 560 | R | Length (14) | Type (8) | Flags (8) | 561 +-+-+-----------+---------------+-------------------------------+ 562 |R| Stream Identifier (31) | 563 +=+=============================================================+ 564 | Frame Payload (0...) ... 565 +---------------------------------------------------------------+ 567 Frame Layout 569 The fields of the frame header are defined as: 571 R: A reserved 2-bit field. The semantics of these bits are undefined 572 and the bits MUST remain unset (0) when sending and MUST be 573 ignored when receiving. 575 Length: The length of the frame payload expressed as an unsigned 576 14-bit integer. The 8 octets of the frame header are not included 577 in this value. 579 Type: The 8-bit type of the frame. The frame type determines the 580 format and semantics of the frame. Implementations MUST ignore 581 and discard any frame that has a type that is unknown. 583 Flags: An 8-bit field reserved for frame-type specific boolean 584 flags. 586 Flags are assigned semantics specific to the indicated frame type. 587 Flags that have no defined semantics for a particular frame type 588 MUST be ignored, and MUST be left unset (0) when sending. 590 R: A reserved 1-bit field. The semantics of this bit are undefined 591 and the bit MUST remain unset (0) when sending and MUST be ignored 592 when receiving. 594 Stream Identifier: A 31-bit stream identifier (see Section 5.1.1). 595 The value 0 is reserved for frames that are associated with the 596 connection as a whole as opposed to an individual stream. 598 The structure and content of the frame payload is dependent entirely 599 on the frame type. 601 4.2. Frame Size 603 The maximum size of a frame payload varies by frame type. The 604 absolute maximum size of a frame payload is 2^14-1 (16,383) octets, 605 meaning that the maximum frame size is 16,391 octets. All 606 implementations MUST be capable of receiving and minimally processing 607 frames up to this maximum size. 609 Certain frame types, such as PING (Section 6.7), impose additional 610 limits on the amount of payload data allowed. 612 If a frame size exceeds any defined limit, or is too small to contain 613 mandatory frame data, the endpoint MUST send a FRAME_SIZE_ERROR 614 error. A frame size error in a frame that could alter the state of 615 the entire connection MUST be treated as a connection error 616 (Section 5.4.1); this includes any frame carrying a header block 617 (Section 4.3) (that is, HEADERS, PUSH_PROMISE, and CONTINUATION), 618 SETTINGS, and any WINDOW_UPDATE frame with a stream identifier of 0. 620 4.3. Header Compression and Decompression 622 A header field in HTTP/2 is a name with one or more associated 623 values. They are used within HTTP request and response messages as 624 well as server push operations (see Section 8.2). 626 Header sets are collections of zero or more header fields. When 627 transmitted over a connection, a header set is serialized into a 628 header block using HTTP Header Compression [COMPRESSION]. The 629 serialized header block is then divided into one or more octet 630 sequences, called header block fragments, and transmitted within the 631 payload of HEADERS (Section 6.2), PUSH_PROMISE (Section 6.6) or 632 CONTINUATION (Section 6.10) frames. 634 HTTP Header Compression does not preserve the relative ordering of 635 header fields. Header fields with multiple values are encoded into a 636 single header field using a special delimiter (see Section 8.1.2.3), 637 this preserves the relative order of values for that header field. 639 The Cookie header field [COOKIE] is treated specially by the HTTP 640 mapping (see Section 8.1.2.4). 642 A receiving endpoint reassembles the header block by concatenating 643 its fragments, then decompresses the block to reconstruct the header 644 set. 646 A complete header block consists of either: 648 o a single HEADERS or PUSH_PROMISE frame, with the END_HEADERS flag 649 set, or 651 o a HEADERS or PUSH_PROMISE frame with the END_HEADERS flag cleared 652 and one or more CONTINUATION frames, where the last CONTINUATION 653 frame has the END_HEADERS flag set. 655 Header compression is stateful, using a single compression context 656 for the entire connection. Each header block is processed as a 657 discrete unit. Header blocks MUST be transmitted as a contiguous 658 sequence of frames, with no interleaved frames of any other type or 659 from any other stream. The last frame in a sequence of HEADERS or 660 CONTINUATION frames MUST have the END_HEADERS flag set. The last 661 frame in a sequence of PUSH_PROMISE or CONTINUATION frames MUST have 662 the END_HEADERS flag set. This allows a header block to be logically 663 equivalent to a single frame. 665 Header block fragments can only be sent as the payload of HEADERS, 666 PUSH_PROMISE or CONTINUATION frames, because these frames carry data 667 that can modify the compression context maintained by a receiver. An 668 endpoint receiving HEADERS, PUSH_PROMISE or CONTINUATION frames MUST 669 reassemble header blocks and perform decompression even if the frames 670 are to be discarded. A receiver MUST terminate the connection with a 671 connection error (Section 5.4.1) of type COMPRESSION_ERROR if it does 672 not decompress a header block. 674 5. Streams and Multiplexing 676 A "stream" is an independent, bi-directional sequence of frames 677 exchanged between the client and server within an HTTP/2 connection. 678 Streams have several important characteristics: 680 o A single HTTP/2 connection can contain multiple concurrently open 681 streams, with either endpoint interleaving frames from multiple 682 streams. 684 o Streams can be established and used unilaterally or shared by 685 either the client or server. 687 o Streams can be closed by either endpoint. 689 o The order in which frames are sent on a stream is significant. 690 Recipients process frames in the order they are received. In 691 particular, the order of HEADERS, and DATA frames is semantically 692 significant. 694 o Streams are identified by an integer. Stream identifiers are 695 assigned to streams by the endpoint initiating the stream. 697 5.1. Stream States 699 The lifecycle of a stream is shown in Figure 1. 701 +--------+ 702 PP | | PP 703 ,--------| idle |--------. 704 / | | \ 705 v +--------+ v 706 +----------+ | +----------+ 707 | | | H | | 708 ,---| reserved | | | reserved |---. 709 | | (local) | v | (remote) | | 710 | +----------+ +--------+ +----------+ | 711 | | ES | | ES | | 712 | | H ,-------| open |-------. | H | 713 | | / | | \ | | 714 | v v +--------+ v v | 715 | +----------+ | +----------+ | 716 | | half | | | half | | 717 | | closed | | R | closed | | 718 | | (remote) | | | (local) | | 719 | +----------+ | +----------+ | 720 | | v | | 721 | | ES / R +--------+ ES / R | | 722 | `----------->| |<-----------' | 723 | R | closed | R | 724 `-------------------->| |<--------------------' 725 +--------+ 727 H: HEADERS frame (with implied CONTINUATIONs) 728 PP: PUSH_PROMISE frame (with implied CONTINUATIONs) 729 ES: END_STREAM flag 730 R: RST_STREAM frame 732 Figure 1: Stream States 734 Note that this diagram shows stream state transitions and frames that 735 affect those transitions only. In this regard, CONTINUATION frames 736 do not result in state transitions and are effectively part of the 737 HEADERS or PUSH_PROMISE that they follow. 739 Both endpoints have a subjective view of the state of a stream that 740 could be different when frames are in transit. Endpoints do not 741 coordinate the creation of streams; they are created unilaterally by 742 either endpoint. The negative consequences of a mismatch in states 743 are limited to the "closed" state after sending RST_STREAM, where 744 frames might be received for some time after closing. 746 Streams have the following states: 748 idle: 749 All streams start in the "idle" state. In this state, no frames 750 have been exchanged. 752 The following transitions are valid from this state: 754 * Sending or receiving a HEADERS frame causes the stream to 755 become "open". The stream identifier is selected as described 756 in Section 5.1.1. The same HEADERS frame can also cause a 757 stream to immediately become "half closed". 759 * Sending a PUSH_PROMISE frame marks the associated stream for 760 later use. The stream state for the reserved stream 761 transitions to "reserved (local)". 763 * Receiving a PUSH_PROMISE frame marks the associated stream as 764 reserved by the remote peer. The state of the stream becomes 765 "reserved (remote)". 767 reserved (local): 768 A stream in the "reserved (local)" state is one that has been 769 promised by sending a PUSH_PROMISE frame. A PUSH_PROMISE frame 770 reserves an idle stream by associating the stream with an open 771 stream that was initiated by the remote peer (see Section 8.2). 773 In this state, only the following transitions are possible: 775 * The endpoint can send a HEADERS frame. This causes the stream 776 to open in a "half closed (remote)" state. 778 * Either endpoint can send a RST_STREAM frame to cause the stream 779 to become "closed". This releases the stream reservation. 781 An endpoint MUST NOT send frames other than HEADERS or RST_STREAM 782 in this state. 784 A PRIORITY frame MAY be received in this state. Receiving any 785 frames other than RST_STREAM, or PRIORITY MUST be treated as a 786 connection error (Section 5.4.1) of type PROTOCOL_ERROR. 788 reserved (remote): 789 A stream in the "reserved (remote)" state has been reserved by a 790 remote peer. 792 In this state, only the following transitions are possible: 794 * Receiving a HEADERS frame causes the stream to transition to 795 "half closed (local)". 797 * Either endpoint can send a RST_STREAM frame to cause the stream 798 to become "closed". This releases the stream reservation. 800 An endpoint MAY send a PRIORITY frame in this state to 801 reprioritize the reserved stream. An endpoint MUST NOT send any 802 other type of frame other than RST_STREAM or PRIORITY. 804 Receiving any other type of frame other than HEADERS or RST_STREAM 805 MUST be treated as a connection error (Section 5.4.1) of type 806 PROTOCOL_ERROR. 808 open: 809 A stream in the "open" state may be used by both peers to send 810 frames of any type. In this state, sending peers observe 811 advertised stream level flow control limits (Section 5.2). 813 From this state either endpoint can send a frame with an 814 END_STREAM flag set, which causes the stream to transition into 815 one of the "half closed" states: an endpoint sending an END_STREAM 816 flag causes the stream state to become "half closed (local)"; an 817 endpoint receiving an END_STREAM flag causes the stream state to 818 become "half closed (remote)". 820 Either endpoint can send a RST_STREAM frame from this state, 821 causing it to transition immediately to "closed". 823 half closed (local): 824 A stream that is in the "half closed (local)" state cannot be used 825 for sending frames. Only WINDOW_UPDATE, PRIORITY and RST_STREAM 826 frames can be sent in this state. 828 A stream transitions from this state to "closed" when a frame that 829 contains an END_STREAM flag is received, or when either peer sends 830 a RST_STREAM frame. 832 A receiver can ignore WINDOW_UPDATE frames in this state, which 833 might arrive for a short period after a frame bearing the 834 END_STREAM flag is sent. 836 PRIORITY frames received in this state are used to reprioritize 837 streams that depend on the current stream. 839 half closed (remote): 840 A stream that is "half closed (remote)" is no longer being used by 841 the peer to send frames. In this state, an endpoint is no longer 842 obligated to maintain a receiver flow control window if it 843 performs flow control. 845 If an endpoint receives additional frames for a stream that is in 846 this state, other than WINDOW_UPDATE, PRIORITY or RST_STREAM, it 847 MUST respond with a stream error (Section 5.4.2) of type 848 STREAM_CLOSED. 850 A stream can transition from this state to "closed" by sending a 851 frame that contains an END_STREAM flag, or when either peer sends 852 a RST_STREAM frame. 854 closed: 855 The "closed" state is the terminal state. 857 An endpoint MUST NOT send frames on a closed stream. An endpoint 858 that receives any frame other than PRIORITY after receiving a 859 RST_STREAM MUST treat that as a stream error (Section 5.4.2) of 860 type STREAM_CLOSED. Similarly, an endpoint that receives any 861 frames after receiving a frame with the END_STREAM flag set MUST 862 treat that as a connection error (Section 5.4.1) of type 863 STREAM_CLOSED, unless the frame is permitted as described below. 865 WINDOW_UPDATE or RST_STREAM frames can be received in this state 866 for a short period after a DATA or HEADERS frame containing an 867 END_STREAM flag is sent. Until the remote peer receives and 868 processes the frame bearing the END_STREAM flag, it might send 869 frames of these types. Endpoints MUST ignore WINDOW_UPDATE or 870 RST_STREAM frames received in this state, though endpoints MAY 871 choose to treat frames that arrive a significant time after 872 sending END_STREAM as a connection error (Section 5.4.1) of type 873 PROTOCOL_ERROR. 875 PRIORITY frames can be sent on closed streams to prioritize 876 streams that are dependent on the closed stream. Endpoints SHOULD 877 process PRIORITY frame, though they can be ignored if the stream 878 has been removed from the dependency tree (see Section 5.3.4). 880 If this state is reached as a result of sending a RST_STREAM 881 frame, the peer that receives the RST_STREAM might have already 882 sent - or enqueued for sending - frames on the stream that cannot 883 be withdrawn. An endpoint MUST ignore frames that it receives on 884 closed streams after it has sent a RST_STREAM frame. An endpoint 885 MAY choose to limit the period over which it ignores frames and 886 treat frames that arrive after this time as being in error. 888 Flow controlled frames (i.e., DATA) received after sending 889 RST_STREAM are counted toward the connection flow control window. 890 Even though these frames might be ignored, because they are sent 891 before the sender receives the RST_STREAM, the sender will 892 consider the frames to count against the flow control window. 894 An endpoint might receive a PUSH_PROMISE frame after it sends 895 RST_STREAM. PUSH_PROMISE causes a stream to become "reserved" 896 even if the associated stream has been reset. Therefore, a 897 RST_STREAM is needed to close an unwanted promised stream. 899 In the absence of more specific guidance elsewhere in this document, 900 implementations SHOULD treat the receipt of a message that is not 901 expressly permitted in the description of a state as a connection 902 error (Section 5.4.1) of type PROTOCOL_ERROR. 904 5.1.1. Stream Identifiers 906 Streams are identified with an unsigned 31-bit integer. Streams 907 initiated by a client MUST use odd-numbered stream identifiers; those 908 initiated by the server MUST use even-numbered stream identifiers. A 909 stream identifier of zero (0x0) is used for connection control 910 messages; the stream identifier zero cannot be used to establish a 911 new stream. 913 HTTP/1.1 requests that are upgraded to HTTP/2 (see Section 3.2) are 914 responded to with a stream identifier of one (0x1). After the 915 upgrade completes, stream 0x1 is "half closed (local)" to the client. 916 Therefore, stream 0x1 cannot be selected as a new stream identifier 917 by a client that upgrades from HTTP/1.1. 919 The identifier of a newly established stream MUST be numerically 920 greater than all streams that the initiating endpoint has opened or 921 reserved. This governs streams that are opened using a HEADERS frame 922 and streams that are reserved using PUSH_PROMISE. An endpoint that 923 receives an unexpected stream identifier MUST respond with a 924 connection error (Section 5.4.1) of type PROTOCOL_ERROR. 926 The first use of a new stream identifier implicitly closes all 927 streams in the "idle" state that might have been initiated by that 928 peer with a lower-valued stream identifier. For example, if a client 929 sends a HEADERS frame on stream 7 without ever sending a frame on 930 stream 5, then stream 5 transitions to the "closed" state when the 931 first frame for stream 7 is sent or received. 933 Stream identifiers cannot be reused. Long-lived connections can 934 result in an endpoint exhausting the available range of stream 935 identifiers. A client that is unable to establish a new stream 936 identifier can establish a new connection for new streams. A server 937 that is unable to establish a new stream identifier can send a GOAWAY 938 frame so that the client is forced to open a new connection for new 939 streams. 941 5.1.2. Stream Concurrency 943 A peer can limit the number of concurrently active streams using the 944 SETTINGS_MAX_CONCURRENT_STREAMS parameter (see Section 6.5.2) within 945 a SETTINGS frame. The maximum concurrent streams setting is specific 946 to each endpoint and applies only to the peer that receives the 947 setting. That is, clients specify the maximum number of concurrent 948 streams the server can initiate, and servers specify the maximum 949 number of concurrent streams the client can initiate. 951 Streams that are in the "open" state, or either of the "half closed" 952 states count toward the maximum number of streams that an endpoint is 953 permitted to open. Streams in any of these three states count toward 954 the limit advertised in the SETTINGS_MAX_CONCURRENT_STREAMS setting. 955 Streams in either of the "reserved" states do not count toward the 956 stream limit. 958 Endpoints MUST NOT exceed the limit set by their peer. An endpoint 959 that receives a HEADERS frame that causes their advertised concurrent 960 stream limit to be exceeded MUST treat this as a stream error 961 (Section 5.4.2). An endpoint that wishes to reduce the value of 962 SETTINGS_MAX_CONCURRENT_STREAMS to a value that is below the current 963 number of open streams can either close streams that exceed the new 964 value or allow streams to complete. 966 5.2. Flow Control 968 Using streams for multiplexing introduces contention over use of the 969 TCP connection, resulting in blocked streams. A flow control scheme 970 ensures that streams on the same connection do not destructively 971 interfere with each other. Flow control is used for both individual 972 streams and for the connection as a whole. 974 HTTP/2 provides for flow control through use of the WINDOW_UPDATE 975 frame (Section 6.9). 977 5.2.1. Flow Control Principles 979 HTTP/2 stream flow control aims to allow for future improvements to 980 flow control algorithms without requiring protocol changes. Flow 981 control in HTTP/2 has the following characteristics: 983 1. Flow control is hop-by-hop, not end-to-end. 985 2. Flow control is based on window update frames. Receivers 986 advertise how many bytes they are prepared to receive on a stream 987 and for the entire connection. This is a credit-based scheme. 989 3. Flow control is directional with overall control provided by the 990 receiver. A receiver MAY choose to set any window size that it 991 desires for each stream and for the entire connection. A sender 992 MUST respect flow control limits imposed by a receiver. Clients, 993 servers and intermediaries all independently advertise their flow 994 control window as a receiver and abide by the flow control limits 995 set by their peer when sending. 997 4. The initial value for the flow control window is 65,535 bytes for 998 both new streams and the overall connection. 1000 5. The frame type determines whether flow control applies to a 1001 frame. Of the frames specified in this document, only DATA 1002 frames are subject to flow control; all other frame types do not 1003 consume space in the advertised flow control window. This 1004 ensures that important control frames are not blocked by flow 1005 control. 1007 6. Flow control cannot be disabled. 1009 7. HTTP/2 defines only the format and semantics of the WINDOW_UPDATE 1010 frame (Section 6.9). This document does not stipulate how a 1011 receiver decides when to send this frame or the value that it 1012 sends. Nor does it specify how a sender chooses to send packets. 1013 Implementations are able to select any algorithm that suits their 1014 needs. 1016 Implementations are also responsible for managing how requests and 1017 responses are sent based on priority; choosing how to avoid head of 1018 line blocking for requests; and managing the creation of new streams. 1019 Algorithm choices for these could interact with any flow control 1020 algorithm. 1022 5.2.2. Appropriate Use of Flow Control 1024 Flow control is defined to protect endpoints that are operating under 1025 resource constraints. For example, a proxy needs to share memory 1026 between many connections, and also might have a slow upstream 1027 connection and a fast downstream one. Flow control addresses cases 1028 where the receiver is unable process data on one stream, yet wants to 1029 continue to process other streams in the same connection. 1031 Deployments that do not require this capability can advertise a flow 1032 control window of the maximum size, incrementing the available space 1033 when new data is received. This effectively disables flow control 1034 for that receiver. Conversely, a sender is always subject to the 1035 flow control window advertised by the receiver. 1037 Deployments with constrained resources (for example, memory) can 1038 employ flow control to limit the amount of memory a peer can consume. 1039 Note, however, that this can lead to suboptimal use of available 1040 network resources if flow control is enabled without knowledge of the 1041 bandwidth-delay product (see [RFC1323]). 1043 Even with full awareness of the current bandwidth-delay product, 1044 implementation of flow control can be difficult. When using flow 1045 control, the receiver MUST read from the TCP receive buffer in a 1046 timely fashion. Failure to do so could lead to a deadlock when 1047 critical frames, such as WINDOW_UPDATE, are not read and acted upon. 1049 5.3. Stream priority 1051 A client can assign a priority for a new stream by including 1052 prioritization information in the HEADERS frame (Section 6.2) that 1053 opens the stream. For an existing stream, the PRIORITY frame 1054 (Section 6.3) can be used to change the priority. 1056 The purpose of prioritization is to allow an endpoint to express how 1057 it would prefer its peer allocate resources when managing concurrent 1058 streams. Most importantly, priority can be used to select streams 1059 for transmitting frames when there is limited capacity for sending. 1061 Streams can be prioritized by marking them as dependent on the 1062 completion of other streams (Section 5.3.1). Each dependency is 1063 assigned a relative weight, a number that is used to determine the 1064 relative proportion of available resources that are assigned to 1065 streams dependent on the same stream. 1067 [[CREF2: Note that stream dependencies have not yet been validated in 1068 practice. The theory might be fairly sound, but there are no 1069 implementations currently sending these. If it turns out that they 1070 are not useful, or actively harmful, implementations will be 1071 requested to avoid creating stream dependencies.]] 1073 Explicitly setting the priority for a stream is input to a 1074 prioritization process. It does not guarantee any particular 1075 processing or transmission order for the stream relative to any other 1076 stream. An endpoint cannot force a peer to process concurrent 1077 streams in a particular order using priority. Expressing priority is 1078 therefore only ever a suggestion. 1080 Prioritization information can be specified explicitly for streams as 1081 they are created using the HEADERS frame, or changed using the 1082 PRIORITY frame. Providing prioritization information is optional, so 1083 default values are used if no explicit indicator is provided 1084 (Section 5.3.5). 1086 5.3.1. Stream Dependencies 1088 Each stream can be given an explicit dependency on another stream. 1089 Including a dependency expresses a preference to allocate resources 1090 to the identified stream rather than to the dependent stream. 1092 A stream that is not dependent on any other stream is given a stream 1093 dependency of 0x0. In other words, the non-existent stream 0 forms 1094 the root of the tree. 1096 A stream that depends on another stream is a dependent stream. The 1097 stream upon which a stream is dependent is a parent stream. 1099 When assigning a dependency on another stream, the stream is added as 1100 a new dependency of the parent stream. Dependent streams that share 1101 the same parent are not order with respect to each other. For 1102 example, if streams B and C are dependent on stream A, and if stream 1103 D is created with a dependency on stream A, this results in a 1104 dependency order of A followed by B, C, and D in any order. 1106 A A 1107 / \ ==> /|\ 1108 B C B D C 1110 Example of Default Dependency Creation 1112 An exclusive flag allows for the insertion of a new level of 1113 dependencies. The exclusive flag causes the stream to become the 1114 sole dependency of its parent stream, causing other dependencies to 1115 become dependent on the prioritized stream. In the previous example, 1116 if stream D is created with an exclusive dependency on stream A, this 1117 results in D becoming the dependency parent of B and C. 1119 A 1120 A | 1121 / \ ==> D 1122 B C / \ 1123 B C 1125 Example of Exclusive Dependency Creation 1127 Inside the dependency tree, a dependent stream SHOULD only be 1128 allocated resources if all of the streams that it depends on (the 1129 chain of parent streams up to 0x0) are either closed, or it is not 1130 possible to make progress on them. 1132 A stream cannot depend on itself. An endpoint MUST treat this as a 1133 stream error (Section 5.4.2) of type PROTOCOL_ERROR. 1135 5.3.2. Dependency Weighting 1137 All dependent streams are allocated an integer weight between 1 to 1138 256 (inclusive). 1140 Streams with the same parent SHOULD be allocated resources 1141 proportionally based on their weight. Thus, if stream B depends on 1142 stream A with weight 4, and C depends on stream A with weight 12, and 1143 if no progress can be made on A, stream B ideally receives one third 1144 of the resources allocated to stream C. 1146 5.3.3. Reprioritization 1148 Stream priorities are changed using the PRIORITY frame. Setting a 1149 dependency causes a stream to become dependent on the identified 1150 parent stream. 1152 Dependent streams move with their parent stream if the parent is 1153 reprioritized. Setting a dependency with the exclusive flag for a 1154 reprioritized stream moves all the dependencies of the new parent 1155 stream to become dependent on the reprioritized stream. 1157 If a stream is made dependent on one of its own dependencies, the 1158 formerly dependent stream is first moved to be dependent on the 1159 reprioritized stream's previous parent. The moved dependency retains 1160 its weight. 1162 For example, consider an original dependency tree where B and C 1163 depend on A, D and E depend on C, and F depends on D. If A is made 1164 dependent on D, then D takes the place of A. All other dependency 1165 relationships stay the same, except for F, which becomes dependent on 1166 A if the reprioritization is exclusive. 1168 ? ? ? ? 1169 | / \ | | 1170 A D A D D 1171 / \ / / \ / \ | 1172 B C ==> F B C ==> F A OR A 1173 / \ | / \ /|\ 1174 D E E B C B C F 1175 | | | 1176 F E E 1177 (intermediate) (non-exclusive) (exclusive) 1179 Example of Dependency Reordering 1181 5.3.4. Prioritization State Management 1183 When a stream is removed from the dependency tree, its dependencies 1184 can be moved to become dependent on the parent of the closed stream. 1185 The weights of new dependencies are recalculated by distributing the 1186 weight of the dependency of the closed stream proportionally based on 1187 the weights of its dependencies. 1189 Streams that are removed from the dependency tree cause some 1190 prioritization information to be lost. Resources are shared between 1191 streams with the same parent stream, which means that if a stream in 1192 that set closes or becomes blocked, any spare capacity allocated to a 1193 stream is distributed to the immediate neighbors of the stream. 1194 However, if the common dependency is removed from the tree, those 1195 streams share resources with streams at the next highest level. 1197 For example, assume streams A and B share a parent, and streams C and 1198 D both depend on stream A. Prior to the removal of stream A, if 1199 streams A and D are unable to proceed, then stream C receives all the 1200 resources dedicated to stream A. If stream A is removed from the 1201 tree, the weight of stream A is divided between streams C and D. If 1202 stream D is still unable to proceed, this results in stream C 1203 receiving a reduced proportion of resources. For equal starting 1204 weights, C receives one third, rather than one half, of available 1205 resources. 1207 It is possible for a stream to become closed while prioritization 1208 information that creates a dependency on that stream is in transit. 1209 If a stream identified in a dependency has had any associated 1210 priority information destroyed, then the dependent stream is instead 1211 assigned a default priority. This potentially creates suboptimal 1212 prioritization, since the stream could be given a priority that is 1213 higher than intended. 1215 To avoid these problems, an endpoint SHOULD retain stream 1216 prioritization state for a period after streams become closed. The 1217 longer state is retained, the lower the chance that streams are 1218 assigned incorrect or default priority values. 1220 This could create a large state burden for an endpoint, so this state 1221 MAY be limited. An endpoint MAY apply a fixed upper limit on the 1222 number of closed streams for which prioritization state is tracked to 1223 limit state exposure. The amount of additional state an endpoint 1224 maintains could be dependent on load; under high load, prioritization 1225 state can be discarded to limit resource commitments. In extreme 1226 cases, an endpoint could even discard prioritization state for active 1227 or reserved streams. If a fixed limit is applied, endpoints SHOULD 1228 maintain state for at least as many streams as allowed by their 1229 setting for SETTINGS_MAX_CONCURRENT_STREAMS. 1231 An endpoint receiving a PRIORITY frame that changes the priority of a 1232 closed stream SHOULD alter the dependencies of the streams that 1233 depend on it, if it has retained enough state to do so. 1235 5.3.5. Default Priorities 1237 Providing priority information is optional. Streams are assigned a 1238 default dependency on stream 0x0. Pushed streams (Section 8.2) 1239 initially depend on their associated stream. In both cases, streams 1240 are assigned a default weight of 16. 1242 5.4. Error Handling 1244 HTTP/2 framing permits two classes of error: 1246 o An error condition that renders the entire connection unusable is 1247 a connection error. 1249 o An error in an individual stream is a stream error. 1251 A list of error codes is included in Section 7. 1253 5.4.1. Connection Error Handling 1255 A connection error is any error which prevents further processing of 1256 the framing layer, or which corrupts any connection state. 1258 An endpoint that encounters a connection error SHOULD first send a 1259 GOAWAY frame (Section 6.8) with the stream identifier of the last 1260 stream that it successfully received from its peer. The GOAWAY frame 1261 includes an error code that indicates why the connection is 1262 terminating. After sending the GOAWAY frame, the endpoint MUST close 1263 the TCP connection. 1265 It is possible that the GOAWAY will not be reliably received by the 1266 receiving endpoint. In the event of a connection error, GOAWAY only 1267 provides a best effort attempt to communicate with the peer about why 1268 the connection is being terminated. 1270 An endpoint can end a connection at any time. In particular, an 1271 endpoint MAY choose to treat a stream error as a connection error. 1272 Endpoints SHOULD send a GOAWAY frame when ending a connection, 1273 providing that circumstances permit it. 1275 5.4.2. Stream Error Handling 1277 A stream error is an error related to a specific stream that does not 1278 affect processing of other streams. 1280 An endpoint that detects a stream error sends a RST_STREAM frame 1281 (Section 6.4) that contains the stream identifier of the stream where 1282 the error occurred. The RST_STREAM frame includes an error code that 1283 indicates the type of error. 1285 A RST_STREAM is the last frame that an endpoint can send on a stream. 1286 The peer that sends the RST_STREAM frame MUST be prepared to receive 1287 any frames that were sent or enqueued for sending by the remote peer. 1288 These frames can be ignored, except where they modify connection 1289 state (such as the state maintained for header compression 1290 (Section 4.3), or flow control). 1292 Normally, an endpoint SHOULD NOT send more than one RST_STREAM frame 1293 for any stream. However, an endpoint MAY send additional RST_STREAM 1294 frames if it receives frames on a closed stream after more than a 1295 round-trip time. This behavior is permitted to deal with misbehaving 1296 implementations. 1298 An endpoint MUST NOT send a RST_STREAM in response to an RST_STREAM 1299 frame, to avoid looping. 1301 5.4.3. Connection Termination 1303 If the TCP connection is torn down while streams remain in open or 1304 half closed states, then the endpoint MUST assume that those streams 1305 were abnormally interrupted and could be incomplete. 1307 5.5. Extending HTTP/2 1309 HTTP/2 permits extension of the protocol. Protocol extensions can be 1310 used to provide additional services or alter any aspect of the 1311 protocol, within the limitations described in this section. 1312 Extensions are effective only within the scope of a single HTTP/2 1313 connection. 1315 Extensions are permitted to use new frame types (Section 4.1), new 1316 settings (Section 6.5.2), new error codes (Section 7), or new header 1317 fields that start with a colon (:). Of these, registries are 1318 established for frame types (Section 11.2), settings (Section 11.3) 1319 and error codes (Section 11.4). 1321 Implementations MUST ignore unknown or unsupported values in all 1322 extensible protocol elements. Implementations MUST discard frames 1323 that have unknown or unsupported types. This means that any of these 1324 extension points can be safely used by extensions without prior 1325 arrangement or negotiation. 1327 However, extensions that could change the semantics of existing 1328 protocol components MUST be negotiated before being used. For 1329 example, an extension that changes the layout of the HEADERS frame 1330 cannot be used until the peer has given a positive signal that this 1331 is acceptable. In this case, it could also be necessary to 1332 coordinate when the revised layout comes into effect. Note that 1333 treating any frame other than DATA frames as flow controlled is such 1334 a change in semantics, and can only be done through negotiation. 1336 This document doesn't mandate a specific method for negotiating the 1337 use of an extension, but notes that a setting (Section 6.5.2) could 1338 be used for that purpose. If both peers set a value that indicates 1339 willingness to use the extension, then the extension can be used. If 1340 a setting is used for extension negotiation, the initial value MUST 1341 be defined so that the extension is initially disabled. 1343 6. Frame Definitions 1345 This specification defines a number of frame types, each identified 1346 by a unique 8-bit type code. Each frame type serves a distinct 1347 purpose either in the establishment and management of the connection 1348 as a whole, or of individual streams. 1350 The transmission of specific frame types can alter the state of a 1351 connection. If endpoints fail to maintain a synchronized view of the 1352 connection state, successful communication within the connection will 1353 no longer be possible. Therefore, it is important that endpoints 1354 have a shared comprehension of how the state is affected by the use 1355 any given frame. 1357 6.1. DATA 1359 DATA frames (type=0x0) convey arbitrary, variable-length sequences of 1360 octets associated with a stream. One or more DATA frames are used, 1361 for instance, to carry HTTP request or response payloads. 1363 DATA frames MAY also contain arbitrary padding. Padding can be added 1364 to DATA frames to obscure the size of messages. 1366 0 1 2 3 1367 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1368 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1369 |Pad Length? (8)| 1370 +---------------+-----------------------------------------------+ 1371 | Data (*) ... 1372 +---------------------------------------------------------------+ 1373 | Padding (*) ... 1374 +---------------------------------------------------------------+ 1376 DATA Frame Payload 1378 The DATA frame contains the following fields: 1380 Pad Length: An 8-bit field containing the length of the frame 1381 padding in units of octets. This field is optional and is only 1382 present if the PADDED flag is set. 1384 Data: Application data. The amount of data is the remainder of the 1385 frame payload after subtracting the length of the other fields 1386 that are present. 1388 Padding: Padding octets that contain no application semantic value. 1389 Padding octets MUST be set to zero when sending and ignored when 1390 receiving. 1392 The DATA frame defines the following flags: 1394 END_STREAM (0x1): Bit 1 being set indicates that this frame is the 1395 last that the endpoint will send for the identified stream. 1396 Setting this flag causes the stream to enter one of the "half 1397 closed" states or the "closed" state (Section 5.1). 1399 END_SEGMENT (0x2): Bit 2 being set indicates that this frame is the 1400 last for the current segment. Intermediaries MUST NOT coalesce 1401 frames across a segment boundary and MUST preserve segment 1402 boundaries when forwarding frames. 1404 PADDED (0x8): Bit 4 being set indicates that the Pad Length field is 1405 present. 1407 DATA frames MUST be associated with a stream. If a DATA frame is 1408 received whose stream identifier field is 0x0, the recipient MUST 1409 respond with a connection error (Section 5.4.1) of type 1410 PROTOCOL_ERROR. 1412 DATA frames are subject to flow control and can only be sent when a 1413 stream is in the "open" or "half closed (remote)" states. The entire 1414 DATA frame payload is included in flow control, including Pad Length 1415 and Padding fields if present. If a DATA frame is received whose 1416 stream is not in "open" or "half closed (local)" state, the recipient 1417 MUST respond with a stream error (Section 5.4.2) of type 1418 STREAM_CLOSED. 1420 The total number of padding octets is determined by the value of the 1421 Pad Length field. If the length of the padding is greater than the 1422 length of the remainder of the frame payload, the recipient MUST 1423 treat this as a connection error (Section 5.4.1) of type 1424 PROTOCOL_ERROR. 1426 Note: A frame can be increased in size by one octet by including a 1427 Pad Length field with a value of zero. 1429 Use of padding is a security feature; as such, its use demands some 1430 care, see Section 10.7. 1432 6.2. HEADERS 1434 The HEADERS frame (type=0x1) carries name-value pairs. It is used to 1435 open a stream (Section 5.1). HEADERS frames can be sent on a stream 1436 in the "open" or "half closed (remote)" states. 1438 0 1 2 3 1439 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1440 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1441 |Pad Length? (8)| 1442 +-+-------------+-----------------------------------------------+ 1443 |E| Stream Dependency? (31) | 1444 +-+-------------+-----------------------------------------------+ 1445 | Weight? (8) | 1446 +-+-------------+-----------------------------------------------+ 1447 | Header Block Fragment (*) ... 1448 +---------------------------------------------------------------+ 1449 | Padding (*) ... 1450 +---------------------------------------------------------------+ 1452 HEADERS Frame Payload 1454 The HEADERS frame payload has the following fields: 1456 Pad Length: An 8-bit field containing the length of the frame 1457 padding in units of octets. This field is optional and is only 1458 present if the PADDED flag is set. 1460 E: A single bit flag indicates that the stream dependency is 1461 exclusive, see Section 5.3. This field is optional and is only 1462 present if the PRIORITY flag is set. 1464 Stream Dependency: A 31-bit stream identifier for the stream that 1465 this stream depends on, see Section 5.3. This field is optional 1466 and is only present if the PRIORITY flag is set. 1468 Weight: An 8-bit weight for the stream, see Section 5.3. Add one to 1469 the value to obtain a weight between 1 and 256. This field is 1470 optional and is only present if the PRIORITY flag is set. 1472 Header Block Fragment: A header block fragment (Section 4.3). 1474 Padding: Padding octets. 1476 The HEADERS frame defines the following flags: 1478 END_STREAM (0x1): Bit 1 being set indicates that the header block 1479 (Section 4.3) is the last that the endpoint will send for the 1480 identified stream. Setting this flag causes the stream to enter 1481 one of "half closed" states (Section 5.1). 1483 A HEADERS frame that is followed by CONTINUATION frames carries 1484 the END_STREAM flag that signals the end of a stream. A 1485 CONTINUATION frame cannot be used to terminate a stream. 1487 END_SEGMENT (0x2): Bit 2 being set indicates that this frame is the 1488 last for the current segment. Intermediaries MUST NOT coalesce 1489 frames across a segment boundary and MUST preserve segment 1490 boundaries when forwarding frames. 1492 END_HEADERS (0x4): Bit 3 being set indicates that this frame 1493 contains an entire header block (Section 4.3) and is not followed 1494 by any CONTINUATION frames. 1496 A HEADERS frame without the END_HEADERS flag set MUST be followed 1497 by a CONTINUATION frame for the same stream. A receiver MUST 1498 treat the receipt of any other type of frame or a frame on a 1499 different stream as a connection error (Section 5.4.1) of type 1500 PROTOCOL_ERROR. 1502 PADDED (0x8): Bit 4 being set indicates that the Pad Length field is 1503 present. 1505 PRIORITY (0x20): Bit 6 being set indicates that the Exclusive Flag 1506 (E), Stream Dependency, and Weight fields are present; see 1507 Section 5.3. 1509 The payload of a HEADERS frame contains a header block fragment 1510 (Section 4.3). A header block that does not fit within a HEADERS 1511 frame is continued in a CONTINUATION frame (Section 6.10). 1513 HEADERS frames MUST be associated with a stream. If a HEADERS frame 1514 is received whose stream identifier field is 0x0, the recipient MUST 1515 respond with a connection error (Section 5.4.1) of type 1516 PROTOCOL_ERROR. 1518 The HEADERS frame changes the connection state as described in 1519 Section 4.3. 1521 The HEADERS frame includes optional padding. Padding fields and 1522 flags are identical to those defined for DATA frames (Section 6.1). 1524 6.3. PRIORITY 1526 The PRIORITY frame (type=0x2) specifies the sender-advised priority 1527 of a stream (Section 5.3). It can be sent at any time for an 1528 existing stream, including closed streams. This enables 1529 reprioritization of existing streams. 1531 0 1 2 3 1532 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1533 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1534 |E| Stream Dependency (31) | 1535 +-+-------------+-----------------------------------------------+ 1536 | Weight (8) | 1537 +-+-------------+ 1539 PRIORITY Frame Payload 1541 The payload of a PRIORITY frame contains the following fields: 1543 E: A single bit flag indicates that the stream dependency is 1544 exclusive, see Section 5.3. 1546 Stream Dependency: A 31-bit stream identifier for the stream that 1547 this stream depends on, see Section 5.3. 1549 Weight: An 8-bit weight for the identified stream dependency, see 1550 Section 5.3. Add one to the value to obtain a weight between 1 1551 and 256. 1553 The PRIORITY frame does not define any flags. 1555 The PRIORITY frame is associated with an existing stream. If a 1556 PRIORITY frame is received with a stream identifier of 0x0, the 1557 recipient MUST respond with a connection error (Section 5.4.1) of 1558 type PROTOCOL_ERROR. 1560 The PRIORITY frame can be sent on a stream in any of the "reserved 1561 (remote)", "open", "half closed (local)", "half closed (remote)", or 1562 "closed" states, though it cannot be sent between consecutive frames 1563 that comprise a single header block (Section 4.3). Note that this 1564 frame could arrive after processing or frame sending has completed, 1565 which would cause it to have no effect on the current stream. For a 1566 stream that is in the "half closed (remote)" or "closed" - state, 1567 this frame can only affect processing of the current stream and not 1568 frame transmission. 1570 The PRIORITY frame is the only frame that can be sent for a stream in 1571 the "closed" state. This allows for the reprioritization of a group 1572 of dependent streams by altering the priority of a parent stream, 1573 which might be closed. However, a PRIORITY frame sent on a closed 1574 stream risks being ignored due to the peer having discarded priority 1575 state information for that stream. 1577 6.4. RST_STREAM 1579 The RST_STREAM frame (type=0x3) allows for abnormal termination of a 1580 stream. When sent by the initiator of a stream, it indicates that 1581 they wish to cancel the stream or that an error condition has 1582 occurred. When sent by the receiver of a stream, it indicates that 1583 either the receiver is rejecting the stream, requesting that the 1584 stream be cancelled, or that an error condition has occurred. 1586 0 1 2 3 1587 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1588 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1589 | Error Code (32) | 1590 +---------------------------------------------------------------+ 1592 RST_STREAM Frame Payload 1594 The RST_STREAM frame contains a single unsigned, 32-bit integer 1595 identifying the error code (Section 7). The error code indicates why 1596 the stream is being terminated. 1598 The RST_STREAM frame does not define any flags. 1600 The RST_STREAM frame fully terminates the referenced stream and 1601 causes it to enter the closed state. After receiving a RST_STREAM on 1602 a stream, the receiver MUST NOT send additional frames for that 1603 stream. However, after sending the RST_STREAM, the sending endpoint 1604 MUST be prepared to receive and process additional frames sent on the 1605 stream that might have been sent by the peer prior to the arrival of 1606 the RST_STREAM. 1608 RST_STREAM frames MUST be associated with a stream. If a RST_STREAM 1609 frame is received with a stream identifier of 0x0, the recipient MUST 1610 treat this as a connection error (Section 5.4.1) of type 1611 PROTOCOL_ERROR. 1613 RST_STREAM frames MUST NOT be sent for a stream in the "idle" state. 1614 If a RST_STREAM frame identifying an idle stream is received, the 1615 recipient MUST treat this as a connection error (Section 5.4.1) of 1616 type PROTOCOL_ERROR. 1618 6.5. SETTINGS 1620 The SETTINGS frame (type=0x4) conveys configuration parameters that 1621 affect how endpoints communicate, such as preferences and constraints 1622 on peer behavior. The SETTINGS frame is also used to acknowledge the 1623 receipt of those parameters. Individually, a SETTINGS parameter can 1624 also be referred to as a "setting". 1626 SETTINGS parameters are not negotiated; they describe characteristics 1627 of the sending peer, which are used by the receiving peer. Different 1628 values for the same parameter can be advertised by each peer. For 1629 example, a client might set a high initial flow control window, 1630 whereas a server might set a lower value to conserve resources. 1632 A SETTINGS frame MUST be sent by both endpoints at the start of a 1633 connection, and MAY be sent at any other time by either endpoint over 1634 the lifetime of the connection. Implementations MUST support all of 1635 the parameters defined by this specification. 1637 Each parameter in a SETTINGS frame replaces any existing value for 1638 that parameter. Parameters are processed in the order in which they 1639 appear, and a receiver of a SETTINGS frame does not need to maintain 1640 any state other than the current value of its parameters. Therefore, 1641 the value of a SETTINGS parameter is the last value that is seen by a 1642 receiver. 1644 SETTINGS parameters are acknowledged by the receiving peer. To 1645 enable this, the SETTINGS frame defines the following flag: 1647 ACK (0x1): Bit 1 being set indicates that this frame acknowledges 1648 receipt and application of the peer's SETTINGS frame. When this 1649 bit is set, the payload of the SETTINGS frame MUST be empty. 1650 Receipt of a SETTINGS frame with the ACK flag set and a length 1651 field value other than 0 MUST be treated as a connection error 1652 (Section 5.4.1) of type FRAME_SIZE_ERROR. For more info, see 1653 Settings Synchronization (Section 6.5.3). 1655 SETTINGS frames always apply to a connection, never a single stream. 1656 The stream identifier for a SETTINGS frame MUST be zero (0x0). If an 1657 endpoint receives a SETTINGS frame whose stream identifier field is 1658 anything other than 0x0, the endpoint MUST respond with a connection 1659 error (Section 5.4.1) of type PROTOCOL_ERROR. 1661 The SETTINGS frame affects connection state. A badly formed or 1662 incomplete SETTINGS frame MUST be treated as a connection error 1663 (Section 5.4.1) of type PROTOCOL_ERROR. 1665 6.5.1. SETTINGS Format 1667 The payload of a SETTINGS frame consists of zero or more parameters, 1668 each consisting of an unsigned 16-bit setting identifier and an 1669 unsigned 32-bit value. 1671 0 1 2 3 1672 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1673 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1674 | Identifier (16) | 1675 +-------------------------------+-------------------------------+ 1676 | Value (32) | 1677 +---------------------------------------------------------------+ 1679 Setting Format 1681 6.5.2. Defined SETTINGS Parameters 1683 The following parameters are defined: 1685 SETTINGS_HEADER_TABLE_SIZE (0x1): Allows the sender to inform the 1686 remote endpoint of the maximum size of the header compression 1687 table used to decode header blocks. The encoder can select any 1688 size equal to or less than this value by using signaling specific 1689 to the header compression format inside a header block. The 1690 initial value is 4,096 bytes. 1692 SETTINGS_ENABLE_PUSH (0x2): This setting can be use to disable 1693 server push (Section 8.2). An endpoint MUST NOT send a 1694 PUSH_PROMISE frame if it receives this parameter set to a value of 1695 0. An endpoint that has both set this parameter to 0 and had it 1696 acknowledged MUST treat the receipt of a PUSH_PROMISE frame as a 1697 connection error (Section 5.4.1) of type PROTOCOL_ERROR. 1699 The initial value is 1, which indicates that server push is 1700 permitted. Any value other than 0 or 1 MUST be treated as a 1701 connection error (Section 5.4.1) of type PROTOCOL_ERROR. 1703 SETTINGS_MAX_CONCURRENT_STREAMS (0x3): Indicates the maximum number 1704 of concurrent streams that the sender will allow. This limit is 1705 directional: it applies to the number of streams that the sender 1706 permits the receiver to create. Initially there is no limit to 1707 this value. It is recommended that this value be no smaller than 1708 100, so as to not unnecessarily limit parallelism. 1710 A value of 0 for SETTINGS_MAX_CONCURRENT_STREAMS SHOULD NOT be 1711 treated as special by endpoints. A zero value does prevent the 1712 creation of new streams, however this can also happen for any 1713 limit that is exhausted with active streams. Servers SHOULD only 1714 set a zero value for short durations; if a server does not wish to 1715 accept requests, closing the connection could be preferable. 1717 SETTINGS_INITIAL_WINDOW_SIZE (0x4): Indicates the sender's initial 1718 window size (in bytes) for stream level flow control. The initial 1719 value is 65,535. 1721 This setting affects the window size of all streams, including 1722 existing streams, see Section 6.9.2. 1724 Values above the maximum flow control window size of 2^31 - 1 MUST 1725 be treated as a connection error (Section 5.4.1) of type 1726 FLOW_CONTROL_ERROR. 1728 An endpoint that receives a SETTINGS frame with any unknown or 1729 unsupported identifier MUST ignore that setting. 1731 6.5.3. Settings Synchronization 1733 Most values in SETTINGS benefit from or require an understanding of 1734 when the peer has received and applied the changed the communicated 1735 parameter values. In order to provide such synchronization 1736 timepoints, the recipient of a SETTINGS frame in which the ACK flag 1737 is not set MUST apply the updated parameters as soon as possible upon 1738 receipt. 1740 The values in the SETTINGS frame MUST be applied in the order they 1741 appear, with no other frame processing between values. Once all 1742 values have been applied, the recipient MUST immediately emit a 1743 SETTINGS frame with the ACK flag set. Upon receiving a SETTINGS 1744 frame with the ACK flag set, the sender of the altered parameters can 1745 rely upon their application. 1747 If the sender of a SETTINGS frame does not receive an acknowledgement 1748 within a reasonable amount of time, it MAY issue a connection error 1749 (Section 5.4.1) of type SETTINGS_TIMEOUT. 1751 6.6. PUSH_PROMISE 1753 The PUSH_PROMISE frame (type=0x5) is used to notify the peer endpoint 1754 in advance of streams the sender intends to initiate. The 1755 PUSH_PROMISE frame includes the unsigned 31-bit identifier of the 1756 stream the endpoint plans to create along with a set of headers that 1757 provide additional context for the stream. Section 8.2 contains a 1758 thorough description of the use of PUSH_PROMISE frames. 1760 0 1 2 3 1761 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1762 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1763 |Pad Length? (8)| 1764 +-+-------------+-----------------------------------------------+ 1765 |R| Promised Stream ID (31) | 1766 +-+-----------------------------+-------------------------------+ 1767 | Header Block Fragment (*) ... 1768 +---------------------------------------------------------------+ 1769 | Padding (*) ... 1770 +---------------------------------------------------------------+ 1772 PUSH_PROMISE Payload Format 1774 The PUSH_PROMISE frame payload has the following fields: 1776 Pad Length: An 8-bit field containing the length of the frame 1777 padding in units of octets. This field is optional and is only 1778 present if the PADDED flag is set. 1780 R: A single reserved bit. 1782 Promised Stream ID: This unsigned 31-bit integer identifies the 1783 stream the endpoint intends to start sending frames for. The 1784 promised stream identifier MUST be a valid choice for the next 1785 stream sent by the sender (see new stream identifier 1786 (Section 5.1.1)). 1788 Header Block Fragment: A header block fragment (Section 4.3) 1789 containing request header fields. 1791 Padding: Padding octets. 1793 The PUSH_PROMISE frame defines the following flags: 1795 END_HEADERS (0x4): Bit 3 being set indicates that this frame 1796 contains an entire header block (Section 4.3) and is not followed 1797 by any CONTINUATION frames. 1799 A PUSH_PROMISE frame without the END_HEADERS flag set MUST be 1800 followed by a CONTINUATION frame for the same stream. A receiver 1801 MUST treat the receipt of any other type of frame or a frame on a 1802 different stream as a connection error (Section 5.4.1) of type 1803 PROTOCOL_ERROR. 1805 PADDED (0x8): Bit 4 being set indicates that the Pad Length field is 1806 present. 1808 PUSH_PROMISE frames MUST be associated with an existing, peer- 1809 initiated stream. The stream identifier of a PUSH_PROMISE frame 1810 indicates the stream it is associated with. If the stream identifier 1811 field specifies the value 0x0, a recipient MUST respond with a 1812 connection error (Section 5.4.1) of type PROTOCOL_ERROR. 1814 Promised streams are not required to be used in the order they are 1815 promised. The PUSH_PROMISE only reserves stream identifiers for 1816 later use. 1818 PUSH_PROMISE MUST NOT be sent if the SETTINGS_ENABLE_PUSH setting of 1819 the peer endpoint is set to 0. An endpoint that has set this setting 1820 and has received acknowledgement MUST treat the receipt of a 1821 PUSH_PROMISE frame as a connection error (Section 5.4.1) of type 1822 PROTOCOL_ERROR. 1824 Recipients of PUSH_PROMISE frames can choose to reject promised 1825 streams by returning a RST_STREAM referencing the promised stream 1826 identifier back to the sender of the PUSH_PROMISE. 1828 A PUSH_PROMISE frame modifies the connection state in two ways. The 1829 inclusion of a header block (Section 4.3) potentially modifies the 1830 state maintained for header compression. PUSH_PROMISE also reserves 1831 a stream for later use, causing the promised stream to enter the 1832 "reserved" state. A sender MUST NOT send a PUSH_PROMISE on a stream 1833 unless that stream is either "open" or "half closed (remote)"; the 1834 sender MUST ensure that the promised stream is a valid choice for a 1835 new stream identifier (Section 5.1.1) (that is, the promised stream 1836 MUST be in the "idle" state). 1838 Since PUSH_PROMISE reserves a stream, ignoring a PUSH_PROMISE frame 1839 causes the stream state to become indeterminate. A receiver MUST 1840 treat the receipt of a PUSH_PROMISE on a stream that is neither 1841 "open" nor "half closed (local)" as a connection error 1842 (Section 5.4.1) of type PROTOCOL_ERROR. Similarly, a receiver MUST 1843 treat the receipt of a PUSH_PROMISE that promises an illegal stream 1844 identifier (Section 5.1.1) (that is, an identifier for a stream that 1845 is not currently in the "idle" state) as a connection error 1846 (Section 5.4.1) of type PROTOCOL_ERROR. 1848 The PUSH_PROMISE frame includes optional padding. Padding fields and 1849 flags are identical to those defined for DATA frames (Section 6.1). 1851 6.7. PING 1853 The PING frame (type=0x6) is a mechanism for measuring a minimal 1854 round trip time from the sender, as well as determining whether an 1855 idle connection is still functional. PING frames can be sent from 1856 any endpoint. 1858 0 1 2 3 1859 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1860 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1861 | | 1862 | Opaque Data (64) | 1863 | | 1864 +---------------------------------------------------------------+ 1866 PING Payload Format 1868 In addition to the frame header, PING frames MUST contain 8 octets of 1869 data in the payload. A sender can include any value it chooses and 1870 use those bytes in any fashion. 1872 Receivers of a PING frame that does not include an ACK flag MUST send 1873 a PING frame with the ACK flag set in response, with an identical 1874 payload. PING responses SHOULD be given higher priority than any 1875 other frame. 1877 The PING frame defines the following flags: 1879 ACK (0x1): Bit 1 being set indicates that this PING frame is a PING 1880 response. An endpoint MUST set this flag in PING responses. An 1881 endpoint MUST NOT respond to PING frames containing this flag. 1883 PING frames are not associated with any individual stream. If a PING 1884 frame is received with a stream identifier field value other than 1885 0x0, the recipient MUST respond with a connection error 1886 (Section 5.4.1) of type PROTOCOL_ERROR. 1888 Receipt of a PING frame with a length field value other than 8 MUST 1889 be treated as a connection error (Section 5.4.1) of type 1890 FRAME_SIZE_ERROR. 1892 6.8. GOAWAY 1894 The GOAWAY frame (type=0x7) informs the remote peer to stop creating 1895 streams on this connection. GOAWAY can be sent by either the client 1896 or the server. Once sent, the sender will ignore frames sent on any 1897 new streams with identifiers higher than the included last stream 1898 identifier. Receivers of a GOAWAY frame MUST NOT open additional 1899 streams on the connection, although a new connection can be 1900 established for new streams. 1902 The purpose of this frame is to allow an endpoint to gracefully stop 1903 accepting new streams, while still finishing processing of previously 1904 established streams. This enables administrative actions, like 1905 server maintainence. 1907 There is an inherent race condition between an endpoint starting new 1908 streams and the remote sending a GOAWAY frame. To deal with this 1909 case, the GOAWAY contains the stream identifier of the last stream 1910 which was or might be processed on the sending endpoint in this 1911 connection. If the receiver of the GOAWAY has sent data on streams 1912 with a higher stream identifier than what is indicated in the GOAWAY 1913 frame, those streams are not or will not be processed. The receiver 1914 of the GOAWAY frame can treat the streams as though they had never 1915 been created at all, thereby allowing those streams to be retried 1916 later on a new connection. 1918 Endpoints SHOULD always send a GOAWAY frame before closing a 1919 connection so that the remote can know whether a stream has been 1920 partially processed or not. For example, if an HTTP client sends a 1921 POST at the same time that a server closes a connection, the client 1922 cannot know if the server started to process that POST request if the 1923 server does not send a GOAWAY frame to indicate what streams it might 1924 have acted on. 1926 An endpoint might choose to close a connection without sending GOAWAY 1927 for misbehaving peers. 1929 0 1 2 3 1930 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1931 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1932 |R| Last-Stream-ID (31) | 1933 +-+-------------------------------------------------------------+ 1934 | Error Code (32) | 1935 +---------------------------------------------------------------+ 1936 | Additional Debug Data (*) | 1937 +---------------------------------------------------------------+ 1939 GOAWAY Payload Format 1941 The GOAWAY frame does not define any flags. 1943 The GOAWAY frame applies to the connection, not a specific stream. 1944 An endpoint MUST treat a GOAWAY frame with a stream identifier other 1945 than 0x0 as a connection error (Section 5.4.1) of type 1946 PROTOCOL_ERROR. 1948 The last stream identifier in the GOAWAY frame contains the highest 1949 numbered stream identifier for which the sender of the GOAWAY frame 1950 might have taken some action on, or might yet take action on. All 1951 streams up to and including the identified stream might have been 1952 processed in some way. The last stream identifier can be set to 0 if 1953 no streams were processed. 1955 Note: In this context, "processed" means that some data from the 1956 stream was passed to some higher layer of software that might have 1957 taken some action as a result. 1959 If a connection terminates without a GOAWAY frame, the last stream 1960 identifier is effectively the highest possible stream identifier. 1962 On streams with lower or equal numbered identifiers that were not 1963 closed completely prior to the connection being closed, re-attempting 1964 requests, transactions, or any protocol activity is not possible, 1965 with the exception of idempotent actions like HTTP GET, PUT, or 1966 DELETE. Any protocol activity that uses higher numbered streams can 1967 be safely retried using a new connection. 1969 Activity on streams numbered lower or equal to the last stream 1970 identifier might still complete successfully. The sender of a GOAWAY 1971 frame might gracefully shut down a connection by sending a GOAWAY 1972 frame, maintaining the connection in an open state until all in- 1973 progress streams complete. 1975 An endpoint MAY send multiple GOAWAY frames if circumstances change. 1976 For instance, an endpoint that sends GOAWAY with NO_ERROR during 1977 graceful shutdown could subsequently encounter an condition that 1978 requires immediate termination of the connection. The last stream 1979 identifier from the last GOAWAY frame received indicates which 1980 streams could have been acted upon. Endpoints MUST NOT increase the 1981 value they send in the last stream identifier, since the peers might 1982 already have retried unprocessed requests on another connection. 1984 A client that is unable to retry requests loses all requests that are 1985 in flight when the server closes the connection. This is especially 1986 true for intermediaries that might not be serving clients using 1987 HTTP/2. A server that is attempting to gracefully shut down a 1988 connection SHOULD send an initial GOAWAY frame with the last stream 1989 identifier set to 2^31-1 and a NO_ERROR code. This signals to the 1990 client that a shutdown is imminent and that no further requests can 1991 be initiated. After waiting at least one round trip time, the server 1992 can send another GOAWAY frame with an updated last stream identifier. 1993 This ensures that a connection can be cleanly shut down without 1994 losing requests. 1996 After sending a GOAWAY frame, the sender can discard frames for 1997 streams with identifiers higher than the identified last stream. 1998 However, any frames that alter connection state cannot be completely 1999 ignored. For instance, HEADERS, PUSH_PROMISE and CONTINUATION frames 2000 MUST be minimally processed to ensure the state maintained for header 2001 compression is consistent (see Section 4.3); similarly DATA frames 2002 MUST be counted toward the connection flow control window. Failure 2003 to process these frames can cause flow control or header compression 2004 state to become unsynchronized. 2006 The GOAWAY frame also contains a 32-bit error code (Section 7) that 2007 contains the reason for closing the connection. 2009 Endpoints MAY append opaque data to the payload of any GOAWAY frame. 2010 Additional debug data is intended for diagnostic purposes only and 2011 carries no semantic value. Debug information could contain security- 2012 or privacy-sensitive data. Logged or otherwise persistently stored 2013 debug data MUST have adequate safeguards to prevent unauthorized 2014 access. 2016 6.9. WINDOW_UPDATE 2018 The WINDOW_UPDATE frame (type=0x8) is used to implement flow control; 2019 see Section 5.2 for an overview. 2021 Flow control operates at two levels: on each individual stream and on 2022 the entire connection. 2024 Both types of flow control are hop-by-hop; that is, only between the 2025 two endpoints. Intermediaries do not forward WINDOW_UPDATE frames 2026 between dependent connections. However, throttling of data transfer 2027 by any receiver can indirectly cause the propagation of flow control 2028 information toward the original sender. 2030 Flow control only applies to frames that are identified as being 2031 subject to flow control. Of the frame types defined in this 2032 document, this includes only DATA frames. Frames that are exempt 2033 from flow control MUST be accepted and processed, unless the receiver 2034 is unable to assign resources to handling the frame. A receiver MAY 2035 respond with a stream error (Section 5.4.2) or connection error 2036 (Section 5.4.1) of type FLOW_CONTROL_ERROR if it is unable to accept 2037 a frame. 2039 0 1 2 3 2040 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2041 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2042 |R| Window Size Increment (31) | 2043 +-+-------------------------------------------------------------+ 2045 WINDOW_UPDATE Payload Format 2047 The payload of a WINDOW_UPDATE frame is one reserved bit, plus an 2048 unsigned 31-bit integer indicating the number of bytes that the 2049 sender can transmit in addition to the existing flow control window. 2050 The legal range for the increment to the flow control window is 1 to 2051 2^31 - 1 (0x7fffffff) bytes. 2053 The WINDOW_UPDATE frame does not define any flags. 2055 The WINDOW_UPDATE frame can be specific to a stream or to the entire 2056 connection. In the former case, the frame's stream identifier 2057 indicates the affected stream; in the latter, the value "0" indicates 2058 that the entire connection is the subject of the frame. 2060 WINDOW_UPDATE can be sent by a peer that has sent a frame bearing the 2061 END_STREAM flag. This means that a receiver could receive a 2062 WINDOW_UPDATE frame on a "half closed (remote)" or "closed" stream. 2063 A receiver MUST NOT treat this as an error, see Section 5.1. 2065 A receiver that receives a flow controlled frame MUST always account 2066 for its contribution against the connection flow control window, 2067 unless the receiver treats this as a connection error 2068 (Section 5.4.1). This is necessary even if the frame is in error. 2069 Since the sender counts the frame toward the flow control window, if 2070 the receiver does not, the flow control window at sender and receiver 2071 can become different. 2073 6.9.1. The Flow Control Window 2075 Flow control in HTTP/2 is implemented using a window kept by each 2076 sender on every stream. The flow control window is a simple integer 2077 value that indicates how many bytes of data the sender is permitted 2078 to transmit; as such, its size is a measure of the buffering capacity 2079 of the receiver. 2081 Two flow control windows are applicable: the stream flow control 2082 window and the connection flow control window. The sender MUST NOT 2083 send a flow controlled frame with a length that exceeds the space 2084 available in either of the flow control windows advertised by the 2085 receiver. Frames with zero length with the END_STREAM flag set (that 2086 is, an empty DATA frame) MAY be sent if there is no available space 2087 in either flow control window. 2089 For flow control calculations, the 8 byte frame header is not 2090 counted. 2092 After sending a flow controlled frame, the sender reduces the space 2093 available in both windows by the length of the transmitted frame. 2095 The receiver of a frame sends a WINDOW_UPDATE frame as it consumes 2096 data and frees up space in flow control windows. Separate 2097 WINDOW_UPDATE frames are sent for the stream and connection level 2098 flow control windows. 2100 A sender that receives a WINDOW_UPDATE frame updates the 2101 corresponding window by the amount specified in the frame. 2103 A sender MUST NOT allow a flow control window to exceed 2^31 - 1 2104 bytes. If a sender receives a WINDOW_UPDATE that causes a flow 2105 control window to exceed this maximum it MUST terminate either the 2106 stream or the connection, as appropriate. For streams, the sender 2107 sends a RST_STREAM with the error code of FLOW_CONTROL_ERROR code; 2108 for the connection, a GOAWAY frame with a FLOW_CONTROL_ERROR code. 2110 Flow controlled frames from the sender and WINDOW_UPDATE frames from 2111 the receiver are completely asynchronous with respect to each other. 2112 This property allows a receiver to aggressively update the window 2113 size kept by the sender to prevent streams from stalling. 2115 6.9.2. Initial Flow Control Window Size 2117 When an HTTP/2 connection is first established, new streams are 2118 created with an initial flow control window size of 65,535 bytes. 2119 The connection flow control window is 65,535 bytes. Both endpoints 2120 can adjust the initial window size for new streams by including a 2121 value for SETTINGS_INITIAL_WINDOW_SIZE in the SETTINGS frame that 2122 forms part of the connection preface. The connection flow control 2123 window can only be changed using WINDOW_UPDATE frames. 2125 Prior to receiving a SETTINGS frame that sets a value for 2126 SETTINGS_INITIAL_WINDOW_SIZE, an endpoint can only use the default 2127 initial window size when sending flow controlled frames. Similarly, 2128 the connection flow control window is set to the default initial 2129 window size until a WINDOW_UPDATE frame is received. 2131 A SETTINGS frame can alter the initial flow control window size for 2132 all current streams. When the value of SETTINGS_INITIAL_WINDOW_SIZE 2133 changes, a receiver MUST adjust the size of all stream flow control 2134 windows that it maintains by the difference between the new value and 2135 the old value. 2137 A change to SETTINGS_INITIAL_WINDOW_SIZE can cause the available 2138 space in a flow control window to become negative. A sender MUST 2139 track the negative flow control window, and MUST NOT send new flow 2140 controlled frames until it receives WINDOW_UPDATE frames that cause 2141 the flow control window to become positive. 2143 For example, if the client sends 60KB immediately on connection 2144 establishment, and the server sets the initial window size to be 2145 16KB, the client will recalculate the available flow control window 2146 to be -44KB on receipt of the SETTINGS frame. The client retains a 2147 negative flow control window until WINDOW_UPDATE frames restore the 2148 window to being positive, after which the client can resume sending. 2150 A SETTINGS frame cannot alter the connection flow control window. 2152 An endpoint MUST treat a change to SETTINGS_INITIAL_WINDOW_SIZE that 2153 causes any flow control window to exceed the maximum size as a 2154 connection error (Section 5.4.1) of type FLOW_CONTROL_ERROR. 2156 6.9.3. Reducing the Stream Window Size 2158 A receiver that wishes to use a smaller flow control window than the 2159 current size can send a new SETTINGS frame. However, the receiver 2160 MUST be prepared to receive data that exceeds this window size, since 2161 the sender might send data that exceeds the lower limit prior to 2162 processing the SETTINGS frame. 2164 After sending a SETTINGS frame that reduces the initial flow control 2165 window size, a receiver has two options for handling streams that 2166 exceed flow control limits: 2168 1. The receiver can immediately send RST_STREAM with 2169 FLOW_CONTROL_ERROR error code for the affected streams. 2171 2. The receiver can accept the streams and tolerate the resulting 2172 head of line blocking, sending WINDOW_UPDATE frames as it 2173 consumes data. 2175 6.10. CONTINUATION 2177 The CONTINUATION frame (type=0x9) is used to continue a sequence of 2178 header block fragments (Section 4.3). Any number of CONTINUATION 2179 frames can be sent on an existing stream, as long as the preceding 2180 frame is on the same stream and is a HEADERS, PUSH_PROMISE or 2181 CONTINUATION frame without the END_HEADERS flag set. 2183 0 1 2 3 2184 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2185 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2186 | Header Block Fragment (*) ... 2187 +---------------------------------------------------------------+ 2189 CONTINUATION Frame Payload 2191 The CONTINUATION frame payload contains a header block fragment 2192 (Section 4.3). 2194 The CONTINUATION frame defines the following flag: 2196 END_HEADERS (0x4): Bit 3 being set indicates that this frame ends a 2197 header block (Section 4.3). 2199 If the END_HEADERS bit is not set, this frame MUST be followed by 2200 another CONTINUATION frame. A receiver MUST treat the receipt of 2201 any other type of frame or a frame on a different stream as a 2202 connection error (Section 5.4.1) of type PROTOCOL_ERROR. 2204 The CONTINUATION frame changes the connection state as defined in 2205 Section 4.3. 2207 CONTINUATION frames MUST be associated with a stream. If a 2208 CONTINUATION frame is received whose stream identifier field is 0x0, 2209 the recipient MUST respond with a connection error (Section 5.4.1) of 2210 type PROTOCOL_ERROR. 2212 A CONTINUATION frame MUST be preceded by a HEADERS, PUSH_PROMISE or 2213 CONTINUATION frame without the END_HEADERS flag set. A recipient 2214 that observes violation of this rule MUST respond with a connection 2215 error (Section 5.4.1) of type PROTOCOL_ERROR. 2217 7. Error Codes 2219 Error codes are 32-bit fields that are used in RST_STREAM and GOAWAY 2220 frames to convey the reasons for the stream or connection error. 2222 Error codes share a common code space. Some error codes apply only 2223 to either streams or the entire connection and have no defined 2224 semantics in the other context. 2226 The following error codes are defined: 2228 NO_ERROR (0x0): The associated condition is not as a result of an 2229 error. For example, a GOAWAY might include this code to indicate 2230 graceful shutdown of a connection. 2232 PROTOCOL_ERROR (0x1): The endpoint detected an unspecific protocol 2233 error. This error is for use when a more specific error code is 2234 not available. 2236 INTERNAL_ERROR (0x2): The endpoint encountered an unexpected 2237 internal error. 2239 FLOW_CONTROL_ERROR (0x3): The endpoint detected that its peer 2240 violated the flow control protocol. 2242 SETTINGS_TIMEOUT (0x4): The endpoint sent a SETTINGS frame, but did 2243 not receive a response in a timely manner. See Settings 2244 Synchronization (Section 6.5.3). 2246 STREAM_CLOSED (0x5): The endpoint received a frame after a stream 2247 was half closed. 2249 FRAME_SIZE_ERROR (0x6): The endpoint received a frame that was 2250 larger than the maximum size that it supports. 2252 REFUSED_STREAM (0x7): The endpoint refuses the stream prior to 2253 performing any application processing, see Section 8.1.4 for 2254 details. 2256 CANCEL (0x8): Used by the endpoint to indicate that the stream is no 2257 longer needed. 2259 COMPRESSION_ERROR (0x9): The endpoint is unable to maintain the 2260 header compression context for the connection. 2262 CONNECT_ERROR (0xa): The connection established in response to a 2263 CONNECT request (Section 8.3) was reset or abnormally closed. 2265 ENHANCE_YOUR_CALM (0xb): The endpoint detected that its peer is 2266 exhibiting a behavior that might be generating excessive load. 2268 INADEQUATE_SECURITY (0xc): The underlying transport has properties 2269 that do not meet minimum security requirements (see Section 9.2). 2271 Unknown or unsupported error codes MUST NOT trigger any special 2272 behavior. These MAY be treated by an implementation as being 2273 equivalent to INTERNAL_ERROR. 2275 8. HTTP Message Exchanges 2277 HTTP/2 is intended to be as compatible as possible with current uses 2278 of HTTP. This means that, from the application perspective, the 2279 features of the protocol are largely unchanged. To achieve this, all 2280 request and response semantics are preserved, although the syntax of 2281 conveying those semantics has changed. 2283 Thus, the specification and requirements of HTTP/1.1 Semantics and 2284 Content [RFC7231], Conditional Requests [RFC7232], Range Requests 2285 [RFC7233], Caching [RFC7234] and Authentication [RFC7235] are 2286 applicable to HTTP/2. Selected portions of HTTP/1.1 Message Syntax 2287 and Routing [RFC7230], such as the HTTP and HTTPS URI schemes, are 2288 also applicable in HTTP/2, but the expression of those semantics for 2289 this protocol are defined in the sections below. 2291 8.1. HTTP Request/Response Exchange 2293 A client sends an HTTP request on a new stream, using a previously 2294 unused stream identifier (Section 5.1.1). A server sends an HTTP 2295 response on the same stream as the request. 2297 An HTTP message (request or response) consists of: 2299 1. one HEADERS frame (followed by zero or more CONTINUATION frames) 2300 containing the message headers (see [RFC7230], Section 3.2), and 2302 2. zero or more DATA frames containing the message payload (see 2303 [RFC7230], Section 3.3), and 2305 3. optionally, one HEADERS frame, followed by zero or more 2306 CONTINUATION frames containing the trailer-part, if present (see 2307 [RFC7230], Section 4.1.2). 2309 The last frame in the sequence bears an END_STREAM flag, noting that 2310 a HEADERS frame bearing the END_STREAM flag can be followed by 2311 CONTINUATION frames that carry any remaining portions of the header 2312 block. 2314 Other frames (from any stream) MUST NOT occur between either HEADERS 2315 frame and any CONTINUATION frames that might follow. 2317 Otherwise, frames MAY be interspersed on the stream between these 2318 frames, but those frames do not carry HTTP semantics. In particular, 2319 HEADERS frames (and any CONTINUATION frames that follow) other than 2320 the first and optional last frames in this sequence do not carry HTTP 2321 semantics. 2323 Trailing header fields are carried in a header block that also 2324 terminates the stream. That is, a sequence starting with a HEADERS 2325 frame, followed by zero or more CONTINUATION frames, where the 2326 HEADERS frame bears an END_STREAM flag. Header blocks after the 2327 first that do not terminate the stream are not part of an HTTP 2328 request or response. 2330 An HTTP request/response exchange fully consumes a single stream. A 2331 request starts with the HEADERS frame that puts the stream into an 2332 "open" state and ends with a frame bearing END_STREAM, which causes 2333 the stream to become "half closed" for the client. A response starts 2334 with a HEADERS frame and ends with a frame bearing END_STREAM, 2335 optionally followed by CONTINUATION frames, which places the stream 2336 in the "closed" state. 2338 8.1.1. Informational Responses 2340 The 1xx series of HTTP response status codes ([RFC7231], Section 6.2) 2341 are not supported in HTTP/2. 2343 The most common use case for 1xx is using an Expect header field with 2344 a "100-continue" token (colloquially, "Expect/continue") to indicate 2345 that the client expects a 100 (Continue) non-final response status 2346 code, receipt of which indicates that the client should continue 2347 sending the request body if it has not already done so. 2349 Typically, Expect/continue is used by clients wishing to avoid 2350 sending a large amount of data in a request body, only to have the 2351 request rejected by the origin server, thereby leaving the connection 2352 potentially unusable. 2354 HTTP/2 does not enable the Expect/continue mechanism; if the server 2355 sends a final status code to reject the request, it can do so without 2356 making the underlying connection unusable. 2358 Note that this means HTTP/2 clients sending requests with bodies may 2359 waste at least one round trip of sent data when the request is 2360 rejected. This can be mitigated by restricting the amount of data 2361 sent for the first round trip by bandwidth-constrained clients, in 2362 anticipation of a final status code. 2364 Other defined 1xx status codes are not applicable to HTTP/2. For 2365 example, the semantics of 101 (Switching Protocols) aren't suitable 2366 to a multiplexed protocol. Likewise, 102 (Processing) [RFC2518] is 2367 no longer necessary to ensure connection liveness, because HTTP/2 has 2368 a separate means of keeping the connection alive. The use of the 102 2369 (Processing) status code for progress reporting has since been 2370 deprecated and is not retained. 2372 This difference between protocol versions necessitates special 2373 handling by intermediaries that translate between them: 2375 o An intermediary that translates HTTP/1.1 requests to HTTP/2 MUST 2376 generate a 100 (Continue) response if a received request includes 2377 and Expect header field with a "100-continue" token ([RFC7231], 2378 Section 5.1.1), unless it can immediately generate a final status 2379 code. It MUST NOT forward the "100-continue" expectation in the 2380 request header fields. 2382 o An intermediary that translates HTTP/2 to HTTP/1.1 MAY add an 2383 Expect header field with a "100-continue" expectation when 2384 forwarding a request that has a body; see [RFC7231], Section 5.1.1 2385 for specific requirements. 2387 o An intermediary that gateways HTTP/2 to HTTP/1.1 MUST discard all 2388 other 1xx informational responses. 2390 8.1.2. HTTP Header Fields 2392 HTTP header fields carry information as a series of key-value pairs. 2393 For a listing of registered HTTP headers, see the Message Header 2394 Field Registry maintained at [4]. 2396 While HTTP/1.x used the message start-line (see [RFC7230], 2397 Section 3.1) to convey the target URI and method of the request, and 2398 the status code for the response, HTTP/2 uses special pseudo-headers 2399 beginning with ':' character (ASCII 0x3a) for this purpose. 2401 Just as in HTTP/1.x, header field names are strings of ASCII 2402 characters that are compared in a case-insensitive fashion. However, 2403 header field names MUST be converted to lowercase prior to their 2404 encoding in HTTP/2. A request or response containing uppercase 2405 header field names MUST be treated as malformed (Section 8.1.2.5). 2407 HTTP/2 does not use the Connection header field to indicate "hop-by- 2408 hop" header fields; in this protocol, connection-specific metadata is 2409 conveyed by other means. As such, a HTTP/2 message containing 2410 Connection MUST be treated as malformed (Section 8.1.2.5). 2412 This means that an intermediary transforming an HTTP/1.x message to 2413 HTTP/2 will need to remove any header fields nominated by the 2414 Connection header field, along with the Connection header field 2415 itself. Such intermediaries SHOULD also remove other connection- 2416 specific header fields, such as Keep-Alive, Proxy-Connection, 2417 Transfer-Encoding and Upgrade, even if they are not nominated by 2418 Connection. 2420 One exception to this is the TE header field, which MAY be present in 2421 an HTTP/2 request, but when it is MUST NOT contain any value other 2422 than "trailers". 2424 Note: HTTP/2 purposefully does not support upgrade to another 2425 protocol. The handshake methods described in Section 3 are 2426 believed sufficient to negotiate the use of alternative protocols. 2428 8.1.2.1. Request Header Fields 2430 HTTP/2 defines a number of pseudo header fields starting with a colon 2431 ':' character that carry information about the request target: 2433 o The ":method" header field includes the HTTP method ([RFC7231], 2434 Section 4). 2436 o The ":scheme" header field includes the scheme portion of the 2437 target URI ([RFC3986], Section 3.1). 2439 ":scheme" is not restricted to "http" and "https" schemed URIs. A 2440 proxy or gateway can translate requests for non-HTTP schemes, 2441 enabling the use of HTTP to interact with non-HTTP services. 2443 o The ":authority" header field includes the authority portion of 2444 the target URI ([RFC3986], Section 3.2). The authority MUST NOT 2445 include the deprecated "userinfo" subcomponent for "http" or 2446 "https" schemed URIs. 2448 To ensure that the HTTP/1.1 request line can be reproduced 2449 accurately, this header field MUST be omitted when translating 2450 from an HTTP/1.1 request that has a request target in origin or 2451 asterisk form (see [RFC7230], Section 5.3). Clients that generate 2452 HTTP/2 requests directly SHOULD instead omit the "Host" header 2453 field. An intermediary that converts an HTTP/2 request to 2454 HTTP/1.1 MUST create a "Host" header field if one is not present 2455 in a request by copying the value of the ":authority" header 2456 field. 2458 o The ":path" header field includes the path and query parts of the 2459 target URI (the "path-absolute" production from [RFC3986] and 2460 optionally a '?' character followed by the "query" production, see 2461 [RFC3986], Section 3.3 and [RFC3986], Section 3.4). This field 2462 MUST NOT be empty; URIs that do not contain a path component MUST 2463 include a value of '/', unless the request is an OPTIONS request 2464 in asterisk form, in which case the ":path" header field MUST 2465 include '*'. 2467 All HTTP/2 requests MUST include exactly one valid value for the 2468 ":method", ":scheme", and ":path" header fields, unless this is a 2469 CONNECT request (Section 8.3). An HTTP request that omits mandatory 2470 header fields is malformed (Section 8.1.2.5). 2472 Header field names that start with a colon are only valid in the 2473 HTTP/2 context. These are not HTTP header fields. Implementations 2474 MUST NOT generate header fields that start with a colon, and they 2475 MUST ignore and discard any header field that starts with a colon. 2476 In particular, header fields with names starting with a colon MUST 2477 NOT be exposed as HTTP header fields. 2479 HTTP/2 does not define a way to carry the version identifier that is 2480 included in the HTTP/1.1 request line. 2482 8.1.2.2. Response Header Fields 2484 A single ":status" header field is defined that carries the HTTP 2485 status code field (see [RFC7231], Section 6). This header field MUST 2486 be included in all responses, otherwise the response is malformed 2487 (Section 8.1.2.5). 2489 HTTP/2 does not define a way to carry the version or reason phrase 2490 that is included in an HTTP/1.1 status line. 2492 8.1.2.3. Header Field Ordering 2494 HTTP Header Compression [COMPRESSION] does not preserve the order of 2495 header fields, because the relative order of header fields with 2496 different names is not important. However, the same header field can 2497 be repeated to form a list (see [RFC7230], Section 3.2.2), where the 2498 relative order of header field values is significant. This 2499 repetition can occur either as a single header field with a comma- 2500 separated list of values, or as several header fields with a single 2501 value, or any combination thereof. Therefore, in the latter case, 2502 ordering needs to be preserved before compression takes place. 2504 To preserve the order of multiple occurrences of a header field with 2505 the same name, its ordered values are concatenated into a single 2506 value using a zero-valued octet (0x0) to delimit them. 2508 After decompression, header fields that have values containing zero 2509 octets (0x0) MUST be split into multiple header fields before being 2510 processed. 2512 For example, the following HTTP/1.x header block: 2514 Content-Type: text/html 2515 Cache-Control: max-age=60, private 2516 Cache-Control: must-revalidate 2518 contains three Cache-Control directives; two directives in the first 2519 Cache-Control header field, and the third directive in the second 2520 Cache-Control field. Before compression, they would need to be 2521 converted to a form similar to this (with 0x0 represented as '\0'): 2523 cache-control = max-age=60, private\0must-revalidate 2524 content-type = text/html 2526 Note here that the ordering between Content-Type and Cache-Control is 2527 not preserved, but the relative ordering of the Cache-Control 2528 directives - as well as the fact that the first two were comma- 2529 separated, while the last was on a different line - is. 2531 Header fields containing multiple values MUST be concatenated into a 2532 single value unless the ordering of that header field is known to be 2533 not significant. 2535 The special case of "set-cookie" - which does not form a comma- 2536 separated list, but can have multiple values - does not depend on 2537 ordering. The "set-cookie" header field MAY be encoded as multiple 2538 header field values, or as a single concatenated value. 2540 8.1.2.4. Compressing the Cookie Header Field 2542 The Cookie header field [COOKIE] can carry a significant amount of 2543 redundant data. 2545 The Cookie header field uses a semi-colon (";") to delimit cookie- 2546 pairs (or "crumbs"). This header field doesn't follow the list 2547 construction rules in HTTP (see [RFC7230], Section 3.2.2), which 2548 prevents cookie-pairs from being separated into different name-value 2549 pairs. This can significantly reduce compression efficiency as 2550 individual cookie-pairs are updated. 2552 To allow for better compression efficiency, the Cookie header field 2553 MAY be split into separate header fields, each with one or more 2554 cookie-pairs. If there are multiple Cookie header fields after 2555 decompression, these MUST be concatenated into a single octet string 2556 using the two octet delimiter of 0x3B, 0x20 (the ASCII string "; "). 2558 The Cookie header field MAY be split using a zero octet (0x0), as 2559 defined in Section 8.1.2.3. When decoding, zero octets MUST be 2560 replaced with the cookie delimiter ("; "). 2562 Therefore, the following sets of Cookie header fields are 2563 semantically equivalent, though the final form might appear in a 2564 different order after compression and decompression. 2566 cookie: a=b; c=d; e=f 2568 cookie: a=b\0c=d; e=f 2570 cookie: a=b 2571 cookie: c=d 2572 cookie: e=f 2574 8.1.2.5. Malformed Messages 2576 A malformed request or response is one that uses a valid sequence of 2577 HTTP/2 frames, but is otherwise invalid due to the presence of 2578 prohibited header fields, the absence of mandatory header fields, or 2579 the inclusion of uppercase header field names. 2581 A request or response that includes an entity body can include a 2582 "content-length" header field. A request or response is also 2583 malformed if the value of a "content-length" header field does not 2584 equal the sum of the DATA frame payload lengths that form the body. 2586 Intermediaries that process HTTP requests or responses (i.e., any 2587 intermediary not acting as a tunnel) MUST NOT forward a malformed 2588 request or response. 2590 Implementations that detect malformed requests or responses need to 2591 ensure that the stream ends. For malformed requests, a server MAY 2592 send an HTTP response prior to closing or resetting the stream. 2593 Clients MUST NOT accept a malformed response. Note that these 2594 requirements are intended to protect against several types of common 2595 attacks against HTTP; they are deliberately strict, because being 2596 permissive can expose implementations to these vulnerabilities. 2598 8.1.3. Examples 2600 This section shows HTTP/1.1 requests and responses, with 2601 illustrations of equivalent HTTP/2 requests and responses. 2603 An HTTP GET request includes request header fields and no body and is 2604 therefore transmitted as a single HEADERS frame, followed by zero or 2605 more CONTINUATION frames containing the serialized block of request 2606 header fields. The HEADERS frame in the following has both the 2607 END_HEADERS and END_STREAM flags set; no CONTINUATION frames are 2608 sent: 2610 GET /resource HTTP/1.1 HEADERS 2611 Host: example.org ==> + END_STREAM 2612 Accept: image/jpeg + END_HEADERS 2613 :method = GET 2614 :scheme = https 2615 :path = /resource 2616 host = example.org 2617 accept = image/jpeg 2619 Similarly, a response that includes only response header fields is 2620 transmitted as a HEADERS frame (again, followed by zero or more 2621 CONTINUATION frames) containing the serialized block of response 2622 header fields. 2624 HTTP/1.1 304 Not Modified HEADERS 2625 ETag: "xyzzy" ==> + END_STREAM 2626 Expires: Thu, 23 Jan ... + END_HEADERS 2627 :status = 304 2628 etag = "xyzzy" 2629 expires = Thu, 23 Jan ... 2631 An HTTP POST request that includes request header fields and payload 2632 data is transmitted as one HEADERS frame, followed by zero or more 2633 CONTINUATION frames containing the request header fields, followed by 2634 one or more DATA frames, with the last CONTINUATION (or HEADERS) 2635 frame having the END_HEADERS flag set and the final DATA frame having 2636 the END_STREAM flag set: 2638 POST /resource HTTP/1.1 HEADERS 2639 Host: example.org ==> - END_STREAM 2640 Content-Type: image/jpeg - END_HEADERS 2641 Content-Length: 123 :method = POST 2642 :path = /resource 2643 {binary data} content-type = image/jpeg 2645 CONTINUATION 2646 + END_HEADERS 2647 host = example.org 2648 :scheme = https 2649 content-length = 123 2651 DATA 2652 + END_STREAM 2653 {binary data} 2655 Note that data contributing to any given header field could be spread 2656 between header block fragments. The allocation of header fields to 2657 frames in this example is illustrative only. 2659 A response that includes header fields and payload data is 2660 transmitted as a HEADERS frame, followed by zero or more CONTINUATION 2661 frames, followed by one or more DATA frames, with the last DATA frame 2662 in the sequence having the END_STREAM flag set: 2664 HTTP/1.1 200 OK HEADERS 2665 Content-Type: image/jpeg ==> - END_STREAM 2666 Content-Length: 123 + END_HEADERS 2667 :status = 200 2668 {binary data} content-type = image/jpeg 2669 content-length = 123 2671 DATA 2672 + END_STREAM 2673 {binary data} 2675 Trailing header fields are sent as a header block after both the 2676 request or response header block and all the DATA frames have been 2677 sent. The HEADERS frame starting the trailers header block has the 2678 END_STREAM flag set. 2680 HTTP/1.1 200 OK HEADERS 2681 Content-Type: image/jpeg ==> - END_STREAM 2682 Transfer-Encoding: chunked + END_HEADERS 2683 Trailer: Foo :status = 200 2684 content-length = 123 2685 123 content-type = image/jpeg 2686 {binary data} trailer = Foo 2687 0 2688 Foo: bar DATA 2689 - END_STREAM 2690 {binary data} 2692 HEADERS 2693 + END_STREAM 2694 + END_HEADERS 2695 foo = bar 2697 8.1.4. Request Reliability Mechanisms in HTTP/2 2699 In HTTP/1.1, an HTTP client is unable to retry a non-idempotent 2700 request when an error occurs, because there is no means to determine 2701 the nature of the error. It is possible that some server processing 2702 occurred prior to the error, which could result in undesirable 2703 effects if the request were reattempted. 2705 HTTP/2 provides two mechanisms for providing a guarantee to a client 2706 that a request has not been processed: 2708 o The GOAWAY frame indicates the highest stream number that might 2709 have been processed. Requests on streams with higher numbers are 2710 therefore guaranteed to be safe to retry. 2712 o The REFUSED_STREAM error code can be included in a RST_STREAM 2713 frame to indicate that the stream is being closed prior to any 2714 processing having occurred. Any request that was sent on the 2715 reset stream can be safely retried. 2717 Requests that have not been processed have not failed; clients MAY 2718 automatically retry them, even those with non-idempotent methods. 2720 A server MUST NOT indicate that a stream has not been processed 2721 unless it can guarantee that fact. If frames that are on a stream 2722 are passed to the application layer for any stream, then 2723 REFUSED_STREAM MUST NOT be used for that stream, and a GOAWAY frame 2724 MUST include a stream identifier that is greater than or equal to the 2725 given stream identifier. 2727 In addition to these mechanisms, the PING frame provides a way for a 2728 client to easily test a connection. Connections that remain idle can 2729 become broken as some middleboxes (for instance, network address 2730 translators, or load balancers) silently discard connection bindings. 2731 The PING frame allows a client to safely test whether a connection is 2732 still active without sending a request. 2734 8.2. Server Push 2736 HTTP/2 enables a server to pre-emptively send (or "push") one or more 2737 associated responses to a client in response to a single request. 2738 This feature becomes particularly helpful when the server knows the 2739 client will need to have those responses available in order to fully 2740 process the response to the original request. 2742 Pushing additional responses is optional, and is negotiated between 2743 individual endpoints. The SETTINGS_ENABLE_PUSH setting can be set to 2744 0 to indicate that server push is disabled. 2746 Because pushing responses is effectively hop-by-hop, an intermediary 2747 could receive pushed responses from the server and choose not to 2748 forward those on to the client. In other words, how to make use of 2749 the pushed responses is up to that intermediary. Equally, the 2750 intermediary might choose to push additional responses to the client, 2751 without any action taken by the server. 2753 A client cannot push. Thus, servers MUST treat the receipt of a 2754 PUSH_PROMISE frame as a connection error (Section 5.4.1) of type 2755 PROTOCOL_ERROR. Clients MUST reject any attempt to change the 2756 SETTINGS_ENABLE_PUSH setting to a value other than 0 by treating the 2757 message as a connection error (Section 5.4.1) of type PROTOCOL_ERROR. 2759 A server can only push responses that are cacheable (see [RFC7234], 2760 Section 3); promised requests MUST be safe (see [RFC7231], 2761 Section 4.2.1) and MUST NOT include a request body. 2763 8.2.1. Push Requests 2765 Server push is semantically equivalent to a server responding to a 2766 request; however, in this case that request is also sent by the 2767 server, as a PUSH_PROMISE frame. 2769 The PUSH_PROMISE frame includes a header block that contains a 2770 complete set of request header fields that the server attributes to 2771 the request. It is not possible to push a response to a request that 2772 includes a request body. 2774 Pushed responses are always associated with an explicit request from 2775 the client. The PUSH_PROMISE frames sent by the server are sent on 2776 that explicit request's stream. The PUSH_PROMISE frame also includes 2777 a promised stream identifier, chosen from the stream identifiers 2778 available to the server (see Section 5.1.1). 2780 The header fields in PUSH_PROMISE and any subsequent CONTINUATION 2781 frames MUST be a valid and complete set of request header fields 2782 (Section 8.1.2.1). The server MUST include a method in the ":method" 2783 header field that is safe and cacheable. If a client receives a 2784 PUSH_PROMISE that does not include a complete and valid set of header 2785 fields, or the ":method" header field identifies a method that is not 2786 safe, it MUST respond with a stream error (Section 5.4.2) of type 2787 PROTOCOL_ERROR. 2789 The server SHOULD send PUSH_PROMISE (Section 6.6) frames prior to 2790 sending any frames that reference the promised responses. This 2791 avoids a race where clients issue requests prior to receiving any 2792 PUSH_PROMISE frames. 2794 For example, if the server receives a request for a document 2795 containing embedded links to multiple image files, and the server 2796 chooses to push those additional images to the client, sending push 2797 promises before the DATA frames that contain the image links ensures 2798 that the client is able to see the promises before discovering 2799 embedded links. Similarly, if the server pushes responses referenced 2800 by the header block (for instance, in Link header fields), sending 2801 the push promises before sending the header block ensures that 2802 clients do not request them. 2804 PUSH_PROMISE frames MUST NOT be sent by the client. PUSH_PROMISE 2805 frames can be sent by the server on any stream that was opened by the 2806 client. They MUST be sent on a stream that is in either the "open" 2807 or "half closed (remote)" state to the server. PUSH_PROMISE frames 2808 are interspersed with the frames that comprise a response, though 2809 they cannot be interspersed with HEADERS and CONTINUATION frames that 2810 comprise a single header block. 2812 8.2.2. Push Responses 2814 After sending the PUSH_PROMISE frame, the server can begin delivering 2815 the pushed response as a response (Section 8.1.2.2) on a server- 2816 initiated stream that uses the promised stream identifier. The 2817 server uses this stream to transmit an HTTP response, using the same 2818 sequence of frames as defined in Section 8.1. This stream becomes 2819 "half closed" to the client (Section 5.1) after the initial HEADERS 2820 frame is sent. 2822 Once a client receives a PUSH_PROMISE frame and chooses to accept the 2823 pushed response, the client SHOULD NOT issue any requests for the 2824 promised response until after the promised stream has closed. 2826 If the client determines, for any reason, that it does not wish to 2827 receive the pushed response from the server, or if the server takes 2828 too long to begin sending the promised response, the client can send 2829 an RST_STREAM frame, using either the CANCEL or REFUSED_STREAM codes, 2830 and referencing the pushed stream's identifier. 2832 A client can use the SETTINGS_MAX_CONCURRENT_STREAMS setting to limit 2833 the number of responses that can be concurrently pushed by a server. 2834 Advertising a SETTINGS_MAX_CONCURRENT_STREAMS value of zero disables 2835 server push by preventing the server from creating the necessary 2836 streams. This does not prohibit a server from sending PUSH_PROMISE 2837 frames; clients need to reset any promised streams that are not 2838 wanted. 2840 Clients receiving a pushed response MUST validate that the server is 2841 authorized to provide the response, see Section 10.1. For example, a 2842 server that offers a certificate for only the "example.com" DNS-ID or 2843 Common Name is not permitted to push a response for 2844 "https://www.example.org/doc". 2846 8.3. The CONNECT Method 2848 In HTTP/1.x, the pseudo-method CONNECT ([RFC7231], Section 4.3.6) is 2849 used to convert an HTTP connection into a tunnel to a remote host. 2850 CONNECT is primarily used with HTTP proxies to establish a TLS 2851 session with an origin server for the purposes of interacting with 2852 "https" resources. 2854 In HTTP/2, the CONNECT method is used to establish a tunnel over a 2855 single HTTP/2 stream to a remote host, for similar purposes. The 2856 HTTP header field mapping works as mostly as defined in Request 2857 Header Fields (Section 8.1.2.1), with a few differences. 2858 Specifically: 2860 o The ":method" header field is set to "CONNECT". 2862 o The ":scheme" and ":path" header fields MUST be omitted. 2864 o The ":authority" header field contains the host and port to 2865 connect to (equivalent to the authority-form of the request-target 2866 of CONNECT requests, see [RFC7230], Section 5.3). 2868 A proxy that supports CONNECT establishes a TCP connection [TCP] to 2869 the server identified in the ":authority" header field. Once this 2870 connection is successfully established, the proxy sends a HEADERS 2871 frame containing a 2xx series status code to the client, as defined 2872 in [RFC7231], Section 4.3.6. 2874 After the initial HEADERS frame sent by each peer, all subsequent 2875 DATA frames correspond to data sent on the TCP connection. The 2876 payload of any DATA frames sent by the client are transmitted by the 2877 proxy to the TCP server; data received from the TCP server is 2878 assembled into DATA frames by the proxy. Frame types other than DATA 2879 or stream management frames (RST_STREAM, WINDOW_UPDATE, and PRIORITY) 2880 MUST NOT be sent on a connected stream, and MUST be treated as a 2881 stream error (Section 5.4.2) if received. 2883 The TCP connection can be closed by either peer. The END_STREAM flag 2884 on a DATA frame is treated as being equivalent to the TCP FIN bit. A 2885 client is expected to send a DATA frame with the END_STREAM flag set 2886 after receiving a frame bearing the END_STREAM flag. A proxy that 2887 receives a DATA frame with the END_STREAM flag set sends the attached 2888 data with the FIN bit set on the last TCP segment. A proxy that 2889 receives a TCP segment with the FIN bit set sends a DATA frame with 2890 the END_STREAM flag set. Note that the final TCP segment or DATA 2891 frame could be empty. 2893 A TCP connection error is signaled with RST_STREAM. A proxy treats 2894 any error in the TCP connection, which includes receiving a TCP 2895 segment with the RST bit set, as a stream error (Section 5.4.2) of 2896 type CONNECT_ERROR. Correspondingly, a proxy MUST send a TCP segment 2897 with the RST bit set if it detects an error with the stream or the 2898 HTTP/2 connection. 2900 9. Additional HTTP Requirements/Considerations 2902 This section outlines attributes of the HTTP protocol that improve 2903 interoperability, reduce exposure to known security vulnerabilities, 2904 or reduce the potential for implementation variation. 2906 9.1. Connection Management 2908 HTTP/2 connections are persistent. For best performance, it is 2909 expected clients will not close connections until it is determined 2910 that no further communication with a server is necessary (for 2911 example, when a user navigates away from a particular web page), or 2912 until the server closes the connection. 2914 Clients SHOULD NOT open more than one HTTP/2 connection to a given 2915 host and port pair, where host is derived from a URI, a selected 2916 alternative service [ALT-SVC], or a configured proxy. 2918 A client can create additional connections as replacements, either to 2919 replace connections that are near to exhausting the available stream 2920 identifier space (Section 5.1.1), to refresh the keying material for 2921 a TLS connection, or to replace connections that have encountered 2922 errors (Section 5.4.1). 2924 A client MAY open multiple connections to the same IP address and TCP 2925 port using different Server Name Indication [TLS-EXT] values or to 2926 provide different TLS client certificates, but SHOULD avoid creating 2927 multiple connections with the same configuration. 2929 Servers are encouraged to maintain open connections for as long as 2930 possible, but are permitted to terminate idle connections if 2931 necessary. When either endpoint chooses to close the transport-level 2932 TCP connection, the terminating endpoint SHOULD first send a GOAWAY 2933 (Section 6.8) frame so that both endpoints can reliably determine 2934 whether previously sent frames have been processed and gracefully 2935 complete or terminate any necessary remaining tasks. 2937 9.1.1. Connection Reuse 2939 Clients MAY use a single server connection to send requests for URIs 2940 with multiple different authority components as long as the server is 2941 authoritative (Section 10.1). For "http" resources, this depends on 2942 the host having resolved to the same IP address. 2944 For "https" resources, connection reuse additionally depends on 2945 having a certificate that is valid for the host in the URI. That is 2946 the use of server certificate with multiple "subjectAltName" 2947 attributes, or names with wildcards. For example, a certificate with 2948 a "subjectAltName" of "*.example.com" might permit the use of the 2949 same connection for "a.example.com" and "b.example.com". 2951 In some deployments, reusing a connection for multiple origins can 2952 result in requests being directed to the wrong origin server. For 2953 example, TLS termination might be performed by a middlebox that uses 2954 the TLS Server Name Indication (SNI) [TLS-EXT] extension to select 2955 the an origin server. This means that it is possible for clients to 2956 send confidential information to servers that might not be the 2957 intended target for the request, even though the server has valid 2958 authentication credentials. 2960 A server that does not wish clients to reuse connections can indicate 2961 that it is not authoritative for a request by sending a 421 (Not 2962 Authoritative) status code in response to request (see 2963 Section 9.1.2). 2965 9.1.2. The 421 (Not Authoritative) Status Code 2967 The 421 (Not Authoritative) status code indicates that the current 2968 origin server is not authoritative for the requested resource, in the 2969 sense of [RFC7230], Section 9.1 (see also Section 10.1). 2971 Clients receiving a 421 (Not Authoritative) response from a server 2972 MAY retry the request - whether the request method is idempotent or 2973 not - over a different connection. This is possible if a connection 2974 is reused (Section 9.1.1) or if an alternative service is selected 2975 ([ALT-SVC]). 2977 This status code MUST NOT be generated by proxies. 2979 A 421 response is cacheable by default; i.e., unless otherwise 2980 indicated by the method definition or explicit cache controls (see 2981 Section 4.2.2 of [RFC7234]). 2983 9.2. Use of TLS Features 2985 Implementations of HTTP/2 MUST support TLS 1.2 [TLS12] for HTTP/2 2986 over TLS. The general TLS usage guidance in [TLSBCP] SHOULD be 2987 followed, with some additional restrictions that are specific to 2988 HTTP/2. 2990 9.2.1. TLS Features 2992 The TLS implementation MUST support the Server Name Indication (SNI) 2993 [TLS-EXT] extension to TLS. HTTP/2 clients MUST indicate the target 2994 domain name when negotiating TLS. 2996 The TLS implementation MUST disable compression. TLS compression can 2997 lead to the exposure of information that would not otherwise be 2998 revealed [RFC3749]. Generic compression is unnecessary since HTTP/2 2999 provides compression features that are more aware of context and 3000 therefore likely to be more appropriate for use for performance, 3001 security or other reasons. 3003 The TLS implementation MUST disable renegotiation. An endpoint MUST 3004 treat a TLS renegotiation as a connection error (Section 5.4.1) of 3005 type PROTOCOL_ERROR. Note that disabling renegotiation can result in 3006 long-lived connections becoming unusable due to limits on the number 3007 of messages the underlying cipher suite can encipher. 3009 A client MAY use renegotiation to provide confidentiality protection 3010 for client credentials offered in the handshake, but any 3011 renegotiation MUST occur prior to sending the connection preface. A 3012 server SHOULD request a client certificate if it sees a renegotiation 3013 request immediately after establishing a connection. 3015 This effectively prevents the use of renegotiation in response to a 3016 request for a specific protected resource. A future specification 3017 might provide a way to support this use case. 3019 9.2.2. TLS Cipher Suites 3021 The set of TLS cipher suites that are permitted in HTTP/2 is 3022 restricted. HTTP/2 MUST only be used with cipher suites that have 3023 ephemeral key exchange, such as the ephemeral Diffie-Hellman (DHE) 3024 [TLS12] or the elliptic curve variant (ECDHE) [RFC4492]. Ephemeral 3025 key exchange MUST have a minimum size of 2048 bits for DHE or 3026 security level of 128 bits for ECDHE. Clients MUST accept DHE sizes 3027 of up to 4096 bits. HTTP MUST NOT be used with cipher suites that 3028 use stream or block ciphers. Authenticated Encryption with 3029 Additional Data (AEAD) modes, such as the Galois Counter Model (GCM) 3030 mode for AES [RFC5288] are acceptable. 3032 Clients MAY advertise support of other cipher suites in order to 3033 allow for connection to servers that do not support HTTP/2 to 3034 complete without the additional latency imposed by using a separate 3035 connection for fallback. 3037 An implementation SHOULD NOT negotiate a TLS connection for HTTP/2 3038 without also negotiating a cipher suite that meets these 3039 requirements. Due to implementation limitations, it might not be 3040 possible to fail TLS negotiation. An endpoint MUST immediately 3041 terminate an HTTP/2 connection that does not meet these minimum 3042 requirements with a connection error (Section 5.4.1) of type 3043 INADEQUATE_SECURITY. 3045 10. Security Considerations 3047 10.1. Server Authority 3049 A client is only able to accept HTTP/2 responses from servers that 3050 are authoritative for those resources. This is particularly 3051 important for server push (Section 8.2), where the client validates 3052 the PUSH_PROMISE before accepting the response. 3054 HTTP/2 relies on the HTTP/1.1 definition of authority for determining 3055 whether a server is authoritative in providing a given response, see 3056 [RFC7230], Section 9.1. This relies on local name resolution for the 3057 "http" URI scheme, and the authenticated server identity for the 3058 "https" scheme (see [RFC2818], Section 3). 3060 A client MUST discard responses provided by a server that is not 3061 authoritative for those resources. 3063 10.2. Cross-Protocol Attacks 3065 In a cross-protocol attack, an attacker causes a client to initiate a 3066 transaction in one protocol toward a server that understands a 3067 different protocol. An attacker might be able to cause the 3068 transaction to appear as valid transaction in the second protocol. 3069 In combination with the capabilities of the web context, this can be 3070 used to interact with poorly protected servers in private networks. 3072 Completing a TLS handshake with an ALPN identifier for HTTP/2 can be 3073 considered sufficient protection against cross protocol attacks. 3074 ALPN provides a positive indication that a server is willing to 3075 proceed with HTTP/2, which prevents attacks on other TLS-based 3076 protocols. 3078 The encryption in TLS makes it difficult for attackers to control the 3079 data which could be used in a cross-protocol attack on a cleartext 3080 protocol. 3082 The cleartext version of HTTP/2 has minimal protection against cross- 3083 protocol attacks. The connection preface (Section 3.5) contains a 3084 string that is designed to confuse HTTP/1.1 servers, but no special 3085 protection is offered for other protocols. A server that is willing 3086 to ignore parts of an HTTP/1.1 request containing an Upgrade header 3087 field in addition to the client connection preface could be exposed 3088 to a cross-protocol attack. 3090 10.3. Intermediary Encapsulation Attacks 3092 HTTP/2 header field names and values are encoded as sequences of 3093 octets with a length prefix. This enables HTTP/2 to carry any string 3094 of octets as the name or value of a header field. An intermediary 3095 that translates HTTP/2 requests or responses into HTTP/1.1 directly 3096 could permit the creation of corrupted HTTP/1.1 messages. An 3097 attacker might exploit this behavior to cause the intermediary to 3098 create HTTP/1.1 messages with illegal header fields, extra header 3099 fields, or even new messages that are entirely falsified. 3101 Header field names or values that contain characters not permitted by 3102 HTTP/1.1, including carriage return (ASCII 0xd) or line feed (ASCII 3103 0xa) MUST NOT be translated verbatim by an intermediary, as 3104 stipulated in [RFC7230], Section 3.2.4. 3106 Translation from HTTP/1.x to HTTP/2 does not produce the same 3107 opportunity to an attacker. Intermediaries that perform translation 3108 to HTTP/2 MUST remove any instances of the "obs-fold" production from 3109 header field values. 3111 10.4. Cacheability of Pushed Responses 3113 Pushed responses do not have an explicit request from the client; the 3114 request is provided by the server in the PUSH_PROMISE frame. 3116 Caching responses that are pushed is possible based on the guidance 3117 provided by the origin server in the Cache-Control header field. 3118 However, this can cause issues if a single server hosts more than one 3119 tenant. For example, a server might offer multiple users each a 3120 small portion of its URI space. 3122 Where multiple tenants share space on the same server, that server 3123 MUST ensure that tenants are not able to push representations of 3124 resources that they do not have authority over. Failure to enforce 3125 this would allow a tenant to provide a representation that would be 3126 served out of cache, overriding the actual representation that the 3127 authoritative tenant provides. 3129 Pushed responses for which an origin server is not authoritative (see 3130 Section 10.1) are never cached or used. 3132 10.5. Denial of Service Considerations 3134 An HTTP/2 connection can demand a greater commitment of resources to 3135 operate than a HTTP/1.1 connection. The use of header compression 3136 and flow control depend on a commitment of resources for storing a 3137 greater amount of state. Settings for these features ensure that 3138 memory commitments for these features are strictly bounded. 3140 The number of PUSH_PROMISE frames is not constrained in the same 3141 fashion. A client that accepts server push SHOULD limit the number 3142 of streams it allows to be in the "reserved (remote)" state. 3143 Excessive number of server push streams can be treated as a stream 3144 error (Section 5.4.2) of type ENHANCE_YOUR_CALM. 3146 Processing capacity cannot be guarded as effectively as state 3147 capacity. 3149 The SETTINGS frame can be abused to cause a peer to expend additional 3150 processing time. This might be done by pointlessly changing SETTINGS 3151 parameters, setting multiple undefined parameters, or changing the 3152 same setting multiple times in the same frame. WINDOW_UPDATE or 3153 PRIORITY frames can be abused to cause an unnecessary waste of 3154 resources. 3156 Large numbers of small or empty frames can be abused to cause a peer 3157 to expend time processing frame headers. Note however that some uses 3158 are entirely legitimate, such as the sending of an empty DATA frame 3159 to end a stream. 3161 Header compression also offers some opportunities to waste processing 3162 resources; see Section 8 of [COMPRESSION] for more details on 3163 potential abuses. 3165 Limits in SETTINGS parameters cannot be reduced instantaneously, 3166 which leaves an endpoint exposed to behavior from a peer that could 3167 exceed the new limits. In particular, immediately after establishing 3168 a connection, limits set by a server are not known to clients and 3169 could be exceeded without being an obvious protocol violation. 3171 All these features - i.e., SETTINGS changes, small frames, header 3172 compression - have legitimate uses. These features become a burden 3173 only when they are used unnecessarily or to excess. 3175 An endpoint that doesn't monitor this behavior exposes itself to a 3176 risk of denial of service attack. Implementations SHOULD track the 3177 use of these features and set limits on their use. An endpoint MAY 3178 treat activity that is suspicious as a connection error 3179 (Section 5.4.1) of type ENHANCE_YOUR_CALM. 3181 10.5.1. Limits on Header Block Size 3183 A large header block (Section 4.3) can cause an implementation to 3184 commit a large amount of state. In servers and intermediaries, 3185 header fields that are critical to routing, such as ":authority", 3186 ":path", and ":scheme" are not guaranteed to be present early in the 3187 header block. In particular, values that are in the reference set 3188 cannot be emitted until the header block ends. 3190 This can prevent streaming of the header fields to their ultimate 3191 destination, and forces the endpoint to buffer the entire header 3192 block. Since there is no hard limit to the size of a header block, 3193 an endpoint could be forced to exhaust available memory. 3195 A server that receives a larger header block than it is willing to 3196 handle can send an HTTP 431 (Request Header Fields Too Large) status 3197 code [RFC6585]. A client can discard responses that it cannot 3198 process. The header block MUST be processed to ensure a consistent 3199 connection state, unless the connection is closed. 3201 10.6. Use of Compression 3203 HTTP/2 enables greater use of compression for both header fields 3204 (Section 4.3) and entity bodies. Compression can allow an attacker 3205 to recover secret data when it is compressed in the same context as 3206 data under attacker control. 3208 There are demonstrable attacks on compression that exploit the 3209 characteristics of the web (e.g., [BREACH]). The attacker induces 3210 multiple requests containing varying plaintext, observing the length 3211 of the resulting ciphertext in each, which reveals a shorter length 3212 when a guess about the secret is correct. 3214 Implementations communicating on a secure channel MUST NOT compress 3215 content that includes both confidential and attacker-controlled data 3216 unless separate compression dictionaries are used for each source of 3217 data. Compression MUST NOT be used if the source of data cannot be 3218 reliably determined. 3220 Further considerations regarding the compression of header fields are 3221 described in [COMPRESSION]. 3223 10.7. Use of Padding 3225 Padding within HTTP/2 is not intended as a replacement for general 3226 purpose padding, such as might be provided by TLS [TLS12]. Redundant 3227 padding could even be counterproductive. Correct application can 3228 depend on having specific knowledge of the data that is being padded. 3230 To mitigate attacks that rely on compression, disabling or limiting 3231 compression might be preferable to padding as a countermeasure. 3233 Padding can be used to obscure the exact size of frame content, and 3234 is provided to mitigate specific attacks within HTTP. For example, 3235 attacks where compressed content includes both attacker-controlled 3236 plaintext and secret data (see for example, [BREACH]). 3238 Use of padding can result in less protection than might seem 3239 immediately obvious. At best, padding only makes it more difficult 3240 for an attacker to infer length information by increasing the number 3241 of frames an attacker has to observe. Incorrectly implemented 3242 padding schemes can be easily defeated. In particular, randomized 3243 padding with a predictable distribution provides very little 3244 protection; similarly, padding payloads to a fixed size exposes 3245 information as payload sizes cross the fixed size boundary, which 3246 could be possible if an attacker can control plaintext. 3248 Intermediaries SHOULD retain padding for DATA frames, but MAY drop 3249 padding for HEADERS and PUSH_PROMISE frames. A valid reason for an 3250 intermediary to change the amount of padding of frames is to improve 3251 the protections that padding provides. 3253 10.8. Privacy Considerations 3255 Several characteristics of HTTP/2 provide an observer an opportunity 3256 to correlate actions of a single client or server over time. This 3257 includes the value of settings, the manner in which flow control 3258 windows are managed, the way priorities are allocated to streams, 3259 timing of reactions to stimulus, and handling of any optional 3260 features. 3262 As far as this creates observable differences in behavior, they could 3263 be used as a basis for fingerprinting a specific client, as defined 3264 in Section 1.8 of [HTML5]. 3266 11. IANA Considerations 3268 A string for identifying HTTP/2 is entered into the "Application 3269 Layer Protocol Negotiation (ALPN) Protocol IDs" registry established 3270 in [TLSALPN]. 3272 This document establishes a registry for frame types, settings, and 3273 error codes. These new registries are entered into a new "Hypertext 3274 Transfer Protocol (HTTP) 2 Parameters" section. 3276 This document registers the "HTTP2-Settings" header field for use in 3277 HTTP; and the 421 (Not Authoritative) status code. 3279 This document registers the "PRI" method for use in HTTP, to avoid 3280 collisions with the connection preface (Section 3.5). 3282 11.1. Registration of HTTP/2 Identification Strings 3284 This document creates two registrations for the identification of 3285 HTTP/2 in the "Application Layer Protocol Negotiation (ALPN) Protocol 3286 IDs" registry established in [TLSALPN]. 3288 The "h2" string identifies HTTP/2 when used over TLS: 3290 Protocol: HTTP/2 over TLS 3292 Identification Sequence: 0x68 0x32 ("h2") 3294 Specification: This document 3295 The "h2c" string identifies HTTP/2 when used over cleartext TCP: 3297 Protocol: HTTP/2 over TCP 3299 Identification Sequence: 0x68 0x32 0x63 ("h2c") 3301 Specification: This document 3303 11.2. Frame Type Registry 3305 This document establishes a registry for HTTP/2 frame types codes. 3306 The "HTTP/2 Frame Type" registry manages an 8-bit space. The "HTTP/2 3307 Frame Type" registry operates under either of the "IETF Review" or 3308 "IESG Approval" policies [RFC5226] for values between 0x00 and 0xef, 3309 with values between 0xf0 and 0xff being reserved for experimental 3310 use. 3312 New entries in this registry require the following information: 3314 Frame Type: A name or label for the frame type. 3316 Code: The 8-bit code assigned to the frame type. 3318 Specification: A reference to a specification that includes a 3319 description of the frame layout, it's semantics and flags that the 3320 frame type uses, including any parts of the frame that are 3321 conditionally present based on the value of flags. 3323 The entries in the following table are registered by this document. 3325 +---------------+------+--------------+ 3326 | Frame Type | Code | Section | 3327 +---------------+------+--------------+ 3328 | DATA | 0x0 | Section 6.1 | 3329 | HEADERS | 0x1 | Section 6.2 | 3330 | PRIORITY | 0x2 | Section 6.3 | 3331 | RST_STREAM | 0x3 | Section 6.4 | 3332 | SETTINGS | 0x4 | Section 6.5 | 3333 | PUSH_PROMISE | 0x5 | Section 6.6 | 3334 | PING | 0x6 | Section 6.7 | 3335 | GOAWAY | 0x7 | Section 6.8 | 3336 | WINDOW_UPDATE | 0x8 | Section 6.9 | 3337 | CONTINUATION | 0x9 | Section 6.10 | 3338 +---------------+------+--------------+ 3340 11.3. Settings Registry 3342 This document establishes a registry for HTTP/2 settings. The 3343 "HTTP/2 Settings" registry manages a 16-bit space. The "HTTP/2 3344 Settings" registry operates under the "Expert Review" policy 3345 [RFC5226] for values in the range from 0x0000 to 0xefff, with values 3346 between and 0xf000 and 0xffff being reserved for experimental use. 3348 New registrations are advised to provide the following information: 3350 Name: A symbolic name for the setting. Specifying a setting name is 3351 optional. 3353 Code: The 16-bit code assigned to the setting. 3355 Initial Value: An initial value for the setting. 3357 Specification: A stable reference to a specification that describes 3358 the use of the setting. 3360 An initial set of setting registrations can be found in 3361 Section 6.5.2. 3363 +------------------------+------+---------------+---------------+ 3364 | Name | Code | Initial Value | Specification | 3365 +------------------------+------+---------------+---------------+ 3366 | HEADER_TABLE_SIZE | 0x1 | 4096 | Section 6.5.2 | 3367 | ENABLE_PUSH | 0x2 | 1 | Section 6.5.2 | 3368 | MAX_CONCURRENT_STREAMS | 0x3 | (infinite) | Section 6.5.2 | 3369 | INITIAL_WINDOW_SIZE | 0x4 | 65535 | Section 6.5.2 | 3370 +------------------------+------+---------------+---------------+ 3372 11.4. Error Code Registry 3374 This document establishes a registry for HTTP/2 error codes. The 3375 "HTTP/2 Error Code" registry manages a 32-bit space. The "HTTP/2 3376 Error Code" registry operates under the "Expert Review" policy 3377 [RFC5226]. 3379 Registrations for error codes are required to include a description 3380 of the error code. An expert reviewer is advised to examine new 3381 registrations for possible duplication with existing error codes. 3382 Use of existing registrations is to be encouraged, but not mandated. 3384 New registrations are advised to provide the following information: 3386 Name: A name for the error code. Specifying an error code name is 3387 optional. 3389 Code: The 32-bit error code value. 3391 Description: A brief description of the error code semantics, longer 3392 if no detailed specification is provided. 3394 Specification: An optional reference for a specification that 3395 defines the error code. 3397 The entries in the following table are registered by this document. 3399 +---------------------+------+----------------------+---------------+ 3400 | Name | Code | Description | Specification | 3401 +---------------------+------+----------------------+---------------+ 3402 | NO_ERROR | 0x0 | Graceful shutdown | Section 7 | 3403 | PROTOCOL_ERROR | 0x1 | Protocol error | Section 7 | 3404 | | | detected | | 3405 | INTERNAL_ERROR | 0x2 | Implementation fault | Section 7 | 3406 | FLOW_CONTROL_ERROR | 0x3 | Flow control limits | Section 7 | 3407 | | | exceeded | | 3408 | SETTINGS_TIMEOUT | 0x4 | Settings not | Section 7 | 3409 | | | acknowledged | | 3410 | STREAM_CLOSED | 0x5 | Frame received for | Section 7 | 3411 | | | closed stream | | 3412 | FRAME_SIZE_ERROR | 0x6 | Frame size incorrect | Section 7 | 3413 | REFUSED_STREAM | 0x7 | Stream not processed | Section 7 | 3414 | CANCEL | 0x8 | Stream cancelled | Section 7 | 3415 | COMPRESSION_ERROR | 0x9 | Compression state | Section 7 | 3416 | | | not updated | | 3417 | CONNECT_ERROR | 0xa | TCP connection error | Section 7 | 3418 | | | for CONNECT method | | 3419 | ENHANCE_YOUR_CALM | 0xb | Processing capacity | Section 7 | 3420 | | | exceeded | | 3421 | INADEQUATE_SECURITY | 0xc | Negotiated TLS | Section 7 | 3422 | | | parameters not | | 3423 | | | acceptable | | 3424 +---------------------+------+----------------------+---------------+ 3426 11.5. HTTP2-Settings Header Field Registration 3428 This section registers the "HTTP2-Settings" header field in the 3429 Permanent Message Header Field Registry [BCP90]. 3431 Header field name: HTTP2-Settings 3433 Applicable protocol: http 3435 Status: standard 3436 Author/Change controller: IETF 3438 Specification document(s): Section 3.2.1 of this document 3440 Related information: This header field is only used by an HTTP/2 3441 client for Upgrade-based negotiation. 3443 11.6. PRI Method Registration 3445 This section registers the "PRI" method in the HTTP Method Registry 3446 ([RFC7231], Section 8.1). 3448 Method Name: PRI 3450 Safe No 3452 Idempotent No 3454 Specification document(s) Section 3.5 of this document 3456 Related information: This method is never used by an actual client. 3457 This method will appear to be used when an HTTP/1.1 server or 3458 intermediary attempts to parse an HTTP/2 connection preface. 3460 11.7. The 421 Not Authoritative HTTP Status Code 3462 This document registers the 421 (Not Authoritative) HTTP Status code 3463 in the Hypertext Transfer Protocol (HTTP) Status Code Registry 3464 ([RFC7231], Section 8.2). 3466 Status Code: 421 3468 Short Description: Not Authoritative 3470 Specification: Section 9.1.2 of this document 3472 12. Acknowledgements 3474 This document includes substantial input from the following 3475 individuals: 3477 o Adam Langley, Wan-Teh Chang, Jim Morrison, Mark Nottingham, Alyssa 3478 Wilk, Costin Manolache, William Chan, Vitaliy Lvin, Joe Chan, Adam 3479 Barth, Ryan Hamilton, Gavin Peters, Kent Alstad, Kevin Lindsay, 3480 Paul Amer, Fan Yang, Jonathan Leighton (SPDY contributors). 3482 o Gabriel Montenegro and Willy Tarreau (Upgrade mechanism). 3484 o William Chan, Salvatore Loreto, Osama Mazahir, Gabriel Montenegro, 3485 Jitu Padhye, Roberto Peon, Rob Trace (Flow control). 3487 o Mike Bishop (Extensibility). 3489 o Mark Nottingham, Julian Reschke, James Snell, Jeff Pinner, Mike 3490 Bishop, Herve Ruellan (Substantial editorial contributions). 3492 o Alexey Melnikov was an editor of this document during 2013. 3494 o A substantial proportion of Martin's contribution was supported by 3495 Microsoft during his employment there. 3497 13. References 3499 13.1. Normative References 3501 [COMPRESSION] 3502 Ruellan, H. and R. Peon, "HPACK - Header Compression for 3503 HTTP/2", draft-ietf-httpbis-header-compression-08 (work in 3504 progress), June 2014. 3506 [COOKIE] Barth, A., "HTTP State Management Mechanism", RFC 6265, 3507 April 2011. 3509 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 3510 Requirement Levels", BCP 14, RFC 2119, March 1997. 3512 [RFC2818] Rescorla, E., "HTTP Over TLS", RFC 2818, May 2000. 3514 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 3515 Resource Identifier (URI): Generic Syntax", STD 66, RFC 3516 3986, January 2005. 3518 [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data 3519 Encodings", RFC 4648, October 2006. 3521 [RFC5226] Narten, T. and H. Alvestrand, "Guidelines for Writing an 3522 IANA Considerations Section in RFCs", BCP 26, RFC 5226, 3523 May 2008. 3525 [RFC5234] Crocker, D. and P. Overell, "Augmented BNF for Syntax 3526 Specifications: ABNF", STD 68, RFC 5234, January 2008. 3528 [RFC7230] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer 3529 Protocol (HTTP/1.1): Message Syntax and Routing", RFC 3530 7230, June 2014. 3532 [RFC7231] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer 3533 Protocol (HTTP/1.1): Semantics and Content", RFC 7231, 3534 June 2014. 3536 [RFC7232] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer 3537 Protocol (HTTP/1.1): Conditional Requests", RFC 7232, June 3538 2014. 3540 [RFC7233] Fielding, R., Ed., Lafon, Y., Ed., and J. Reschke, Ed., 3541 "Hypertext Transfer Protocol (HTTP/1.1): Range Requests", 3542 RFC 7233, June 2014. 3544 [RFC7234] Fielding, R., Ed., Nottingham, M., Ed., and J. Reschke, 3545 Ed., "Hypertext Transfer Protocol (HTTP/1.1): Caching", 3546 RFC 7234, June 2014. 3548 [RFC7235] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer 3549 Protocol (HTTP/1.1): Authentication", RFC 7235, June 2014. 3551 [TCP] Postel, J., "Transmission Control Protocol", STD 7, RFC 3552 793, September 1981. 3554 [TLS-EXT] Eastlake, D., "Transport Layer Security (TLS) Extensions: 3555 Extension Definitions", RFC 6066, January 2011. 3557 [TLS12] Dierks, T. and E. Rescorla, "The Transport Layer Security 3558 (TLS) Protocol Version 1.2", RFC 5246, August 2008. 3560 [TLSALPN] Friedl, S., Popov, A., Langley, A., and E. Stephan, 3561 "Transport Layer Security (TLS) Application Layer Protocol 3562 Negotiation Extension", draft-ietf-tls-applayerprotoneg-05 3563 (work in progress), March 2014. 3565 13.2. Informative References 3567 [ALT-SVC] Nottingham, M., McManus, P., and J. Reschke, "HTTP 3568 Alternative Services", draft-ietf-httpbis-alt-svc-01 (work 3569 in progress), April 2014. 3571 [BCP90] Klyne, G., Nottingham, M., and J. Mogul, "Registration 3572 Procedures for Message Header Fields", BCP 90, RFC 3864, 3573 September 2004. 3575 [BREACH] Gluck, Y., Harris, N., and A. Prado, "BREACH: Reviving the 3576 CRIME Attack", July 2013, . 3580 [HTML5] Berjon, R., Faulkner, S., Leithead, T., Doyle Navara, E., 3581 O'Connor, E., and S. Pfeiffer, "HTML5", W3C Candidate 3582 Recommendation CR-html5-20140204, Febuary 2014, 3583 . 3585 Latest version available at [5]. 3587 [RFC1323] Jacobson, V., Braden, B., and D. Borman, "TCP Extensions 3588 for High Performance", RFC 1323, May 1992. 3590 [RFC2518] Goland, Y., Whitehead, E., Faizi, A., Carter, S., and D. 3591 Jensen, "HTTP Extensions for Distributed Authoring -- 3592 WEBDAV", RFC 2518, February 1999. 3594 [RFC3749] Hollenbeck, S., "Transport Layer Security Protocol 3595 Compression Methods", RFC 3749, May 2004. 3597 [RFC4492] Blake-Wilson, S., Bolyard, N., Gupta, V., Hawk, C., and B. 3598 Moeller, "Elliptic Curve Cryptography (ECC) Cipher Suites 3599 for Transport Layer Security (TLS)", RFC 4492, May 2006. 3601 [RFC5288] Salowey, J., Choudhury, A., and D. McGrew, "AES Galois 3602 Counter Mode (GCM) Cipher Suites for TLS", RFC 5288, 3603 August 2008. 3605 [RFC6585] Nottingham, N. and R. Fielding, "Additional HTTP Status 3606 Codes", RFC 6585, April 2012. 3608 [TALKING] Huang, L-S., Chen, E., Barth, A., Rescorla, E., and C. 3609 Jackson, "Talking to Yourself for Fun and Profit", 2011, 3610 . 3612 [TLSBCP] Sheffer, Y., Holz, R., and P. Saint-Andre, 3613 "Recommendations for Secure Use of TLS and DTLS", draft- 3614 sheffer-tls-bcp-02 (work in progress), February 2014. 3616 13.3. URIs 3618 [1] https://www.iana.org/assignments/message-headers 3620 [2] https://groups.google.com/forum/?fromgroups#!topic/spdy-dev/ 3621 cfUef2gL3iU 3623 [3] https://tools.ietf.org/html/draft-montenegro-httpbis-http2-fc- 3624 principles-01 3626 Appendix A. Change Log (to be removed by RFC Editor before publication) 3628 A.1. Since draft-ietf-httpbis-http2-12 3630 Restored extensibility options. 3632 Restricting TLS cipher suites to AEAD only. 3634 Removing Content-Encoding requirements. 3636 Permitting the use of PRIORITY after stream close. 3638 Removed ALTSVC frame. 3640 Removed BLOCKED frame. 3642 Reducing the maximum padding size to 256 octets; removing padding 3643 from CONTINUATION frames. 3645 Removed per-frame GZIP compression. 3647 A.2. Since draft-ietf-httpbis-http2-11 3649 Added BLOCKED frame (at risk). 3651 Simplified priority scheme. 3653 Added DATA per-frame GZIP compression. 3655 A.3. Since draft-ietf-httpbis-http2-10 3657 Changed "connection header" to "connection preface" to avoid 3658 confusion. 3660 Added dependency-based stream prioritization. 3662 Added "h2c" identifier to distinguish between cleartext and secured 3663 HTTP/2. 3665 Adding missing padding to PUSH_PROMISE. 3667 Integrate ALTSVC frame and supporting text. 3669 Dropping requirement on "deflate" Content-Encoding. 3671 Improving security considerations around use of compression. 3673 A.4. Since draft-ietf-httpbis-http2-09 3675 Adding padding for data frames. 3677 Renumbering frame types, error codes, and settings. 3679 Adding INADEQUATE_SECURITY error code. 3681 Updating TLS usage requirements to 1.2; forbidding TLS compression. 3683 Removing extensibility for frames and settings. 3685 Changing setting identifier size. 3687 Removing the ability to disable flow control. 3689 Changing the protocol identification token to "h2". 3691 Changing the use of :authority to make it optional and to allow 3692 userinfo in non-HTTP cases. 3694 Allowing split on 0x0 for Cookie. 3696 Reserved PRI method in HTTP/1.1 to avoid possible future collisions. 3698 A.5. Since draft-ietf-httpbis-http2-08 3700 Added cookie crumbling for more efficient header compression. 3702 Added header field ordering with the value-concatenation mechanism. 3704 A.6. Since draft-ietf-httpbis-http2-07 3706 Marked draft for implementation. 3708 A.7. Since draft-ietf-httpbis-http2-06 3710 Adding definition for CONNECT method. 3712 Constraining the use of push to safe, cacheable methods with no 3713 request body. 3715 Changing from :host to :authority to remove any potential confusion. 3717 Adding setting for header compression table size. 3719 Adding settings acknowledgement. 3721 Removing unnecessary and potentially problematic flags from 3722 CONTINUATION. 3724 Added denial of service considerations. 3726 A.8. Since draft-ietf-httpbis-http2-05 3728 Marking the draft ready for implementation. 3730 Renumbering END_PUSH_PROMISE flag. 3732 Editorial clarifications and changes. 3734 A.9. Since draft-ietf-httpbis-http2-04 3736 Added CONTINUATION frame for HEADERS and PUSH_PROMISE. 3738 PUSH_PROMISE is no longer implicitly prohibited if 3739 SETTINGS_MAX_CONCURRENT_STREAMS is zero. 3741 Push expanded to allow all safe methods without a request body. 3743 Clarified the use of HTTP header fields in requests and responses. 3744 Prohibited HTTP/1.1 hop-by-hop header fields. 3746 Requiring that intermediaries not forward requests with missing or 3747 illegal routing :-headers. 3749 Clarified requirements around handling different frames after stream 3750 close, stream reset and GOAWAY. 3752 Added more specific prohibitions for sending of different frame types 3753 in various stream states. 3755 Making the last received setting value the effective value. 3757 Clarified requirements on TLS version, extension and ciphers. 3759 A.10. Since draft-ietf-httpbis-http2-03 3761 Committed major restructuring atrocities. 3763 Added reference to first header compression draft. 3765 Added more formal description of frame lifecycle. 3767 Moved END_STREAM (renamed from FINAL) back to HEADERS/DATA. 3769 Removed HEADERS+PRIORITY, added optional priority to HEADERS frame. 3771 Added PRIORITY frame. 3773 A.11. Since draft-ietf-httpbis-http2-02 3775 Added continuations to frames carrying header blocks. 3777 Replaced use of "session" with "connection" to avoid confusion with 3778 other HTTP stateful concepts, like cookies. 3780 Removed "message". 3782 Switched to TLS ALPN from NPN. 3784 Editorial changes. 3786 A.12. Since draft-ietf-httpbis-http2-01 3788 Added IANA considerations section for frame types, error codes and 3789 settings. 3791 Removed data frame compression. 3793 Added PUSH_PROMISE. 3795 Added globally applicable flags to framing. 3797 Removed zlib-based header compression mechanism. 3799 Updated references. 3801 Clarified stream identifier reuse. 3803 Removed CREDENTIALS frame and associated mechanisms. 3805 Added advice against naive implementation of flow control. 3807 Added session header section. 3809 Restructured frame header. Removed distinction between data and 3810 control frames. 3812 Altered flow control properties to include session-level limits. 3814 Added note on cacheability of pushed resources and multiple tenant 3815 servers. 3817 Changed protocol label form based on discussions. 3819 A.13. Since draft-ietf-httpbis-http2-00 3821 Changed title throughout. 3823 Removed section on Incompatibilities with SPDY draft#2. 3825 Changed INTERNAL_ERROR on GOAWAY to have a value of 2 [6]. 3827 Replaced abstract and introduction. 3829 Added section on starting HTTP/2.0, including upgrade mechanism. 3831 Removed unused references. 3833 Added flow control principles (Section 5.2.1) based on [7]. 3835 A.14. Since draft-mbelshe-httpbis-spdy-00 3837 Adopted as base for draft-ietf-httpbis-http2. 3839 Updated authors/editors list. 3841 Added status note. 3843 Authors' Addresses 3845 Mike Belshe 3846 Twist 3848 EMail: mbelshe@chromium.org 3850 Roberto Peon 3851 Google, Inc 3853 EMail: fenix@google.com 3855 Martin Thomson (editor) 3856 Mozilla 3857 331 E Evelyn Street 3858 Mountain View, CA 94041 3859 US 3861 EMail: martin.thomson@gmail.com