idnits 2.17.1 draft-ietf-httpbis-http2-01.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 'Intended status' indicated for this document; assuming Proposed Standard Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- ** The document seems to lack an IANA Considerations section. (See Section 2.2 of https://www.ietf.org/id-info/checklist for how to handle the case when there are no actions for IANA.) == There are 2 instances of lines with non-RFC2606-compliant FQDNs in the document. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == Using lowercase 'not' together with uppercase 'MUST', 'SHALL', 'SHOULD', or 'RECOMMENDED' is not an accepted usage according to RFC 2119. Please use uppercase 'NOT' together with RFC 2119 keywords (if that is what you mean). Found 'MUST not' in this paragraph: The message is intentionally extensible for future information which may improve client-server communications. The sender does not need to send every type of ID/value. It must only send those for which it has accurate values to convey. When multiple ID/value pairs are sent, they should be sent in order of lowest id to highest id. A single SETTINGS frame MUST not contain multiple values for the same ID. If the recipient of a SETTINGS frame discovers multiple values for the same ID, it MUST ignore all values except the first one. == Using lowercase 'not' together with uppercase 'MUST', 'SHALL', 'SHOULD', or 'RECOMMENDED' is not an accepted usage according to RFC 2119. Please use uppercase 'NOT' together with RFC 2119 keywords (if that is what you mean). Found 'MUST not' in this paragraph: The Connection, Host, Keep-Alive, Proxy-Connection, and Transfer-Encoding headers are not valid and MUST not be sent. == Using lowercase 'not' together with uppercase 'MUST', 'SHALL', 'SHOULD', or 'RECOMMENDED' is not an accepted usage according to RFC 2119. Please use uppercase 'NOT' together with RFC 2119 keywords (if that is what you mean). Found 'MUST not' in this paragraph: The Connection, Keep-Alive, Proxy-Connection, and Transfer-Encoding headers are not valid and MUST not be sent. -- The document date (January 22, 2013) is 4111 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) == Missing Reference: 'TBD' is mentioned on line 241, but not defined -- Possible downref: Non-RFC (?) normative reference: ref. 'ASCII' == Outdated reference: A later version (-26) exists of draft-ietf-httpbis-p1-messaging-21 == Outdated reference: A later version (-26) exists of draft-ietf-httpbis-p2-semantics-21 ** Obsolete normative reference: RFC 793 (Obsoleted by RFC 9293) ** Obsolete normative reference: RFC 1738 (Obsoleted by RFC 4248, RFC 4266) ** Downref: Normative reference to an Informational RFC: RFC 1950 ** Obsolete normative reference: RFC 2616 (Obsoleted by RFC 7230, RFC 7231, RFC 7232, RFC 7233, RFC 7234, RFC 7235) ** Obsolete normative reference: RFC 2617 (Obsoleted by RFC 7235, RFC 7615, RFC 7616, RFC 7617) ** Downref: Normative reference to an Informational RFC: RFC 4559 ** Obsolete normative reference: RFC 5246 (Obsoleted by RFC 8446) == Outdated reference: A later version (-04) exists of draft-agl-tls-nextprotoneg-01 -- Possible downref: Normative reference to a draft: ref. 'TLSNPN' -- Possible downref: Non-RFC (?) normative reference: ref. 'UDELCOMPRESSION' Summary: 8 errors (**), 0 flaws (~~), 10 warnings (==), 4 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 Expires: July 26, 2013 R. Peon 5 Google, Inc 6 M. Thomson, Ed. 7 Microsoft 8 A. Melnikov, Ed. 9 Isode Ltd 10 January 22, 2013 12 Hypertext Transfer Protocol version 2.0 13 draft-ietf-httpbis-http2-01 15 Abstract 17 This document describes an optimised expression of the semantics of 18 the HTTP protocol. The HTTP/2.0 encapsulation enables more efficient 19 transfer of resources over HTTP by providing compressed headers, 20 simultaneous requests, and unsolicited push of resources from server 21 to client. 23 This document is an alternative to, but does not obsolete 24 RFC{http-p1}. The HTTP protocol semantics described in RFC{http- 25 p2..p7} are unmodified. 27 Editorial Note (To be removed by RFC Editor) 29 This draft is a work-in-progress, and does not yet reflect Working 30 Group consensus. 32 This draft contains features from the SPDY Protocol as a starting 33 point, as per the Working Group's charter. Future drafts will add, 34 remove and change text, based upon the Working Group's decisions. 36 Discussion of this draft takes place on the HTTPBIS working group 37 mailing list (ietf-http-wg@w3.org), which is archived at 38 . 40 The current issues list is at 41 and related 42 documents (including fancy diffs) can be found at 43 . 45 The changes in this draft are summarized in Appendix A.1. 47 Status of This Memo 48 This Internet-Draft is submitted in full conformance with the 49 provisions of BCP 78 and BCP 79. 51 Internet-Drafts are working documents of the Internet Engineering 52 Task Force (IETF). Note that other groups may also distribute 53 working documents as Internet-Drafts. The list of current Internet- 54 Drafts is at http://datatracker.ietf.org/drafts/current/. 56 Internet-Drafts are draft documents valid for a maximum of six months 57 and may be updated, replaced, or obsoleted by other documents at any 58 time. It is inappropriate to use Internet-Drafts as reference 59 material or to cite them other than as "work in progress." 61 This Internet-Draft will expire on July 26, 2013. 63 Copyright Notice 65 Copyright (c) 2013 IETF Trust and the persons identified as the 66 document authors. All rights reserved. 68 This document is subject to BCP 78 and the IETF Trust's Legal 69 Provisions Relating to IETF Documents 70 (http://trustee.ietf.org/license-info) in effect on the date of 71 publication of this document. Please review these documents 72 carefully, as they describe your rights and restrictions with respect 73 to this document. Code Components extracted from this document must 74 include Simplified BSD License text as described in Section 4.e of 75 the Trust Legal Provisions and are provided without warranty as 76 described in the Simplified BSD License. 78 Table of Contents 80 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 5 81 1.1. Document Organization . . . . . . . . . . . . . . . . . . 5 82 1.2. Definitions . . . . . . . . . . . . . . . . . . . . . . . 6 83 2. Starting HTTP/2.0 . . . . . . . . . . . . . . . . . . . . . . 6 84 2.1. HTTP/2.0 Version Identification . . . . . . . . . . . . . 6 85 2.2. Starting HTTP/2.0 for "http:" URIs . . . . . . . . . . . . 7 86 2.3. Starting HTTP/2.0 for "https:" URIs . . . . . . . . . . . 8 87 3. HTTP/2.0 Framing Layer . . . . . . . . . . . . . . . . . . . . 8 88 3.1. Session (Connections) . . . . . . . . . . . . . . . . . . 8 89 3.2. Framing . . . . . . . . . . . . . . . . . . . . . . . . . 8 90 3.2.1. Control frames . . . . . . . . . . . . . . . . . . . . 9 91 3.2.2. Data frames . . . . . . . . . . . . . . . . . . . . . 10 92 3.3. Streams . . . . . . . . . . . . . . . . . . . . . . . . . 11 93 3.3.1. Stream frames . . . . . . . . . . . . . . . . . . . . 11 94 3.3.2. Stream creation . . . . . . . . . . . . . . . . . . . 11 95 3.3.3. Stream priority . . . . . . . . . . . . . . . . . . . 12 96 3.3.4. Stream headers . . . . . . . . . . . . . . . . . . . . 12 97 3.3.5. Stream data exchange . . . . . . . . . . . . . . . . . 13 98 3.3.6. Stream half-close . . . . . . . . . . . . . . . . . . 13 99 3.3.7. Stream close . . . . . . . . . . . . . . . . . . . . . 13 100 3.4. Error Handling . . . . . . . . . . . . . . . . . . . . . . 14 101 3.4.1. Session Error Handling . . . . . . . . . . . . . . . . 14 102 3.4.2. Stream Error Handling . . . . . . . . . . . . . . . . 14 103 3.5. Stream Flow Control . . . . . . . . . . . . . . . . . . . 15 104 3.5.1. Flow Control Principles . . . . . . . . . . . . . . . 15 105 3.5.2. Basic Flow Control Algorithm . . . . . . . . . . . . . 16 106 3.6. Control frame types . . . . . . . . . . . . . . . . . . . 16 107 3.6.1. SYN_STREAM . . . . . . . . . . . . . . . . . . . . . . 16 108 3.6.2. SYN_REPLY . . . . . . . . . . . . . . . . . . . . . . 18 109 3.6.3. RST_STREAM . . . . . . . . . . . . . . . . . . . . . . 19 110 3.6.4. SETTINGS . . . . . . . . . . . . . . . . . . . . . . . 20 111 3.6.5. PING . . . . . . . . . . . . . . . . . . . . . . . . . 23 112 3.6.6. GOAWAY . . . . . . . . . . . . . . . . . . . . . . . . 24 113 3.6.7. HEADERS . . . . . . . . . . . . . . . . . . . . . . . 25 114 3.6.8. WINDOW_UPDATE . . . . . . . . . . . . . . . . . . . . 26 115 3.6.9. CREDENTIAL . . . . . . . . . . . . . . . . . . . . . . 28 116 3.6.10. Name/Value Header Block . . . . . . . . . . . . . . . 30 117 4. HTTP Layering over HTTP/2.0 . . . . . . . . . . . . . . . . . 36 118 4.1. Connection Management . . . . . . . . . . . . . . . . . . 36 119 4.1.1. Use of GOAWAY . . . . . . . . . . . . . . . . . . . . 36 120 4.2. HTTP Request/Response . . . . . . . . . . . . . . . . . . 37 121 4.2.1. Request . . . . . . . . . . . . . . . . . . . . . . . 37 122 4.2.2. Response . . . . . . . . . . . . . . . . . . . . . . . 39 123 4.2.3. Authentication . . . . . . . . . . . . . . . . . . . . 39 124 4.3. Server Push Transactions . . . . . . . . . . . . . . . . . 40 125 4.3.1. Server implementation . . . . . . . . . . . . . . . . 41 126 4.3.2. Client implementation . . . . . . . . . . . . . . . . 42 127 5. Design Rationale and Notes . . . . . . . . . . . . . . . . . . 43 128 5.1. Separation of Framing Layer and Application Layer . . . . 43 129 5.2. Error handling - Framing Layer . . . . . . . . . . . . . . 43 130 5.3. One Connection Per Domain . . . . . . . . . . . . . . . . 44 131 5.4. Fixed vs Variable Length Fields . . . . . . . . . . . . . 44 132 5.5. Compression Context(s) . . . . . . . . . . . . . . . . . . 45 133 5.6. Unidirectional streams . . . . . . . . . . . . . . . . . . 45 134 5.7. Data Compression . . . . . . . . . . . . . . . . . . . . . 45 135 5.8. Server Push . . . . . . . . . . . . . . . . . . . . . . . 46 136 6. Security Considerations . . . . . . . . . . . . . . . . . . . 46 137 6.1. Use of Same-origin constraints . . . . . . . . . . . . . . 46 138 6.2. HTTP Headers and HTTP/2.0 Headers . . . . . . . . . . . . 46 139 6.3. Cross-Protocol Attacks . . . . . . . . . . . . . . . . . . 46 140 6.4. Server Push Implicit Headers . . . . . . . . . . . . . . . 46 141 7. Privacy Considerations . . . . . . . . . . . . . . . . . . . . 47 142 7.1. Long Lived Connections . . . . . . . . . . . . . . . . . . 47 143 7.2. SETTINGS frame . . . . . . . . . . . . . . . . . . . . . . 47 145 8. Requirements Notation . . . . . . . . . . . . . . . . . . . . 47 146 9. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 47 147 10. Normative References . . . . . . . . . . . . . . . . . . . . . 48 148 Appendix A. Change Log (to be removed by RFC Editor before 149 publication) . . . . . . . . . . . . . . . . . . . . 49 150 A.1. Since draft-ietf-httpbis-http2-00 . . . . . . . . . . . . 49 151 A.2. Since draft-mbelshe-httpbis-spdy-00 . . . . . . . . . . . 49 153 1. Introduction 155 HTTP is a wildly successful protocol. HTTP/1.1 message encapsulation 156 [HTTP-p1] is optimized for implementation simplicity and 157 accessibility, not application performance. As such it has several 158 characteristics that have a negative overall effect on application 159 performance. 161 The HTTP/1.1 encapsulation ensures that only one request can be 162 delivered at a time on a given connection. HTTP/1.1 pipelining, 163 which is not widely deployed, only partially addresses these 164 concerns. Clients that need to make multiple requests therefore use 165 commonly multiple connections to a server or servers in order to 166 reduce the overall latency of those requests. 168 Furthermore, HTTP/1.1 headers are represented in an inefficient 169 fashion, which, in addition to generating more or larger network 170 packets, can cause the small initial TCP window to fill more quickly 171 than is ideal. This results in excessive latency where multiple 172 requests are made on a new TCP connection. 174 This document defines an optimized mapping of the HTTP semantics to a 175 TCP connection. This optimization reduces the latency costs of HTTP 176 by allowing parallel requests on the same connection and by using an 177 efficient coding for HTTP headers. Prioritization of requests lets 178 more important requests complete faster, further improving 179 application performance. 181 HTTP/2.0 applications have an improved impact on network congestion 182 due to the use of fewer TCP connections to achieve the same effect. 183 Fewer TCP connections compete more fairly with other flows. Long- 184 lived connections are also more able to take better advantage of the 185 available network capacity, rather than operating in the slow start 186 phase of TCP. 188 The HTTP/2.0 encapsulation also enables more efficient processing of 189 messages by providing efficient message framing. Processing of 190 headers in HTTP/2.0 messages is more efficient (for entities that 191 process many messages). 193 1.1. Document Organization 195 The HTTP/2.0 Specification is split into three parts: starting 196 HTTP/2.0 (Section 2), which covers how a HTTP/2.0 is started; a 197 framing layer (Section 3), which multiplexes a TCP connection into 198 independent, length-prefixed frames; and an HTTP layer (Section 4), 199 which specifies the mechanism for overlaying HTTP request/response 200 pairs on top of the framing layer. While some of the framing layer 201 concepts are isolated from the HTTP layer, building a generic framing 202 layer has not been a goal. The framing layer is tailored to the 203 needs of the HTTP protocol and server push. 205 1.2. Definitions 207 client: The endpoint initiating the HTTP/2.0 session. 209 connection: A transport-level connection between two endpoints. 211 endpoint: Either the client or server of a connection. 213 frame: A header-prefixed sequence of bytes sent over a HTTP/2.0 214 session. 216 server: The endpoint which did not initiate the HTTP/2.0 session. 218 session: A synonym for a connection. 220 session error: An error on the HTTP/2.0 session. 222 stream: A bi-directional flow of bytes across a virtual channel 223 within a HTTP/2.0 session. 225 stream error: An error on an individual HTTP/2.0 stream. 227 2. Starting HTTP/2.0 229 Just as HTTP/1.1 does, HTTP/2.0 uses the "http:" and "https:" URI 230 schemes. An HTTP/2.0-capable client is therefore required to 231 discover whether a server (or intermediary) supports HTTP/2.0. 233 Different discovery mechanisms are defined for "http:" and "https:" 234 URIs. Discovery for "http:" URIs is described in Section 2.2; 235 discovery for "https:" URIs is described in Section 2.3. 237 2.1. HTTP/2.0 Version Identification 239 HTTP/2.0 is identified in using the string "HTTP/2.0". This 240 identification is used in the HTTP/1.1 Upgrade header, in the TLS-NPN 241 [TLSNPN] [[TBD]] field and other places where protocol identification 242 is required. 244 [[Editor's Note: please remove the following text prior to the 245 publication of a final version of this document.]] 247 Only implementations of the final, published RFC can identify 248 themselves as "HTTP/2.0". Until such an RFC exists, implementations 249 MUST NOT identify themselves using "HTTP/2.0". 251 Examples and text throughout the rest of this document use "HTTP/2.0" 252 as a matter of editorial convenience only. Implementations of draft 253 versions MUST NOT identify using this string. 255 Implementations of draft versions of the protocol MUST add the 256 corresponding draft number to the identifier before the separator 257 ('/'). For example, draft-ietf-httpbis-http2-03 is identified using 258 the string "HTTP-03/2.0". 260 Non-compatible experiments that are based on these draft versions 261 MUST include a further identifier. For example, an experimental 262 implementation of packet mood-based encoding based on 263 draft-ietf-httpbis-http2-07 might identify itself as "HTTP-07- 264 emo/2.0". Note that any label MUST conform with the "token" syntax 265 defined in Section 3.2.4 of [HTTP-p1]. Experimenters are encouraged 266 to coordinate their experiments on the ietf-http-wg@w3.org mailing 267 list. 269 2.2. Starting HTTP/2.0 for "http:" URIs 271 A client that makes a request to an "http:" URI without prior 272 knowledge about support for HTTP/2.0 uses the HTTP Upgrade mechanism 273 [HTTP-p2]. The client makes an HTTP/1.1 request that includes an 274 Upgrade header field identifying HTTP/2.0. 276 For example: 278 GET /default.htm HTTP/1.1 279 Host: server.example.com 280 Connection: Upgrade 281 Upgrade: HTTP/2.0 283 A server that does not support HTTP/2.0 can respond to the request as 284 though the Upgrade header field were absent: 286 HTTP/1.1 200 OK 287 Content-length: 243 288 Content-type: text/html 289 ... 291 A server that supports HTTP/2.0 can accept the upgrade with a 101 292 (Switching Protocols) status code. After the empty line that 293 terminates the 101 response, the server can begin sending HTTP/2.0 294 frames. These frames MUST include a response to the request that 295 initiated the Upgrade. 297 HTTP/1.1 101 Switching Protocols 298 Connection: Upgrade 299 Upgrade: HTTP/2.0 301 [ HTTP/2.0 frames ... 303 A client can learn that a particular server supports HTTP/2.0 by 304 other means. A client MAY immediately send HTTP/2.0 frames to a 305 server that is known to support HTTP/2.0. [[Open Issue: This is not 306 definite. We may yet choose to perform negotiation for every 307 connection. Reasons include intermediaries; phased upgrade of load- 308 balanced server farms; etc...]] [[Open Issue: We need to enumerate 309 the ways that clients can learn of HTTP/2.0 support.]] 311 2.3. Starting HTTP/2.0 for "https:" URIs 313 [[TBD, maybe NPN]] 315 3. HTTP/2.0 Framing Layer 317 3.1. Session (Connections) 319 The HTTP/2.0 framing layer (or "session") runs atop a reliable 320 transport layer such as TCP [RFC0793]. The client is the TCP 321 connection initiator. HTTP/2.0 connections are persistent 322 connections. 324 For best performance, it is expected that clients will not close open 325 connections until the user navigates away from all web pages 326 referencing a connection, or until the server closes the connection. 327 Servers are encouraged to leave connections open for as long as 328 possible, but can terminate idle connections if necessary. When 329 either endpoint closes the transport-level connection, it MUST first 330 send a GOAWAY (Section 3.6.6) frame so that the endpoints can 331 reliably determine if requests finished before the close. 333 3.2. Framing 335 Once the connection is established, clients and servers exchange 336 framed messages. There are two types of frames: control frames 337 (Section 3.2.1) and data frames (Section 3.2.2). Frames always have 338 a common header which is 8 bytes in length. 340 The first bit is a control bit indicating whether a frame is a 341 control frame or data frame. Control frames carry a version number, 342 a frame type, flags, and a length. Data frames contain the stream 343 ID, flags, and the length for the payload carried after the common 344 header. The simple header is designed to make reading and writing of 345 frames easy. 347 All integer values, including length, version, and type, are in 348 network byte order. HTTP/2.0 does not enforce alignment of types in 349 dynamically sized frames. 351 3.2.1. Control frames 353 +----------------------------------+ 354 |C| Version(15bits) | Type(16bits) | 355 +----------------------------------+ 356 | Flags (8) | Length (24 bits) | 357 +----------------------------------+ 358 | Data | 359 +----------------------------------+ 361 Control bit: The 'C' bit is a single bit indicating if this is a 362 control message. For control frames this value is always 1. 364 Version: The version number of the HTTP/2.0 protocol. This document 365 describes HTTP/2.0 version 3. 367 Type: The type of control frame. See Control Frames for the complete 368 list of control frames. 370 Flags: Flags related to this frame. Flags for control frames and 371 data frames are different. 373 Length: An unsigned 24-bit value representing the number of bytes 374 after the length field. 376 Data: data associated with this control frame. The format and length 377 of this data is controlled by the control frame type. 379 Control frame processing requirements: 381 Note that full length control frames (16MB) can be large for 382 implementations running on resource-limited hardware. In such 383 cases, implementations MAY limit the maximum length frame 384 supported. However, all implementations MUST be able to receive 385 control frames of at least 8192 octets in length. 387 3.2.2. Data frames 389 +----------------------------------+ 390 |C| Stream-ID (31bits) | 391 +----------------------------------+ 392 | Flags (8) | Length (24 bits) | 393 +----------------------------------+ 394 | Data | 395 +----------------------------------+ 397 Control bit: For data frames this value is always 0. 399 Stream-ID: A 31-bit value identifying the stream. 401 Flags: Flags related to this frame. Valid flags are: 403 0x01 = FLAG_FIN - signifies that this frame represents the last 404 frame to be transmitted on this stream. See Stream Close 405 (Section 3.3.7) below. 407 0x02 = FLAG_COMPRESS - indicates that the data in this frame has 408 been compressed. 410 Length: An unsigned 24-bit value representing the number of bytes 411 after the length field. The total size of a data frame is 8 bytes + 412 length. It is valid to have a zero-length data frame. 414 Data: The variable-length data payload; the length was defined in the 415 length field. 417 Data frame processing requirements: 419 If an endpoint receives a data frame for a stream-id which is not 420 open and the endpoint has not sent a GOAWAY (Section 3.6.6) frame, 421 it MUST send issue a stream error (Section 3.4.2) with the error 422 code INVALID_STREAM for the stream-id. 424 If the endpoint which created the stream receives a data frame 425 before receiving a SYN_REPLY on that stream, it is a protocol 426 error, and the recipient MUST issue a stream error (Section 3.4.2) 427 with the status code PROTOCOL_ERROR for the stream-id. 429 Implementors note: If an endpoint receives multiple data frames 430 for invalid stream-ids, it MAY close the session. 432 All HTTP/2.0 endpoints MUST accept compressed data frames. 433 Compression of data frames is always done using zlib compression. 434 Each stream initializes and uses its own compression context 435 dedicated to use within that stream. Endpoints are encouraged to 436 use application level compression rather than HTTP/2.0 stream 437 level compression. 439 Each HTTP/2.0 stream sending compressed frames creates its own 440 zlib context for that stream, and these compression contexts MUST 441 be distinct from the compression contexts used with SYN_STREAM/ 442 SYN_REPLY/HEADER compression. (Thus, if both endpoints of a 443 stream are compressing data on the stream, there will be two zlib 444 contexts, one for sending and one for receiving). 446 3.3. Streams 448 Streams are independent sequences of bi-directional data divided into 449 frames with several properties: 451 Streams may be created by either the client or server. 453 Streams optionally carry a set of name/value header pairs. 455 Streams can concurrently send data interleaved with other streams. 457 Streams may be cancelled. 459 3.3.1. Stream frames 461 HTTP/2.0 defines 3 control frames to manage the lifecycle of a 462 stream: 464 SYN_STREAM - Open a new stream 466 SYN_REPLY - Remote acknowledgement of a new, open stream 468 RST_STREAM - Close a stream 470 3.3.2. Stream creation 472 A stream is created by sending a control frame with the type set to 473 SYN_STREAM (Section 3.6.1). If the server is initiating the stream, 474 the Stream-ID must be even. If the client is initiating the stream, 475 the Stream-ID must be odd. 0 is not a valid Stream-ID. Stream-IDs 476 from each side of the connection must increase monotonically as new 477 streams are created. E.g. Stream 2 may be created after stream 3, 478 but stream 7 must not be created after stream 9. Stream IDs do not 479 wrap: when a client or server cannot create a new stream id without 480 exceeding a 31 bit value, it MUST NOT create a new stream. 482 The stream-id MUST increase with each new stream. If an endpoint 483 receives a SYN_STREAM with a stream id which is less than any 484 previously received SYN_STREAM, it MUST issue a session error 485 (Section 3.4.1) with the status PROTOCOL_ERROR. 487 It is a protocol error to send two SYN_STREAMs with the same 488 stream-id. If a recipient receives a second SYN_STREAM for the same 489 stream, it MUST issue a stream error (Section 3.4.2) with the status 490 code PROTOCOL_ERROR. 492 Upon receipt of a SYN_STREAM, the recipient can reject the stream by 493 sending a stream error (Section 3.4.2) with the error code 494 REFUSED_STREAM. Note, however, that the creating endpoint may have 495 already sent additional frames for that stream which cannot be 496 immediately stopped. 498 Once the stream is created, the creator may immediately send HEADERS 499 or DATA frames for that stream, without needing to wait for the 500 recipient to acknowledge. 502 3.3.2.1. Unidirectional streams 504 When an endpoint creates a stream with the FLAG_UNIDIRECTIONAL flag 505 set, it creates a unidirectional stream which the creating endpoint 506 can use to send frames, but the receiving endpoint cannot. The 507 receiving endpoint is implicitly already in the half-closed 508 (Section 3.3.6) state. 510 3.3.2.2. Bidirectional streams 512 SYN_STREAM frames which do not use the FLAG_UNIDIRECTIONAL flag are 513 bidirectional streams. Both endpoints can send data on a bi- 514 directional stream. 516 3.3.3. Stream priority 518 The creator of a stream assigns a priority for that stream. Priority 519 is represented as an integer from 0 to 7. 0 represents the highest 520 priority and 7 represents the lowest priority. 522 The sender and recipient SHOULD use best-effort to process streams in 523 the order of highest priority to lowest priority. 525 3.3.4. Stream headers 527 Streams carry optional sets of name/value pair headers which carry 528 metadata about the stream. After the stream has been created, and as 529 long as the sender is not closed (Section 3.3.7) or half-closed 530 (Section 3.3.6), each side may send HEADERS frame(s) containing the 531 header data. Header data can be sent in multiple HEADERS frames, and 532 HEADERS frames may be interleaved with data frames. 534 3.3.5. Stream data exchange 536 Once a stream is created, it can be used to send arbitrary amounts of 537 data. Generally this means that a series of data frames will be sent 538 on the stream until a frame containing the FLAG_FIN flag is set. The 539 FLAG_FIN can be set on a SYN_STREAM (Section 3.6.1), SYN_REPLY 540 (Section 3.6.2), HEADERS (Section 3.6.7) or a DATA (Section 3.2.2) 541 frame. Once the FLAG_FIN has been sent, the stream is considered to 542 be half-closed. 544 3.3.6. Stream half-close 546 When one side of the stream sends a frame with the FLAG_FIN flag set, 547 the stream is half-closed from that endpoint. The sender of the 548 FLAG_FIN MUST NOT send further frames on that stream. When both 549 sides have half-closed, the stream is closed. 551 If an endpoint receives a data frame after the stream is half-closed 552 from the sender (e.g. the endpoint has already received a prior frame 553 for the stream with the FIN flag set), it MUST send a RST_STREAM to 554 the sender with the status STREAM_ALREADY_CLOSED. 556 3.3.7. Stream close 558 There are 3 ways that streams can be terminated: 560 Normal termination: Normal stream termination occurs when both 561 sender and recipient have half-closed the stream by sending a 562 FLAG_FIN. 564 Abrupt termination: Either the client or server can send a 565 RST_STREAM control frame at any time. A RST_STREAM contains an 566 error code to indicate the reason for failure. When a RST_STREAM 567 is sent from the stream originator, it indicates a failure to 568 complete the stream and that no further data will be sent on the 569 stream. When a RST_STREAM is sent from the stream recipient, the 570 sender, upon receipt, should stop sending any data on the stream. 571 The stream recipient should be aware that there is a race between 572 data already in transit from the sender and the time the 573 RST_STREAM is received. See Stream Error Handling (Section 3.4.2) 575 TCP connection teardown: If the TCP connection is torn down while 576 un-closed streams exist, then the endpoint must assume that the 577 stream was abnormally interrupted and may be incomplete. 579 If an endpoint receives a data frame after the stream is closed, it 580 must send a RST_STREAM to the sender with the status PROTOCOL_ERROR. 582 3.4. Error Handling 584 The HTTP/2.0 framing layer has only two types of errors, and they are 585 always handled consistently. Any reference in this specification to 586 "issue a session error" refers to Section 3.4.1. Any reference to 587 "issue a stream error" refers to Section 3.4.2. 589 3.4.1. Session Error Handling 591 A session error is any error which prevents further processing of the 592 framing layer or which corrupts the session compression state. When 593 a session error occurs, the endpoint encountering the error MUST 594 first send a GOAWAY (Section 3.6.6) frame with the stream id of most 595 recently received stream from the remote endpoint, and the error code 596 for why the session is terminating. After sending the GOAWAY frame, 597 the endpoint MUST close the TCP connection. 599 Note that the session compression state is dependent upon both 600 endpoints always processing all compressed data. If an endpoint 601 partially processes a frame containing compressed data without 602 updating compression state properly, future control frames which use 603 compression will be always be errored. Implementations SHOULD always 604 try to process compressed data so that errors which could be handled 605 as stream errors do not become session errors. 607 Note that because this GOAWAY is sent during a session error case, it 608 is possible that the GOAWAY will not be reliably received by the 609 receiving endpoint. It is a best-effort attempt to communicate with 610 the remote about why the session is going down. 612 3.4.2. Stream Error Handling 614 A stream error is an error related to a specific stream-id which does 615 not affect processing of other streams at the framing layer. Upon a 616 stream error, the endpoint MUST send a RST_STREAM (Section 3.6.3) 617 frame which contains the stream id of the stream where the error 618 occurred and the error status which caused the error. After sending 619 the RST_STREAM, the stream is closed to the sending endpoint. After 620 sending the RST_STREAM, if the sender receives any frames other than 621 a RST_STREAM for that stream id, it will result in sending additional 622 RST_STREAM frames. An endpoint MUST NOT send a RST_STREAM in 623 response to an RST_STREAM, as doing so would lead to RST_STREAM 624 loops. Sending a RST_STREAM does not cause the HTTP/2.0 session to 625 be closed. 627 If an endpoint has multiple RST_STREAM frames to send in succession 628 for the same stream-id and the same error code, it MAY coalesce them 629 into a single RST_STREAM frame. (This can happen if a stream is 630 closed, but the remote sends multiple data frames. There is no 631 reason to send a RST_STREAM for each frame in succession). 633 3.5. Stream Flow Control 635 Multiplexing streams introduces contention for access to the shared 636 TCP connection. Stream contention can result in streams being 637 blocked by other streams. A flow control scheme ensures that streams 638 do not destructively interfere with other streams on the same TCP 639 connection. 641 3.5.1. Flow Control Principles 643 Experience with TCP congestion control has shown that algorithms can 644 evolve over time to become more sophisticated without requiring 645 protocol changes. TCP congestion control and its evolution is 646 clearly different from HTTP/2.0 flow control, though the evolution of 647 TCP congestion control algorithms shows that a similar approach could 648 be feasible for HTTP/2.0 flow control. 650 HTTP/2.0 stream flow control aims to allow for future improvements to 651 flow control algorithms without requiring protocol changes. The 652 following principles guide the HTTP/2.0 design: 654 1. Flow control is hop-by-hop, not end-to-end. 656 2. Flow control is based on window update messages. Receivers 657 advertise how many octets they are prepared to receive on a 658 stream. This is a credit-based scheme. 660 3. Flow control is directional with overall control provided by the 661 receiver. A receiver MAY choose to set any window size that it 662 desires for each stream [[TBD: ... and for the overall 663 connection]]. A sender MUST respect flow control limits imposed 664 by a receiver. Clients, servers and intermediaries all 665 independently advertise their flow control preferences as a 666 receiver and abide by the flow control limits set by their peer 667 when sending. 669 4. Flow control can be disabled by a receiver. A receiver can 670 choose to either disable flow control, or to declare an infinite 671 flow control limit. [[TBD: determine whether just one mechanism 672 is sufficient, and then which alternative]] 674 5. HTTP/2.0 standardizes only the format of the window update 675 message (Section 3.6.8). This does not stipulate how a receiver 676 decides when to send this message or the value that it sends. 677 Nor does it specify how a sender chooses to send packets. 678 Implementations are able to select any algorithm that suits their 679 needs. An example flow control algorithm is described in 680 Section 3.5.2. 682 Implementations are also responsible for managing how requests and 683 responses are sent based on priority; choosing how to avoid head of 684 line blocking for requests; and managing the creation of new streams. 685 Algorithm choices for these could interact with any flow control 686 algorithm. 688 3.5.2. Basic Flow Control Algorithm 690 This section describes a basic flow control algorithm. This 691 algorithm is provided as an example, implementations can use any 692 algorithm that complies with flow control requirements. 694 [[Algorithm TBD]] 696 3.6. Control frame types 698 3.6.1. SYN_STREAM 700 The SYN_STREAM control frame allows the sender to asynchronously 701 create a stream between the endpoints. See Stream Creation 702 (Section 3.3.2) 703 +------------------------------------+ 704 |1| version | 1 | 705 +------------------------------------+ 706 | Flags (8) | Length (24 bits) | 707 +------------------------------------+ 708 |X| Stream-ID (31bits) | 709 +------------------------------------+ 710 |X| Associated-To-Stream-ID (31bits) | 711 +------------------------------------+ 712 | Pri|Unused | Slot | | 713 +-------------------+ | 714 | Number of Name/Value pairs (int32) | <+ 715 +------------------------------------+ | 716 | Length of name (int32) | | This section is the 717 +------------------------------------+ | "Name/Value Header 718 | Name (string) | | Block", and is 719 +------------------------------------+ | compressed. 720 | Length of value (int32) | | 721 +------------------------------------+ | 722 | Value (string) | | 723 +------------------------------------+ | 724 | (repeats) | <+ 726 Flags: Flags related to this frame. Valid flags are: 728 0x01 = FLAG_FIN - marks this frame as the last frame to be 729 transmitted on this stream and puts the sender in the half-closed 730 (Section 3.3.6) state. 732 0x02 = FLAG_UNIDIRECTIONAL - a stream created with this flag puts 733 the recipient in the half-closed (Section 3.3.6) state. 735 Length: The length is the number of bytes which follow the length 736 field in the frame. For SYN_STREAM frames, this is 10 bytes plus the 737 length of the compressed Name/Value block. 739 Stream-ID: The 31-bit identifier for this stream. This stream-id 740 will be used in frames which are part of this stream. 742 Associated-To-Stream-ID: The 31-bit identifier for a stream which 743 this stream is associated to. If this stream is independent of all 744 other streams, it should be 0. 746 Priority: A 3-bit priority (Section 3.3.3) field. 748 Unused: 5 bits of unused space, reserved for future use. 750 Slot: An 8 bit unsigned integer specifying the index in the server's 751 CREDENTIAL vector of the client certificate to be used for this 752 request. see CREDENTIAL frame (Section 3.6.9). The value 0 means no 753 client certificate should be associated with this stream. 755 Name/Value Header Block: A set of name/value pairs carried as part of 756 the SYN_STREAM. see Name/Value Header Block (Section 3.6.10). 758 If an endpoint receives a SYN_STREAM which is larger than the 759 implementation supports, it MAY send a RST_STREAM with error code 760 FRAME_TOO_LARGE. All implementations MUST support the minimum size 761 limits defined in the Control Frames section (Section 3.2.1). 763 3.6.2. SYN_REPLY 765 SYN_REPLY indicates the acceptance of a stream creation by the 766 recipient of a SYN_STREAM frame. 768 +------------------------------------+ 769 |1| version | 2 | 770 +------------------------------------+ 771 | Flags (8) | Length (24 bits) | 772 +------------------------------------+ 773 |X| Stream-ID (31bits) | 774 +------------------------------------+ 775 | Number of Name/Value pairs (int32) | <+ 776 +------------------------------------+ | 777 | Length of name (int32) | | This section is the 778 +------------------------------------+ | "Name/Value Header 779 | Name (string) | | Block", and is 780 +------------------------------------+ | compressed. 781 | Length of value (int32) | | 782 +------------------------------------+ | 783 | Value (string) | | 784 +------------------------------------+ | 785 | (repeats) | <+ 787 Flags: Flags related to this frame. Valid flags are: 789 0x01 = FLAG_FIN - marks this frame as the last frame to be 790 transmitted on this stream and puts the sender in the half-closed 791 (Section 3.3.6) state. 793 Length: The length is the number of bytes which follow the length 794 field in the frame. For SYN_REPLY frames, this is 4 bytes plus the 795 length of the compressed Name/Value block. 797 Stream-ID: The 31-bit identifier for this stream. 799 If an endpoint receives multiple SYN_REPLY frames for the same active 800 stream ID, it MUST issue a stream error (Section 3.4.2) with the 801 error code STREAM_IN_USE. 803 Name/Value Header Block: A set of name/value pairs carried as part of 804 the SYN_STREAM. see Name/Value Header Block (Section 3.6.10). 806 If an endpoint receives a SYN_REPLY which is larger than the 807 implementation supports, it MAY send a RST_STREAM with error code 808 FRAME_TOO_LARGE. All implementations MUST support the minimum size 809 limits defined in the Control Frames section (Section 3.2.1). 811 3.6.3. RST_STREAM 813 The RST_STREAM frame allows for abnormal termination of a stream. 814 When sent by the creator of a stream, it indicates the creator wishes 815 to cancel the stream. When sent by the recipient of a stream, it 816 indicates an error or that the recipient did not want to accept the 817 stream, so the stream should be closed. 819 +----------------------------------+ 820 |1| version | 3 | 821 +----------------------------------+ 822 | Flags (8) | 8 | 823 +----------------------------------+ 824 |X| Stream-ID (31bits) | 825 +----------------------------------+ 826 | Status code | 827 +----------------------------------+ 829 Flags: Flags related to this frame. RST_STREAM does not define any 830 flags. This value must be 0. 832 Length: An unsigned 24-bit value representing the number of bytes 833 after the length field. For RST_STREAM control frames, this value is 834 always 8. 836 Stream-ID: The 31-bit identifier for this stream. 838 Status code: (32 bits) An indicator for why the stream is being 839 terminated.The following status codes are defined: 841 1 - PROTOCOL_ERROR. This is a generic error, and should only be 842 used if a more specific error is not available. 844 2 - INVALID_STREAM. This is returned when a frame is received for 845 a stream which is not active. 847 3 - REFUSED_STREAM. Indicates that the stream was refused before 848 any processing has been done on the stream. 850 4 - UNSUPPORTED_VERSION. Indicates that the recipient of a stream 851 does not support the HTTP/2.0 version requested. 853 5 - CANCEL. Used by the creator of a stream to indicate that the 854 stream is no longer needed. 856 6 - INTERNAL_ERROR. This is a generic error which can be used 857 when the implementation has internally failed, not due to anything 858 in the protocol. 860 7 - FLOW_CONTROL_ERROR. The endpoint detected that its peer 861 violated the flow control protocol. 863 8 - STREAM_IN_USE. The endpoint received a SYN_REPLY for a stream 864 already open. 866 9 - STREAM_ALREADY_CLOSED. The endpoint received a data or 867 SYN_REPLY frame for a stream which is half closed. 869 10 - INVALID_CREDENTIALS. The server received a request for a 870 resource whose origin does not have valid credentials in the 871 client certificate vector. 873 11 - FRAME_TOO_LARGE. The endpoint received a frame which this 874 implementation could not support. If FRAME_TOO_LARGE is sent for 875 a SYN_STREAM, HEADERS, or SYN_REPLY frame without fully processing 876 the compressed portion of those frames, then the compression state 877 will be out-of-sync with the other endpoint. In this case, 878 senders of FRAME_TOO_LARGE MUST close the session. 880 Note: 0 is not a valid status code for a RST_STREAM. 882 After receiving a RST_STREAM on a stream, the recipient must not send 883 additional frames for that stream, and the stream moves into the 884 closed state. 886 3.6.4. SETTINGS 888 A SETTINGS frame contains a set of id/value pairs for communicating 889 configuration data about how the two endpoints may communicate. 890 SETTINGS frames can be sent at any time by either endpoint, are 891 optionally sent, and are fully asynchronous. When the server is the 892 sender, the sender can request that configuration data be persisted 893 by the client across HTTP/2.0 sessions and returned to the server in 894 future communications. 896 Persistence of SETTINGS ID/Value pairs is done on a per origin/IP 897 pair (the "origin" is the set of scheme, host, and port from the URI. 898 See [RFC6454]). That is, when a client connects to a server, and the 899 server persists settings within the client, the client SHOULD return 900 the persisted settings on future connections to the same origin AND 901 IP address and TCP port. Clients MUST NOT request servers to use the 902 persistence features of the SETTINGS frames, and servers MUST ignore 903 persistence related flags sent by a client. 905 +----------------------------------+ 906 |1| version | 4 | 907 +----------------------------------+ 908 | Flags (8) | Length (24 bits) | 909 +----------------------------------+ 910 | Number of entries | 911 +----------------------------------+ 912 | ID/Value Pairs | 913 | ... | 915 Control bit: The control bit is always 1 for this message. 917 Version: The HTTP/2.0 version number. 919 Type: The message type for a SETTINGS message is 4. 921 Flags: FLAG_SETTINGS_CLEAR_SETTINGS (0x1): When set, the client 922 should clear any previously persisted SETTINGS ID/Value pairs. If 923 this frame contains ID/Value pairs with the 924 FLAG_SETTINGS_PERSIST_VALUE set, then the client will first clear its 925 existing, persisted settings, and then persist the values with the 926 flag set which are contained within this frame. Because persistence 927 is only implemented on the client, this flag can only be used when 928 the sender is the server. 930 Length: An unsigned 24-bit value representing the number of bytes 931 after the length field. The total size of a SETTINGS frame is 8 932 bytes + length. 934 Number of entries: A 32-bit value representing the number of ID/value 935 pairs in this message. 937 ID: A 32-bit ID number, comprised of 8 bits of flags and 24 bits of 938 unique ID. 940 ID.flags: 942 FLAG_SETTINGS_PERSIST_VALUE (0x1): When set, the sender of this 943 SETTINGS frame is requesting that the recipient persist the ID/ 944 Value and return it in future SETTINGS frames sent from the 945 sender to this recipient. Because persistence is only 946 implemented on the client, this flag is only sent by the 947 server. 949 FLAG_SETTINGS_PERSISTED (0x2): When set, the sender is 950 notifying the recipient that this ID/Value pair was previously 951 sent to the sender by the recipient with the 952 FLAG_SETTINGS_PERSIST_VALUE, and the sender is returning it. 953 Because persistence is only implemented on the client, this 954 flag is only sent by the client. 956 Defined IDs: 958 1 - SETTINGS_UPLOAD_BANDWIDTH allows the sender to send its 959 expected upload bandwidth on this channel. This number is an 960 estimate. The value should be the integral number of kilobytes 961 per second that the sender predicts as an expected maximum 962 upload channel capacity. 964 2 - SETTINGS_DOWNLOAD_BANDWIDTH allows the sender to send its 965 expected download bandwidth on this channel. This number is an 966 estimate. The value should be the integral number of kilobytes 967 per second that the sender predicts as an expected maximum 968 download channel capacity. 970 3 - SETTINGS_ROUND_TRIP_TIME allows the sender to send its 971 expected round-trip-time on this channel. The round trip time 972 is defined as the minimum amount of time to send a control 973 frame from this client to the remote and receive a response. 974 The value is represented in milliseconds. 976 4 - SETTINGS_MAX_CONCURRENT_STREAMS allows the sender to inform 977 the remote endpoint the maximum number of concurrent streams 978 which it will allow. By default there is no limit. For 979 implementors it is recommended that this value be no smaller 980 than 100. 982 5 - SETTINGS_CURRENT_CWND allows the sender to inform the 983 remote endpoint of the current TCP CWND value. 985 6 - SETTINGS_DOWNLOAD_RETRANS_RATE allows the sender to inform 986 the remote endpoint the retransmission rate (bytes 987 retransmitted / total bytes transmitted). 989 7 - SETTINGS_INITIAL_WINDOW_SIZE allows the sender to inform 990 the remote endpoint the initial window size (in bytes) for new 991 streams. 993 8 - SETTINGS_CLIENT_CERTIFICATE_VECTOR_SIZE allows the server 994 to inform the client of the new size of the client certificate 995 vector. 997 Value: A 32-bit value. 999 The message is intentionally extensible for future information which 1000 may improve client-server communications. The sender does not need 1001 to send every type of ID/value. It must only send those for which it 1002 has accurate values to convey. When multiple ID/value pairs are 1003 sent, they should be sent in order of lowest id to highest id. A 1004 single SETTINGS frame MUST not contain multiple values for the same 1005 ID. If the recipient of a SETTINGS frame discovers multiple values 1006 for the same ID, it MUST ignore all values except the first one. 1008 A server may send multiple SETTINGS frames containing different ID/ 1009 Value pairs. When the same ID/Value is sent twice, the most recent 1010 value overrides any previously sent values. If the server sends IDs 1011 1, 2, and 3 with the FLAG_SETTINGS_PERSIST_VALUE in a first SETTINGS 1012 frame, and then sends IDs 4 and 5 with the 1013 FLAG_SETTINGS_PERSIST_VALUE, when the client returns the persisted 1014 state on its next SETTINGS frame, it SHOULD send all 5 settings (1, 1015 2, 3, 4, and 5 in this example) to the server. 1017 3.6.5. PING 1019 The PING control frame is a mechanism for measuring a minimal round- 1020 trip time from the sender. It can be sent from the client or the 1021 server. Recipients of a PING frame should send an identical frame to 1022 the sender as soon as possible (if there is other pending data 1023 waiting to be sent, PING should take highest priority). Each ping 1024 sent by a sender should use a unique ID. 1026 +----------------------------------+ 1027 |1| version | 6 | 1028 +----------------------------------+ 1029 | 0 (flags) | 4 (length) | 1030 +----------------------------------| 1031 | 32-bit ID | 1032 +----------------------------------+ 1034 Control bit: The control bit is always 1 for this message. 1036 Version: The HTTP/2.0 version number. 1038 Type: The message type for a PING message is 6. 1040 Length: This frame is always 4 bytes long. 1042 ID: A unique ID for this ping, represented as an unsigned 32 bit 1043 value. When the client initiates a ping, it must use an odd numbered 1044 ID. When the server initiates a ping, it must use an even numbered 1045 ping. Use of odd/even IDs is required in order to avoid accidental 1046 looping on PINGs (where each side initiates an identical PING at the 1047 same time). 1049 Note: If a sender uses all possible PING ids (e.g. has sent all 2^31 1050 possible IDs), it can wrap and start re-using IDs. 1052 If a server receives an even numbered PING which it did not initiate, 1053 it must ignore the PING. If a client receives an odd numbered PING 1054 which it did not initiate, it must ignore the PING. 1056 3.6.6. GOAWAY 1058 The GOAWAY control frame is a mechanism to tell the remote side of 1059 the connection to stop creating streams on this session. It can be 1060 sent from the client or the server. Once sent, the sender will not 1061 respond to any new SYN_STREAMs on this session. Recipients of a 1062 GOAWAY frame must not send additional streams on this session, 1063 although a new session can be established for new streams. The 1064 purpose of this message is to allow an endpoint to gracefully stop 1065 accepting new streams (perhaps for a reboot or maintenance), while 1066 still finishing processing of previously established streams. 1068 There is an inherent race condition between an endpoint sending 1069 SYN_STREAMs and the remote sending a GOAWAY message. To deal with 1070 this case, the GOAWAY contains a last-stream-id indicating the 1071 stream-id of the last stream which was created on the sending 1072 endpoint in this session. If the receiver of the GOAWAY sent new 1073 SYN_STREAMs for sessions after this last-stream-id, they were not 1074 processed by the server and the receiver may treat the stream as 1075 though it had never been created at all (hence the receiver may want 1076 to re-create the stream later on a new session). 1078 Endpoints should always send a GOAWAY message before closing a 1079 connection so that the remote can know whether a stream has been 1080 partially processed or not. (For example, if an HTTP client sends a 1081 POST at the same time that a server closes a connection, the client 1082 cannot know if the server started to process that POST request if the 1083 server does not send a GOAWAY frame to indicate where it stopped 1084 working). 1086 After sending a GOAWAY message, the sender must ignore all SYN_STREAM 1087 frames for new streams. 1089 +----------------------------------+ 1090 |1| version | 7 | 1091 +----------------------------------+ 1092 | 0 (flags) | 8 (length) | 1093 +----------------------------------| 1094 |X| Last-good-stream-ID (31 bits) | 1095 +----------------------------------+ 1096 | Status code | 1097 +----------------------------------+ 1099 Control bit: The control bit is always 1 for this message. 1101 Version: The HTTP/2.0 version number. 1103 Type: The message type for a GOAWAY message is 7. 1105 Length: This frame is always 8 bytes long. 1107 Last-good-stream-Id: The last stream id which was replied to (with 1108 either a SYN_REPLY or RST_STREAM) by the sender of the GOAWAY 1109 message. If no streams were replied to, this value MUST be 0. 1111 Status: The reason for closing the session. 1113 0 - OK. This is a normal session teardown. 1115 1 - PROTOCOL_ERROR. This is a generic error, and should only be 1116 used if a more specific error is not available. 1118 2 - INTERNAL_ERROR. This is a generic error which can be used 1119 when the implementation has internally failed, not due to anything 1120 in the protocol. 1122 3.6.7. HEADERS 1124 The HEADERS frame augments a stream with additional headers. It may 1125 be optionally sent on an existing stream at any time. Specific 1126 application of the headers in this frame is application-dependent. 1127 The name/value header block within this frame is compressed. 1129 +------------------------------------+ 1130 |1| version | 8 | 1131 +------------------------------------+ 1132 | Flags (8) | Length (24 bits) | 1133 +------------------------------------+ 1134 |X| Stream-ID (31bits) | 1135 +------------------------------------+ 1136 | Number of Name/Value pairs (int32) | <+ 1137 +------------------------------------+ | 1138 | Length of name (int32) | | This section is the 1139 +------------------------------------+ | "Name/Value Header 1140 | Name (string) | | Block", and is 1141 +------------------------------------+ | compressed. 1142 | Length of value (int32) | | 1143 +------------------------------------+ | 1144 | Value (string) | | 1145 +------------------------------------+ | 1146 | (repeats) | <+ 1148 Flags: Flags related to this frame. Valid flags are: 1150 0x01 = FLAG_FIN - marks this frame as the last frame to be 1151 transmitted on this stream and puts the sender in the half-closed 1152 (Section 3.3.6) state. 1154 Length: An unsigned 24 bit value representing the number of bytes 1155 after the length field. The minimum length of the length field is 4 1156 (when the number of name value pairs is 0). 1158 Stream-ID: The stream this HEADERS block is associated with. 1160 Name/Value Header Block: A set of name/value pairs carried as part of 1161 the SYN_STREAM. see Name/Value Header Block (Section 3.6.10). 1163 3.6.8. WINDOW_UPDATE 1165 The WINDOW_UPDATE control frame is used to implement per stream flow 1166 control in HTTP/2.0. Flow control in HTTP/2.0 is per hop, that is, 1167 only between the two endpoints of a HTTP/2.0 connection. If there 1168 are one or more intermediaries between the client and the origin 1169 server, flow control signals are not explicitly forwarded by the 1170 intermediaries. (However, throttling of data transfer by any 1171 recipient may have the effect of indirectly propagating flow control 1172 information upstream back to the original sender.) Flow control only 1173 applies to the data portion of data frames. Recipients must buffer 1174 all control frames. If a recipient fails to buffer an entire control 1175 frame, it MUST issue a stream error (Section 3.4.2) with the status 1176 code FLOW_CONTROL_ERROR for the stream. 1178 Flow control in HTTP/2.0 is implemented by a data transfer window 1179 kept by the sender of each stream. The data transfer window is a 1180 simple uint32 that indicates how many bytes of data the sender can 1181 transmit. After a stream is created, but before any data frames have 1182 been transmitted, the sender begins with the initial window size. 1183 This window size is a measure of the buffering capability of the 1184 recipient. The sender must not send a data frame with data length 1185 greater than the transfer window size. After sending each data 1186 frame, the sender decrements its transfer window size by the amount 1187 of data transmitted. When the window size becomes less than or equal 1188 to 0, the sender must pause transmitting data frames. At the other 1189 end of the stream, the recipient sends a WINDOW_UPDATE control back 1190 to notify the sender that it has consumed some data and freed up 1191 buffer space to receive more data. 1193 +----------------------------------+ 1194 |1| version | 9 | 1195 +----------------------------------+ 1196 | 0 (flags) | 8 (length) | 1197 +----------------------------------+ 1198 |X| Stream-ID (31-bits) | 1199 +----------------------------------+ 1200 |X| Delta-Window-Size (31-bits) | 1201 +----------------------------------+ 1203 Control bit: The control bit is always 1 for this message. 1205 Version: The HTTP/2.0 version number. 1207 Type: The message type for a WINDOW_UPDATE message is 9. 1209 Length: The length field is always 8 for this frame (there are 8 1210 bytes after the length field). 1212 Stream-ID: The stream ID that this WINDOW_UPDATE control frame is 1213 for. 1215 Delta-Window-Size: The additional number of bytes that the sender can 1216 transmit in addition to existing remaining window size. The legal 1217 range for this field is 1 to 2^31 - 1 (0x7fffffff) bytes. 1219 The window size as kept by the sender must never exceed 2^31 1220 (although it can become negative in one special case). If a sender 1221 receives a WINDOW_UPDATE that causes the its window size to exceed 1222 this limit, it must send RST_STREAM with status code 1223 FLOW_CONTROL_ERROR to terminate the stream. 1225 When a HTTP/2.0 connection is first established, the default initial 1226 window size for all streams is 64KB. An endpoint can use the 1227 SETTINGS control frame to adjust the initial window size for the 1228 connection. That is, its peer can start out using the 64KB default 1229 initial window size when sending data frames before receiving the 1230 SETTINGS. Because SETTINGS is asynchronous, there may be a race 1231 condition if the recipient wants to decrease the initial window size, 1232 but its peer immediately sends 64KB on the creation of a new 1233 connection, before waiting for the SETTINGS to arrive. This is one 1234 case where the window size kept by the sender will become negative. 1235 Once the sender detects this condition, it must stop sending data 1236 frames and wait for the recipient to catch up. The recipient has two 1237 choices: 1239 immediately send RST_STREAM with FLOW_CONTROL_ERROR status code. 1241 allow the head of line blocking (as there is only one stream for 1242 the session and the amount of data in flight is bounded by the 1243 default initial window size), and send WINDOW_UPDATE as it 1244 consumes data. 1246 In the case of option 2, both sides must compute the window size 1247 based on the initial window size in the SETTINGS. For example, if 1248 the recipient sets the initial window size to be 16KB, and the sender 1249 sends 64KB immediately on connection establishment, the sender will 1250 discover its window size is -48KB on receipt of the SETTINGS. As the 1251 recipient consumes the first 16KB, it must send a WINDOW_UPDATE of 1252 16KB back to the sender. This interaction continues until the 1253 sender's window size becomes positive again, and it can resume 1254 transmitting data frames. 1256 After the recipient reads in a data frame with FLAG_FIN that marks 1257 the end of the data stream, it should not send WINDOW_UPDATE frames 1258 as it consumes the last data frame. A sender should ignore all the 1259 WINDOW_UPDATE frames associated with the stream after it send the 1260 last frame for the stream. 1262 The data frames from the sender and the WINDOW_UPDATE frames from the 1263 recipient are completely asynchronous with respect to each other. 1264 This property allows a recipient to aggressively update the window 1265 size kept by the sender to prevent the stream from stalling. 1267 3.6.9. CREDENTIAL 1269 The CREDENTIAL control frame is used by the client to send additional 1270 client certificates to the server. A HTTP/2.0 client may decide to 1271 send requests for resources from different origins on the same 1272 HTTP/2.0 session if it decides that that server handles both origins. 1273 For example if the IP address associated with both hostnames matches 1274 and the SSL server certificate presented in the initial handshake is 1275 valid for both hostnames. However, because the SSL connection can 1276 contain at most one client certificate, the client needs a mechanism 1277 to send additional client certificates to the server. 1279 The server is required to maintain a vector of client certificates 1280 associated with a HTTP/2.0 session. When the client needs to send a 1281 client certificate to the server, it will send a CREDENTIAL frame 1282 that specifies the index of the slot in which to store the 1283 certificate as well as proof that the client posesses the 1284 corresponding private key. The initial size of this vector must be 1285 8. If the client provides a client certificate during the first TLS 1286 handshake, the contents of this certificate must be copied into the 1287 first slot (index 1) in the CREDENTIAL vector, though it may be 1288 overwritten by subsequent CREDENTIAL frames. The server must 1289 exclusively use the CREDENTIAL vector when evaluating the client 1290 certificates associated with an origin. The server may change the 1291 size of this vector by sending a SETTINGS frame with the setting 1292 SETTINGS_CLIENT_CERTIFICATE_VECTOR_SIZE value specified. In the 1293 event that the new size is smaller than the current size, truncation 1294 occurs preserving lower-index slots as possible. 1296 TLS renegotiation with client authentication is incompatible with 1297 HTTP/2.0 given the multiplexed nature of HTTP/2.0. Specifically, 1298 imagine that the client has 2 requests outstanding to the server for 1299 two different pages (in different tabs). When the renegotiation + 1300 client certificate request comes in, the browser is unable to 1301 determine which resource triggered the client certificate request, in 1302 order to prompt the user accordingly. 1304 +----------------------------------+ 1305 |1|000000000000001|0000000000001011| 1306 +----------------------------------+ 1307 | flags (8) | Length (24 bits) | 1308 +----------------------------------+ 1309 | Slot (16 bits) | | 1310 +-----------------+ | 1311 | Proof Length (32 bits) | 1312 +----------------------------------+ 1313 | Proof | 1314 +----------------------------------+ <+ 1315 | Certificate Length (32 bits) | | 1316 +----------------------------------+ | Repeated until end of frame 1317 | Certificate | | 1318 +----------------------------------+ <+ 1320 Slot: The index in the server's client certificate vector where this 1321 certificate should be stored. If there is already a certificate 1322 stored at this index, it will be overwritten. The index is one 1323 based, not zero based; zero is an invalid slot index. 1325 Proof: Cryptographic proof that the client has possession of the 1326 private key associated with the certificate. The format is a TLS 1327 digitally-signed element ([RFC5246], Section 4.7). The signature 1328 algorithm must be the same as that used in the CertificateVerify 1329 message. However, since the MD5+SHA1 signature type used in TLS 1.0 1330 connections can not be correctly encoded in a digitally-signed 1331 element, SHA1 must be used when MD5+SHA1 was used in the SSL 1332 connection. The signature is calculated over a 32 byte TLS extractor 1333 value (http://tools.ietf.org/html/rfc5705) with a label of "EXPORTER 1334 HTTP/2.0 certificate proof" using the empty string as context. 1335 ForRSA certificates the signature would be a PKCS#1 v1.5 signature. 1336 For ECDSA, it would be an ECDSA-Sig-Value 1337 (http://tools.ietf.org/html/rfc5480#appendix-A). For a 1024-bit RSA 1338 key, the CREDENTIAL message would be ~500 bytes. 1340 Certificate: The certificate chain, starting with the leaf 1341 certificate. Each certificate must be encoded as a 32 bit length, 1342 followed by a DER encoded certificate. The certificate must be of 1343 the same type (RSA, ECDSA, etc) as the client certificate associated 1344 with the SSL connection. 1346 If the server receives a request for a resource with unacceptable 1347 credential (either missing or invalid), it must reply with a 1348 RST_STREAM frame with the status code INVALID_CREDENTIALS. Upon 1349 receipt of a RST_STREAM frame with INVALID_CREDENTIALS, the client 1350 should initiate a new stream directly to the requested origin and 1351 resend the request. Note, HTTP/2.0 does not allow the server to 1352 request different client authentication for different resources in 1353 the same origin. 1355 If the server receives an invalid CREDENTIAL frame, it MUST respond 1356 with a GOAWAY frame and shutdown the session. 1358 3.6.10. Name/Value Header Block 1360 The Name/Value Header Block is found in the SYN_STREAM, SYN_REPLY and 1361 HEADERS control frames, and shares a common format: 1363 +------------------------------------+ 1364 | Number of Name/Value pairs (int32) | 1365 +------------------------------------+ 1366 | Length of name (int32) | 1367 +------------------------------------+ 1368 | Name (string) | 1369 +------------------------------------+ 1370 | Length of value (int32) | 1371 +------------------------------------+ 1372 | Value (string) | 1373 +------------------------------------+ 1374 | (repeats) | 1376 Number of Name/Value pairs: The number of repeating name/value pairs 1377 following this field. 1379 List of Name/Value pairs: 1381 Length of Name: a 32-bit value containing the number of octets in 1382 the name field. Note that in practice, this length must not 1383 exceed 2^24, as that is the maximum size of a HTTP/2.0 frame. 1385 Name: 0 or more octets, 8-bit sequences of data, excluding 0. 1387 Length of Value: a 32-bit value containing the number of octets in 1388 the value field. Note that in practice, this length must not 1389 exceed 2^24, as that is the maximum size of a HTTP/2.0 frame. 1391 Value: 0 or more octets, 8-bit sequences of data, excluding 0. 1393 Each header name must have at least one value. Header names are 1394 encoded using the US-ASCII character set [ASCII] and must be all 1395 lower case. The length of each name must be greater than zero. A 1396 recipient of a zero-length name MUST issue a stream error 1397 (Section 3.4.2) with the status code PROTOCOL_ERROR for the 1398 stream-id. 1400 Duplicate header names are not allowed. To send two identically 1401 named headers, send a header with two values, where the values are 1402 separated by a single NUL (0) byte. A header value can either be 1403 empty (e.g. the length is zero) or it can contain multiple, NUL- 1404 separated values, each with length greater than zero. The value 1405 never starts nor ends with a NUL character. Recipients of illegal 1406 value fields MUST issue a stream error (Section 3.4.2) with the 1407 status code PROTOCOL_ERROR for the stream-id. 1409 3.6.10.1. Compression 1411 The Name/Value Header Block is a section of the SYN_STREAM, 1412 SYN_REPLY, and HEADERS frames used to carry header meta-data. This 1413 block is always compressed using zlib compression. Within this 1414 specification, any reference to 'zlib' is referring to the ZLIB 1415 Compressed Data Format Specification Version 3.3 as part of RFC1950. 1416 [RFC1950] 1418 For each HEADERS compression instance, the initial state is 1419 initialized using the following dictionary [UDELCOMPRESSION]: 1421 1423 const unsigned char http2_dictionary_txt[] = { 1424 0x00, 0x00, 0x00, 0x07, 0x6f, 0x70, 0x74, 0x69, \\ - - - - o p t i 1425 0x6f, 0x6e, 0x73, 0x00, 0x00, 0x00, 0x04, 0x68, \\ o n s - - - - h 1426 0x65, 0x61, 0x64, 0x00, 0x00, 0x00, 0x04, 0x70, \\ e a d - - - - p 1427 0x6f, 0x73, 0x74, 0x00, 0x00, 0x00, 0x03, 0x70, \\ o s t - - - - p 1428 0x75, 0x74, 0x00, 0x00, 0x00, 0x06, 0x64, 0x65, \\ u t - - - - d e 1429 0x6c, 0x65, 0x74, 0x65, 0x00, 0x00, 0x00, 0x05, \\ l e t e - - - - 1430 0x74, 0x72, 0x61, 0x63, 0x65, 0x00, 0x00, 0x00, \\ t r a c e - - - 1431 0x06, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x00, \\ - a c c e p t - 1432 0x00, 0x00, 0x0e, 0x61, 0x63, 0x63, 0x65, 0x70, \\ - - - a c c e p 1433 0x74, 0x2d, 0x63, 0x68, 0x61, 0x72, 0x73, 0x65, \\ t - c h a r s e 1434 0x74, 0x00, 0x00, 0x00, 0x0f, 0x61, 0x63, 0x63, \\ t - - - - a c c 1435 0x65, 0x70, 0x74, 0x2d, 0x65, 0x6e, 0x63, 0x6f, \\ e p t - e n c o 1436 0x64, 0x69, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x0f, \\ d i n g - - - - 1437 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x2d, 0x6c, \\ a c c e p t - l 1438 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x00, \\ a n g u a g e - 1439 0x00, 0x00, 0x0d, 0x61, 0x63, 0x63, 0x65, 0x70, \\ - - - a c c e p 1440 0x74, 0x2d, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x73, \\ t - r a n g e s 1441 0x00, 0x00, 0x00, 0x03, 0x61, 0x67, 0x65, 0x00, \\ - - - - a g e - 1442 0x00, 0x00, 0x05, 0x61, 0x6c, 0x6c, 0x6f, 0x77, \\ - - - a l l o w 1443 0x00, 0x00, 0x00, 0x0d, 0x61, 0x75, 0x74, 0x68, \\ - - - - a u t h 1444 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, \\ o r i z a t i o 1445 0x6e, 0x00, 0x00, 0x00, 0x0d, 0x63, 0x61, 0x63, \\ n - - - - c a c 1446 0x68, 0x65, 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72, \\ h e - c o n t r 1447 0x6f, 0x6c, 0x00, 0x00, 0x00, 0x0a, 0x63, 0x6f, \\ o l - - - - c o 1448 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, \\ n n e c t i o n 1449 0x00, 0x00, 0x00, 0x0c, 0x63, 0x6f, 0x6e, 0x74, \\ - - - - c o n t 1450 0x65, 0x6e, 0x74, 0x2d, 0x62, 0x61, 0x73, 0x65, \\ e n t - b a s e 1451 0x00, 0x00, 0x00, 0x10, 0x63, 0x6f, 0x6e, 0x74, \\ - - - - c o n t 1452 0x65, 0x6e, 0x74, 0x2d, 0x65, 0x6e, 0x63, 0x6f, \\ e n t - e n c o 1453 0x64, 0x69, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x10, \\ d i n g - - - - 1454 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, \\ c o n t e n t - 1455 0x6c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, \\ l a n g u a g e 1456 0x00, 0x00, 0x00, 0x0e, 0x63, 0x6f, 0x6e, 0x74, \\ - - - - c o n t 1457 0x65, 0x6e, 0x74, 0x2d, 0x6c, 0x65, 0x6e, 0x67, \\ e n t - l e n g 1458 0x74, 0x68, 0x00, 0x00, 0x00, 0x10, 0x63, 0x6f, \\ t h - - - - c o 1459 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x6c, 0x6f, \\ n t e n t - l o 1460 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, \\ c a t i o n - - 1461 0x00, 0x0b, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, \\ - - c o n t e n 1462 0x74, 0x2d, 0x6d, 0x64, 0x35, 0x00, 0x00, 0x00, \\ t - m d 5 - - - 1463 0x0d, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, \\ - c o n t e n t 1464 0x2d, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x00, 0x00, \\ - r a n g e - - 1465 0x00, 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, \\ - - c o n t e n 1466 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x00, 0x00, \\ t - t y p e - - 1467 0x00, 0x04, 0x64, 0x61, 0x74, 0x65, 0x00, 0x00, \\ - - d a t e - - 1468 0x00, 0x04, 0x65, 0x74, 0x61, 0x67, 0x00, 0x00, \\ - - e t a g - - 1469 0x00, 0x06, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, \\ - - e x p e c t 1470 0x00, 0x00, 0x00, 0x07, 0x65, 0x78, 0x70, 0x69, \\ - - - - e x p i 1471 0x72, 0x65, 0x73, 0x00, 0x00, 0x00, 0x04, 0x66, \\ r e s - - - - f 1472 0x72, 0x6f, 0x6d, 0x00, 0x00, 0x00, 0x04, 0x68, \\ r o m - - - - h 1473 0x6f, 0x73, 0x74, 0x00, 0x00, 0x00, 0x08, 0x69, \\ o s t - - - - i 1474 0x66, 0x2d, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x00, \\ f - m a t c h - 1475 0x00, 0x00, 0x11, 0x69, 0x66, 0x2d, 0x6d, 0x6f, \\ - - - i f - m o 1476 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x2d, 0x73, \\ d i f i e d - s 1477 0x69, 0x6e, 0x63, 0x65, 0x00, 0x00, 0x00, 0x0d, \\ i n c e - - - - 1478 0x69, 0x66, 0x2d, 0x6e, 0x6f, 0x6e, 0x65, 0x2d, \\ i f - n o n e - 1479 0x6d, 0x61, 0x74, 0x63, 0x68, 0x00, 0x00, 0x00, \\ m a t c h - - - 1480 0x08, 0x69, 0x66, 0x2d, 0x72, 0x61, 0x6e, 0x67, \\ - i f - r a n g 1481 0x65, 0x00, 0x00, 0x00, 0x13, 0x69, 0x66, 0x2d, \\ e - - - - i f - 1482 0x75, 0x6e, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, \\ u n m o d i f i 1483 0x65, 0x64, 0x2d, 0x73, 0x69, 0x6e, 0x63, 0x65, \\ e d - s i n c e 1484 0x00, 0x00, 0x00, 0x0d, 0x6c, 0x61, 0x73, 0x74, \\ - - - - l a s t 1485 0x2d, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, \\ - m o d i f i e 1486 0x64, 0x00, 0x00, 0x00, 0x08, 0x6c, 0x6f, 0x63, \\ d - - - - l o c 1487 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00, \\ a t i o n - - - 1488 0x0c, 0x6d, 0x61, 0x78, 0x2d, 0x66, 0x6f, 0x72, \\ - m a x - f o r 1489 0x77, 0x61, 0x72, 0x64, 0x73, 0x00, 0x00, 0x00, \\ w a r d s - - - 1490 0x06, 0x70, 0x72, 0x61, 0x67, 0x6d, 0x61, 0x00, \\ - p r a g m a - 1491 0x00, 0x00, 0x12, 0x70, 0x72, 0x6f, 0x78, 0x79, \\ - - - p r o x y 1492 0x2d, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, \\ - a u t h e n t 1493 0x69, 0x63, 0x61, 0x74, 0x65, 0x00, 0x00, 0x00, \\ i c a t e - - - 1494 0x13, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2d, 0x61, \\ - p r o x y - a 1495 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, \\ u t h o r i z a 1496 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00, 0x05, \\ t i o n - - - - 1497 0x72, 0x61, 0x6e, 0x67, 0x65, 0x00, 0x00, 0x00, \\ r a n g e - - - 1498 0x07, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x72, \\ - r e f e r e r 1499 0x00, 0x00, 0x00, 0x0b, 0x72, 0x65, 0x74, 0x72, \\ - - - - r e t r 1500 0x79, 0x2d, 0x61, 0x66, 0x74, 0x65, 0x72, 0x00, \\ y - a f t e r - 1501 0x00, 0x00, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, \\ - - - s e r v e 1502 0x72, 0x00, 0x00, 0x00, 0x02, 0x74, 0x65, 0x00, \\ r - - - - t e - 1503 0x00, 0x00, 0x07, 0x74, 0x72, 0x61, 0x69, 0x6c, \\ - - - t r a i l 1504 0x65, 0x72, 0x00, 0x00, 0x00, 0x11, 0x74, 0x72, \\ e r - - - - t r 1505 0x61, 0x6e, 0x73, 0x66, 0x65, 0x72, 0x2d, 0x65, \\ a n s f e r - e 1506 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x00, \\ n c o d i n g - 1507 0x00, 0x00, 0x07, 0x75, 0x70, 0x67, 0x72, 0x61, \\ - - - u p g r a 1508 0x64, 0x65, 0x00, 0x00, 0x00, 0x0a, 0x75, 0x73, \\ d e - - - - u s 1509 0x65, 0x72, 0x2d, 0x61, 0x67, 0x65, 0x6e, 0x74, \\ e r - a g e n t 1510 0x00, 0x00, 0x00, 0x04, 0x76, 0x61, 0x72, 0x79, \\ - - - - v a r y 1511 0x00, 0x00, 0x00, 0x03, 0x76, 0x69, 0x61, 0x00, \\ - - - - v i a - 1512 0x00, 0x00, 0x07, 0x77, 0x61, 0x72, 0x6e, 0x69, \\ - - - w a r n i 1513 0x6e, 0x67, 0x00, 0x00, 0x00, 0x10, 0x77, 0x77, \\ n g - - - - w w 1514 0x77, 0x2d, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, \\ w - a u t h e n 1515 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x00, 0x00, \\ t i c a t e - - 1516 0x00, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, \\ - - m e t h o d 1517 0x00, 0x00, 0x00, 0x03, 0x67, 0x65, 0x74, 0x00, \\ - - - - g e t - 1518 0x00, 0x00, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, \\ - - - s t a t u 1519 0x73, 0x00, 0x00, 0x00, 0x06, 0x32, 0x30, 0x30, \\ s - - - - 2 0 0 1520 0x20, 0x4f, 0x4b, 0x00, 0x00, 0x00, 0x07, 0x76, \\ - O K - - - - v 1521 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x00, 0x00, \\ e r s i o n - - 1522 0x00, 0x08, 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, \\ - - H T T P - 1 1523 0x2e, 0x31, 0x00, 0x00, 0x00, 0x03, 0x75, 0x72, \\ - 1 - - - - u r 1524 0x6c, 0x00, 0x00, 0x00, 0x06, 0x70, 0x75, 0x62, \\ l - - - - p u b 1525 0x6c, 0x69, 0x63, 0x00, 0x00, 0x00, 0x0a, 0x73, \\ l i c - - - - s 1526 0x65, 0x74, 0x2d, 0x63, 0x6f, 0x6f, 0x6b, 0x69, \\ e t - c o o k i 1527 0x65, 0x00, 0x00, 0x00, 0x0a, 0x6b, 0x65, 0x65, \\ e - - - - k e e 1528 0x70, 0x2d, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x00, \\ p - a l i v e - 1529 0x00, 0x00, 0x06, 0x6f, 0x72, 0x69, 0x67, 0x69, \\ - - - o r i g i 1530 0x6e, 0x31, 0x30, 0x30, 0x31, 0x30, 0x31, 0x32, \\ n 1 0 0 1 0 1 2 1531 0x30, 0x31, 0x32, 0x30, 0x32, 0x32, 0x30, 0x35, \\ 0 1 2 0 2 2 0 5 1532 0x32, 0x30, 0x36, 0x33, 0x30, 0x30, 0x33, 0x30, \\ 2 0 6 3 0 0 3 0 1533 0x32, 0x33, 0x30, 0x33, 0x33, 0x30, 0x34, 0x33, \\ 2 3 0 3 3 0 4 3 1534 0x30, 0x35, 0x33, 0x30, 0x36, 0x33, 0x30, 0x37, \\ 0 5 3 0 6 3 0 7 1535 0x34, 0x30, 0x32, 0x34, 0x30, 0x35, 0x34, 0x30, \\ 4 0 2 4 0 5 4 0 1536 0x36, 0x34, 0x30, 0x37, 0x34, 0x30, 0x38, 0x34, \\ 6 4 0 7 4 0 8 4 1537 0x30, 0x39, 0x34, 0x31, 0x30, 0x34, 0x31, 0x31, \\ 0 9 4 1 0 4 1 1 1538 0x34, 0x31, 0x32, 0x34, 0x31, 0x33, 0x34, 0x31, \\ 4 1 2 4 1 3 4 1 1539 0x34, 0x34, 0x31, 0x35, 0x34, 0x31, 0x36, 0x34, \\ 4 4 1 5 4 1 6 4 1540 0x31, 0x37, 0x35, 0x30, 0x32, 0x35, 0x30, 0x34, \\ 1 7 5 0 2 5 0 4 1541 0x35, 0x30, 0x35, 0x32, 0x30, 0x33, 0x20, 0x4e, \\ 5 0 5 2 0 3 - N 1542 0x6f, 0x6e, 0x2d, 0x41, 0x75, 0x74, 0x68, 0x6f, \\ o n - A u t h o 1543 0x72, 0x69, 0x74, 0x61, 0x74, 0x69, 0x76, 0x65, \\ r i t a t i v e 1544 0x20, 0x49, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, \\ - I n f o r m a 1545 0x74, 0x69, 0x6f, 0x6e, 0x32, 0x30, 0x34, 0x20, \\ t i o n 2 0 4 - 1546 0x4e, 0x6f, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x65, \\ N o - C o n t e 1547 0x6e, 0x74, 0x33, 0x30, 0x31, 0x20, 0x4d, 0x6f, \\ n t 3 0 1 - M o 1548 0x76, 0x65, 0x64, 0x20, 0x50, 0x65, 0x72, 0x6d, \\ v e d - P e r m 1549 0x61, 0x6e, 0x65, 0x6e, 0x74, 0x6c, 0x79, 0x34, \\ a n e n t l y 4 1550 0x30, 0x30, 0x20, 0x42, 0x61, 0x64, 0x20, 0x52, \\ 0 0 - B a d - R 1551 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x34, 0x30, \\ e q u e s t 4 0 1552 0x31, 0x20, 0x55, 0x6e, 0x61, 0x75, 0x74, 0x68, \\ 1 - U n a u t h 1553 0x6f, 0x72, 0x69, 0x7a, 0x65, 0x64, 0x34, 0x30, \\ o r i z e d 4 0 1554 0x33, 0x20, 0x46, 0x6f, 0x72, 0x62, 0x69, 0x64, \\ 3 - F o r b i d 1555 0x64, 0x65, 0x6e, 0x34, 0x30, 0x34, 0x20, 0x4e, \\ d e n 4 0 4 - N 1556 0x6f, 0x74, 0x20, 0x46, 0x6f, 0x75, 0x6e, 0x64, \\ o t - F o u n d 1557 0x35, 0x30, 0x30, 0x20, 0x49, 0x6e, 0x74, 0x65, \\ 5 0 0 - I n t e 1558 0x72, 0x6e, 0x61, 0x6c, 0x20, 0x53, 0x65, 0x72, \\ r n a l - S e r 1559 0x76, 0x65, 0x72, 0x20, 0x45, 0x72, 0x72, 0x6f, \\ v e r - E r r o 1560 0x72, 0x35, 0x30, 0x31, 0x20, 0x4e, 0x6f, 0x74, \\ r 5 0 1 - N o t 1561 0x20, 0x49, 0x6d, 0x70, 0x6c, 0x65, 0x6d, 0x65, \\ - I m p l e m e 1562 0x6e, 0x74, 0x65, 0x64, 0x35, 0x30, 0x33, 0x20, \\ n t e d 5 0 3 - 1563 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x20, \\ S e r v i c e - 1564 0x55, 0x6e, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, \\ U n a v a i l a 1565 0x62, 0x6c, 0x65, 0x4a, 0x61, 0x6e, 0x20, 0x46, \\ b l e J a n - F 1566 0x65, 0x62, 0x20, 0x4d, 0x61, 0x72, 0x20, 0x41, \\ e b - M a r - A 1567 0x70, 0x72, 0x20, 0x4d, 0x61, 0x79, 0x20, 0x4a, \\ p r - M a y - J 1568 0x75, 0x6e, 0x20, 0x4a, 0x75, 0x6c, 0x20, 0x41, \\ u n - J u l - A 1569 0x75, 0x67, 0x20, 0x53, 0x65, 0x70, 0x74, 0x20, \\ u g - S e p t - 1570 0x4f, 0x63, 0x74, 0x20, 0x4e, 0x6f, 0x76, 0x20, \\ O c t - N o v - 1571 0x44, 0x65, 0x63, 0x20, 0x30, 0x30, 0x3a, 0x30, \\ D e c - 0 0 - 0 1572 0x30, 0x3a, 0x30, 0x30, 0x20, 0x4d, 0x6f, 0x6e, \\ 0 - 0 0 - M o n 1573 0x2c, 0x20, 0x54, 0x75, 0x65, 0x2c, 0x20, 0x57, \\ - - T u e - - W 1574 0x65, 0x64, 0x2c, 0x20, 0x54, 0x68, 0x75, 0x2c, \\ e d - - T h u - 1575 0x20, 0x46, 0x72, 0x69, 0x2c, 0x20, 0x53, 0x61, \\ - F r i - - S a 1576 0x74, 0x2c, 0x20, 0x53, 0x75, 0x6e, 0x2c, 0x20, \\ t - - S u n - - 1577 0x47, 0x4d, 0x54, 0x63, 0x68, 0x75, 0x6e, 0x6b, \\ G M T c h u n k 1578 0x65, 0x64, 0x2c, 0x74, 0x65, 0x78, 0x74, 0x2f, \\ e d - t e x t - 1579 0x68, 0x74, 0x6d, 0x6c, 0x2c, 0x69, 0x6d, 0x61, \\ h t m l - i m a 1580 0x67, 0x65, 0x2f, 0x70, 0x6e, 0x67, 0x2c, 0x69, \\ g e - p n g - i 1581 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x6a, 0x70, 0x67, \\ m a g e - j p g 1582 0x2c, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x67, \\ - i m a g e - g 1583 0x69, 0x66, 0x2c, 0x61, 0x70, 0x70, 0x6c, 0x69, \\ i f - a p p l i 1584 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x78, \\ c a t i o n - x 1585 0x6d, 0x6c, 0x2c, 0x61, 0x70, 0x70, 0x6c, 0x69, \\ m l - a p p l i 1586 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x78, \\ c a t i o n - x 1587 0x68, 0x74, 0x6d, 0x6c, 0x2b, 0x78, 0x6d, 0x6c, \\ h t m l - x m l 1588 0x2c, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x70, 0x6c, \\ - t e x t - p l 1589 0x61, 0x69, 0x6e, 0x2c, 0x74, 0x65, 0x78, 0x74, \\ a i n - t e x t 1590 0x2f, 0x6a, 0x61, 0x76, 0x61, 0x73, 0x63, 0x72, \\ - j a v a s c r 1591 0x69, 0x70, 0x74, 0x2c, 0x70, 0x75, 0x62, 0x6c, \\ i p t - p u b l 1592 0x69, 0x63, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, \\ i c p r i v a t 1593 0x65, 0x6d, 0x61, 0x78, 0x2d, 0x61, 0x67, 0x65, \\ e m a x - a g e 1594 0x3d, 0x67, 0x7a, 0x69, 0x70, 0x2c, 0x64, 0x65, \\ - g z i p - d e 1595 0x66, 0x6c, 0x61, 0x74, 0x65, 0x2c, 0x73, 0x64, \\ f l a t e - s d 1596 0x63, 0x68, 0x63, 0x68, 0x61, 0x72, 0x73, 0x65, \\ c h c h a r s e 1597 0x74, 0x3d, 0x75, 0x74, 0x66, 0x2d, 0x38, 0x63, \\ t - u t f - 8 c 1598 0x68, 0x61, 0x72, 0x73, 0x65, 0x74, 0x3d, 0x69, \\ h a r s e t - i 1599 0x73, 0x6f, 0x2d, 0x38, 0x38, 0x35, 0x39, 0x2d, \\ s o - 8 8 5 9 - 1600 0x31, 0x2c, 0x75, 0x74, 0x66, 0x2d, 0x2c, 0x2a, \\ 1 - u t f - - - 1601 0x2c, 0x65, 0x6e, 0x71, 0x3d, 0x30, 0x2e \\ - e n q - 0 - 1602 }; 1604 1606 The entire contents of the name/value header block is compressed 1607 using zlib. There is a single zlib stream for all name value pairs 1608 in one direction on a connection. HTTP/2.0 uses a SYNC_FLUSH between 1609 each compressed frame. 1611 Implementation notes: the compression engine can be tuned to favor 1612 speed or size. Optimizing for size increases memory use and CPU 1613 consumption. Because header blocks are generally small, implementors 1614 may want to reduce the window-size of the compression engine from the 1615 default 15bits (a 32KB window) to more like 11bits (a 2KB window). 1616 The exact setting is chosen by the compressor, the decompressor will 1617 work with any setting. 1619 4. HTTP Layering over HTTP/2.0 1621 HTTP/2.0 is intended to be as compatible as possible with current 1622 web-based applications. This means that, from the perspective of the 1623 server business logic or application API, the features of HTTP are 1624 unchanged. To achieve this, all of the application request and 1625 response header semantics are preserved, although the syntax of 1626 conveying those semantics has changed. Thus, the rules from the 1627 HTTP/1.1 specification in RFC2616 [RFC2616] apply with the changes in 1628 the sections below. 1630 4.1. Connection Management 1632 Clients SHOULD NOT open more than one HTTP/2.0 session to a given 1633 origin [RFC6454] concurrently. 1635 Note that it is possible for one HTTP/2.0 session to be finishing 1636 (e.g. a GOAWAY message has been sent, but not all streams have 1637 finished), while another HTTP/2.0 session is starting. 1639 4.1.1. Use of GOAWAY 1641 HTTP/2.0 provides a GOAWAY message which can be used when closing a 1642 connection from either the client or server. Without a server GOAWAY 1643 message, HTTP has a race condition where the client sends a request 1644 (a new SYN_STREAM) just as the server is closing the connection, and 1645 the client cannot know if the server received the stream or not. By 1646 using the last-stream-id in the GOAWAY, servers can indicate to the 1647 client if a request was processed or not. 1649 Note that some servers will choose to send the GOAWAY and immediately 1650 terminate the connection without waiting for active streams to 1651 finish. The client will be able to determine this because HTTP/2.0 1652 streams are determinstically closed. This abrupt termination will 1653 force the client to heuristically decide whether to retry the pending 1654 requests. Clients always need to be capable of dealing with this 1655 case because they must deal with accidental connection termination 1656 cases, which are the same as the server never having sent a GOAWAY. 1658 More sophisticated servers will use GOAWAY to implement a graceful 1659 teardown. They will send the GOAWAY and provide some time for the 1660 active streams to finish before terminating the connection. 1662 If a HTTP/2.0 client closes the connection, it should also send a 1663 GOAWAY message. This allows the server to know if any server-push 1664 streams were received by the client. 1666 If the endpoint closing the connection has not received any 1667 SYN_STREAMs from the remote, the GOAWAY will contain a last-stream-id 1668 of 0. 1670 4.2. HTTP Request/Response 1672 4.2.1. Request 1674 The client initiates a request by sending a SYN_STREAM frame. For 1675 requests which do not contain a body, the SYN_STREAM frame MUST set 1676 the FLAG_FIN, indicating that the client intends to send no further 1677 data on this stream. For requests which do contain a body, the 1678 SYN_STREAM will not contain the FLAG_FIN, and the body will follow 1679 the SYN_STREAM in a series of DATA frames. The last DATA frame will 1680 set the FLAG_FIN to indicate the end of the body. 1682 The SYN_STREAM Name/Value section will contain all of the HTTP 1683 headers which are associated with an HTTP request. The header block 1684 in HTTP/2.0 is mostly unchanged from today's HTTP header block, with 1685 the following differences: 1687 The first line of the request is unfolded into name/value pairs 1688 like other HTTP headers and MUST be present: 1690 ":method" - the HTTP method for this request (e.g. "GET", 1691 "POST", "HEAD", etc) 1693 ":path" - the url-path for this url with "/" prefixed. (See 1694 RFC1738 [RFC1738]). For example, for 1695 "http://www.google.com/search?q=dogs" the path would be 1696 "/search?q=dogs". 1698 ":version" - the HTTP version of this request (e.g. 1699 "HTTP/1.1") 1701 In addition, the following two name/value pairs must also be 1702 present in every request: 1704 ":host" - the hostport (See RFC1738 [RFC1738]) portion of the 1705 URL for this request (e.g. "www.google.com:1234"). This header 1706 is the same as the HTTP 'Host' header. 1708 ":scheme" - the scheme portion of the URL for this request 1709 (e.g. "https")) 1711 Header names are all lowercase. 1713 The Connection, Host, Keep-Alive, Proxy-Connection, and Transfer- 1714 Encoding headers are not valid and MUST not be sent. 1716 User-agents MUST support gzip compression. Regardless of the 1717 Accept-Encoding sent by the user-agent, the server may always send 1718 content encoded with gzip or deflate encoding. 1720 If a server receives a request where the sum of the data frame 1721 payload lengths does not equal the size of the Content-Length 1722 header, the server MUST return a 400 (Bad Request) error. 1724 POST-specific changes: 1726 Although POSTs are inherently chunked, POST requests SHOULD 1727 also be accompanied by a Content-Length header. There are two 1728 reasons for this: First, it assists with upload progress meters 1729 for an improved user experience. But second, we know from 1730 early versions of HTTP/2.0 that failure to send a content 1731 length header is incompatible with many existing HTTP server 1732 implementations. Existing user-agents do not omit the Content- 1733 Length header, and server implementations have come to depend 1734 upon this. 1736 The user-agent is free to prioritize requests as it sees fit. If the 1737 user-agent cannot make progress without receiving a resource, it 1738 should attempt to raise the priority of that resource. Resources 1739 such as images, SHOULD generally use the lowest priority. 1741 If a client sends a SYN_STREAM without all of the method, host, path, 1742 scheme, and version headers, the server MUST reply with a HTTP 400 1743 Bad Request reply. 1745 4.2.2. Response 1747 The server responds to a client request with a SYN_REPLY frame. 1748 Symmetric to the client's upload stream, server will send data after 1749 the SYN_REPLY frame via a series of DATA frames, and the last data 1750 frame will contain the FLAG_FIN to indicate successful end-of-stream. 1751 If a response (like a 202 or 204 response) contains no body, the 1752 SYN_REPLY frame may contain the FLAG_FIN flag to indicate no further 1753 data will be sent on the stream. 1755 The response status line is unfolded into name/value pairs like 1756 other HTTP headers and must be present: 1758 ":status" - The HTTP response status code (e.g. "200" or "200 1759 OK") 1761 ":version" - The HTTP response version (e.g. "HTTP/1.1") 1763 All header names must be lowercase. 1765 The Connection, Keep-Alive, Proxy-Connection, and Transfer- 1766 Encoding headers are not valid and MUST not be sent. 1768 Responses MAY be accompanied by a Content-Length header for 1769 advisory purposes. (e.g. for UI progress meters) 1771 If a client receives a response where the sum of the data frame 1772 payload lengths does not equal the size of the Content-Length 1773 header, the client MUST ignore the content length header. 1775 If a client receives a SYN_REPLY without a status or without a 1776 version header, the client must reply with a RST_STREAM frame 1777 indicating a PROTOCOL ERROR. 1779 4.2.3. Authentication 1781 When a client sends a request to an origin server that requires 1782 authentication, the server can reply with a "401 Unauthorized" 1783 response, and include a WWW-Authenticate challenge header that 1784 defines the authentication scheme to be used. The client then 1785 retries the request with an Authorization header appropriate to the 1786 specified authentication scheme. 1788 There are four options for proxy authentication, Basic, Digest, NTLM 1789 and Negotiate (SPNEGO). The first two options were defined in 1790 RFC2617 [RFC2617], and are stateless. The second two options were 1791 developed by Microsoft and specified in RFC4559 [RFC4559], and are 1792 stateful; otherwise known as multi-round authentication, or 1793 connection authentication. 1795 4.2.3.1. Stateless Authentication 1797 Stateless Authentication over HTTP/2.0 is identical to how it is 1798 performed over HTTP. If multiple HTTP/2.0 streams are concurrently 1799 sent to a single server, each will authenticate independently, 1800 similar to how two HTTP connections would independently authenticate 1801 to a proxy server. 1803 4.2.3.2. Stateful Authentication 1805 Unfortunately, the stateful authentication mechanisms were 1806 implemented and defined in a such a way that directly violates 1807 RFC2617 - they do not include a "realm" as part of the request. This 1808 is problematic in HTTP/2.0 because it makes it impossible for a 1809 client to disambiguate two concurrent server authentication 1810 challenges. 1812 To deal with this case, HTTP/2.0 servers using Stateful 1813 Authentication MUST implement one of two changes: 1815 Servers can add a "realm=" header so that the two 1816 authentication requests can be disambiguated and run concurrently. 1817 Unfortunately, given how these mechanisms work, this is probably 1818 not practical. 1820 Upon sending the first stateful challenge response, the server 1821 MUST buffer and defer all further frames which are not part of 1822 completing the challenge until the challenge has completed. 1823 Completing the authentication challenge may take multiple round 1824 trips. Once the client receives a "401 Authenticate" response for 1825 a stateful authentication type, it MUST stop sending new requests 1826 to the server until the authentication has completed by receiving 1827 a non-401 response on at least one stream. 1829 4.3. Server Push Transactions 1831 HTTP/2.0 enables a server to send multiple replies to a client for a 1832 single request. The rationale for this feature is that sometimes a 1833 server knows that it will need to send multiple resources in response 1834 to a single request. Without server push features, the client must 1835 first download the primary resource, then discover the secondary 1836 resource(s), and request them. Pushing of resources avoids the 1837 round-trip delay, but also creates a potential race where a server 1838 can be pushing content which a user-agent is in the process of 1839 requesting. The following mechanics attempt to prevent the race 1840 condition while enabling the performance benefit. 1842 Browsers receiving a pushed response MUST validate that the server is 1843 authorized to push the URL using the browser same-origin [RFC6454] 1844 policy. For example, a HTTP/2.0 connection to www.foo.com is 1845 generally not permitted to push a response for www.evil.com. 1847 If the browser accepts a pushed response (e.g. it does not send a 1848 RST_STREAM), the browser MUST attempt to cache the pushed response in 1849 same way that it would cache any other response. This means 1850 validating the response headers and inserting into the disk cache. 1852 Because pushed responses have no request, they have no request 1853 headers associated with them. At the framing layer, HTTP/2.0 pushed 1854 streams contain an "associated-stream-id" which indicates the 1855 requested stream for which the pushed stream is related. The pushed 1856 stream inherits all of the headers from the associated-stream-id with 1857 the exception of ":host", ":scheme", and ":path", which are provided 1858 as part of the pushed response stream headers. The browser MUST 1859 store these inherited and implied request headers with the cached 1860 resource. 1862 Implementation note: With server push, it is theoretically possible 1863 for servers to push unreasonable amounts of content or resources to 1864 the user-agent. Browsers MUST implement throttles to protect against 1865 unreasonable push attacks. 1867 4.3.1. Server implementation 1869 When the server intends to push a resource to the user-agent, it 1870 opens a new stream by sending a unidirectional SYN_STREAM. The 1871 SYN_STREAM MUST include an Associated-To-Stream-ID, and MUST set the 1872 FLAG_UNIDIRECTIONAL flag. The SYN_STREAM MUST include headers for 1873 ":scheme", ":host", ":path", which represent the URL for the resource 1874 being pushed. Subsequent headers may follow in HEADERS frames. The 1875 purpose of the association is so that the user-agent can 1876 differentiate which request induced the pushed stream; without it, if 1877 the user-agent had two tabs open to the same page, each pushing 1878 unique content under a fixed URL, the user-agent would not be able to 1879 differentiate the requests. 1881 The Associated-To-Stream-ID must be the ID of an existing, open 1882 stream. The reason for this restriction is to have a clear endpoint 1883 for pushed content. If the user-agent requested a resource on stream 1884 11, the server replies on stream 11. It can push any number of 1885 additional streams to the client before sending a FLAG_FIN on stream 1886 11. However, once the originating stream is closed no further push 1887 streams may be associated with it. The pushed streams do not need to 1888 be closed (FIN set) before the originating stream is closed, they 1889 only need to be created before the originating stream closes. 1891 It is illegal for a server to push a resource with the Associated-To- 1892 Stream-ID of 0. 1894 To minimize race conditions with the client, the SYN_STREAM for the 1895 pushed resources MUST be sent prior to sending any content which 1896 could allow the client to discover the pushed resource and request 1897 it. 1899 The server MUST only push resources which would have been returned 1900 from a GET request. 1902 Note: If the server does not have all of the Name/Value Response 1903 headers available at the time it issues the HEADERS frame for the 1904 pushed resource, it may later use an additional HEADERS frame to 1905 augment the name/value pairs to be associated with the pushed stream. 1906 The subsequent HEADERS frame(s) must not contain a header for 1907 ':host', ':scheme', or ':path' (e.g. the server can't change the 1908 identity of the resource to be pushed). The HEADERS frame must not 1909 contain duplicate headers with a previously sent HEADERS frame. The 1910 server must send a HEADERS frame including the scheme/host/port 1911 headers before sending any data frames on the stream. 1913 4.3.2. Client implementation 1915 When fetching a resource the client has 3 possibilities: 1917 the resource is not being pushed 1919 the resource is being pushed, but the data has not yet arrived 1921 the resource is being pushed, and the data has started to arrive 1923 When a SYN_STREAM and HEADERS frame which contains an Associated-To- 1924 Stream-ID is received, the client must not issue GET requests for the 1925 resource in the pushed stream, and instead wait for the pushed stream 1926 to arrive. 1928 If a client receives a server push stream with stream-id 0, it MUST 1929 issue a session error (Section 3.4.1) with the status code 1930 PROTOCOL_ERROR. 1932 When a client receives a SYN_STREAM from the server without a the 1933 ':host', ':scheme', and ':path' headers in the Name/Value section, it 1934 MUST reply with a RST_STREAM with error code HTTP_PROTOCOL_ERROR. 1936 To cancel individual server push streams, the client can issue a 1937 stream error (Section 3.4.2) with error code CANCEL. Upon receipt, 1938 the server MUST stop sending on this stream immediately (this is an 1939 Abrupt termination). 1941 To cancel all server push streams related to a request, the client 1942 may issue a stream error (Section 3.4.2) with error code CANCEL on 1943 the associated-stream-id. By cancelling that stream, the server MUST 1944 immediately stop sending frames for any streams with 1945 in-association-to for the original stream. 1947 If the server sends a HEADER frame containing duplicate headers with 1948 a previous HEADERS frame for the same stream, the client must issue a 1949 stream error (Section 3.4.2) with error code PROTOCOL ERROR. 1951 If the server sends a HEADERS frame after sending a data frame for 1952 the same stream, the client MAY ignore the HEADERS frame. Ignoring 1953 the HEADERS frame after a data frame prevents handling of HTTP's 1954 trailing headers 1955 (http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.40). 1957 5. Design Rationale and Notes 1959 Authors' notes: The notes in this section have no bearing on the 1960 HTTP/2.0 protocol as specified within this document, and none of 1961 these notes should be considered authoritative about how the protocol 1962 works. However, these notes may prove useful in future debates about 1963 how to resolve protocol ambiguities or how to evolve the protocol 1964 going forward. They may be removed before the final draft. 1966 5.1. Separation of Framing Layer and Application Layer 1968 Readers may note that this specification sometimes blends the framing 1969 layer (Section 3) with requirements of a specific application - HTTP 1970 (Section 4). This is reflected in the request/response nature of the 1971 streams, the definition of the HEADERS and compression contexts which 1972 are very similar to HTTP, and other areas as well. 1974 This blending is intentional - the primary goal of this protocol is 1975 to create a low-latency protocol for use with HTTP. Isolating the 1976 two layers is convenient for description of the protocol and how it 1977 relates to existing HTTP implementations. However, the ability to 1978 reuse the HTTP/2.0 framing layer is a non goal. 1980 5.2. Error handling - Framing Layer 1982 Error handling at the HTTP/2.0 layer splits errors into two groups: 1983 Those that affect an individual HTTP/2.0 stream, and those that do 1984 not. 1986 When an error is confined to a single stream, but general framing is 1987 in tact, HTTP/2.0 attempts to use the RST_STREAM as a mechanism to 1988 invalidate the stream but move forward without aborting the 1989 connection altogether. 1991 For errors occuring outside of a single stream context, HTTP/2.0 1992 assumes the entire session is hosed. In this case, the endpoint 1993 detecting the error should initiate a connection close. 1995 5.3. One Connection Per Domain 1997 HTTP/2.0 attempts to use fewer connections than other protocols have 1998 traditionally used. The rationale for this behavior is because it is 1999 very difficult to provide a consistent level of service (e.g. TCP 2000 slow-start), prioritization, or optimal compression when the client 2001 is connecting to the server through multiple channels. 2003 Through lab measurements, we have seen consistent latency benefits by 2004 using fewer connections from the client. The overall number of 2005 packets sent by HTTP/2.0 can be as much as 40% less than HTTP. 2006 Handling large numbers of concurrent connections on the server also 2007 does become a scalability problem, and HTTP/2.0 reduces this load. 2009 The use of multiple connections is not without benefit, however. 2010 Because HTTP/2.0 multiplexes multiple, independent streams onto a 2011 single stream, it creates a potential for head-of-line blocking 2012 problems at the transport level. In tests so far, the negative 2013 effects of head-of-line blocking (especially in the presence of 2014 packet loss) is outweighed by the benefits of compression and 2015 prioritization. 2017 5.4. Fixed vs Variable Length Fields 2019 HTTP/2.0 favors use of fixed length 32bit fields in cases where 2020 smaller, variable length encodings could have been used. To some, 2021 this seems like a tragic waste of bandwidth. HTTP/2.0 choses the 2022 simple encoding for speed and simplicity. 2024 The goal of HTTP/2.0 is to reduce latency on the network. The 2025 overhead of HTTP/2.0 frames is generally quite low. Each data frame 2026 is only an 8 byte overhead for a 1452 byte payload (~0.6%). At the 2027 time of this writing, bandwidth is already plentiful, and there is a 2028 strong trend indicating that bandwidth will continue to increase. 2029 With an average worldwide bandwidth of 1Mbps, and assuming that a 2030 variable length encoding could reduce the overhead by 50%, the 2031 latency saved by using a variable length encoding would be less than 2032 100 nanoseconds. More interesting are the effects when the larger 2033 encodings force a packet boundary, in which case a round-trip could 2034 be induced. However, by addressing other aspects of HTTP/2.0 and TCP 2035 interactions, we believe this is completely mitigated. 2037 5.5. Compression Context(s) 2039 When isolating the compression contexts used for communicating with 2040 multiple origins, we had a few choices to make. We could have 2041 maintained a map (or list) of compression contexts usable for each 2042 origin. The basic case is easy - each HEADERS frame would need to 2043 identify the context to use for that frame. However, compression 2044 contexts are not cheap, so the lifecycle of each context would need 2045 to be bounded. For proxy servers, where we could churn through many 2046 contexts, this would be a concern. We considered using a static set 2047 of contexts, say 16 of them, which would bound the memory use. We 2048 also considered dynamic contexts, which could be created on the fly, 2049 and would need to be subsequently destroyed. All of these are 2050 complicated, and ultimately we decided that such a mechanism creates 2051 too many problems to solve. 2053 Alternatively, we've chosen the simple approach, which is to simply 2054 provide a flag for resetting the compression context. For the common 2055 case (no proxy), this fine because most requests are to the same 2056 origin and we never need to reset the context. For cases where we 2057 are using two different origins over a single HTTP/2.0 session, we 2058 simply reset the compression state between each transition. 2060 5.6. Unidirectional streams 2062 Many readers notice that unidirectional streams are both a bit 2063 confusing in concept and also somewhat redundant. If the recipient 2064 of a stream doesn't wish to send data on a stream, it could simply 2065 send a SYN_REPLY with the FLAG_FIN bit set. The FLAG_UNIDIRECTIONAL 2066 is, therefore, not necessary. 2068 It is true that we don't need the UNIDIRECTIONAL markings. It is 2069 added because it avoids the recipient of pushed streams from needing 2070 to send a set of empty frames (e.g. the SYN_STREAM w/ FLAG_FIN) which 2071 otherwise serve no purpose. 2073 5.7. Data Compression 2075 Generic compression of data portion of the streams (as opposed to 2076 compression of the headers) without knowing the content of the stream 2077 is redundant. There is no value in compressing a stream which is 2078 already compressed. Because of this, HTTP/2.0 does allow data 2079 compression to be optional. We included it because study of existing 2080 websites shows that many sites are not using compression as they 2081 should, and users suffer because of it. We wanted a mechanism where, 2082 at the HTTP/2.0 layer, site administrators could simply force 2083 compression - it is better to compress twice than to not compress. 2085 Overall, however, with this feature being optional and sometimes 2086 redundant, it is unclear if it is useful at all. We will likely 2087 remove it from the specification. 2089 5.8. Server Push 2091 A subtle but important point is that server push streams must be 2092 declared before the associated stream is closed. The reason for this 2093 is so that proxies have a lifetime for which they can discard 2094 information about previous streams. If a pushed stream could 2095 associate itself with an already-closed stream, then endpoints would 2096 not have a specific lifecycle for when they could disavow knowledge 2097 of the streams which went before. 2099 6. Security Considerations 2101 6.1. Use of Same-origin constraints 2103 This specification uses the same-origin policy [RFC6454] in all cases 2104 where verification of content is required. 2106 6.2. HTTP Headers and HTTP/2.0 Headers 2108 At the application level, HTTP uses name/value pairs in its headers. 2109 Because HTTP/2.0 merges the existing HTTP headers with HTTP/2.0 2110 headers, there is a possibility that some HTTP applications already 2111 use a particular header name. To avoid any conflicts, all headers 2112 introduced for layering HTTP over HTTP/2.0 are prefixed with ":". ":" 2113 is not a valid sequence in HTTP header naming, preventing any 2114 possible conflict. 2116 6.3. Cross-Protocol Attacks 2118 By utilizing TLS, we believe that HTTP/2.0 introduces no new cross- 2119 protocol attacks. TLS encrypts the contents of all transmission 2120 (except the handshake itself), making it difficult for attackers to 2121 control the data which could be used in a cross-protocol attack. 2123 6.4. Server Push Implicit Headers 2125 Pushed resources do not have an associated request. In order for 2126 existing HTTP cache control validations (such as the Vary header) to 2127 work, however, all cached resources must have a set of request 2128 headers. For this reason, browsers MUST be careful to inherit 2129 request headers from the associated stream for the push. This 2130 includes the 'Cookie' header. 2132 7. Privacy Considerations 2134 7.1. Long Lived Connections 2136 HTTP/2.0 aims to keep connections open longer between clients and 2137 servers in order to reduce the latency when a user makes a request. 2138 The maintenance of these connections over time could be used to 2139 expose private information. For example, a user using a browser 2140 hours after the previous user stopped using that browser may be able 2141 to learn about what the previous user was doing. This is a problem 2142 with HTTP in its current form as well, however the short lived 2143 connections make it less of a risk. 2145 7.2. SETTINGS frame 2147 The HTTP/2.0 SETTINGS frame allows servers to store out-of-band 2148 transmitted information about the communication between client and 2149 server on the client. Although this is intended only to be used to 2150 reduce latency, renegade servers could use it as a mechanism to store 2151 identifying information about the client in future requests. 2153 Clients implementing privacy modes, such as Google Chrome's 2154 "incognito mode", may wish to disable client-persisted SETTINGS 2155 storage. 2157 Clients MUST clear persisted SETTINGS information when clearing the 2158 cookies. 2160 TODO: Put range maximums on each type of setting to limit 2161 inappropriate uses. 2163 8. Requirements Notation 2165 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 2166 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 2167 document are to be interpreted as described in RFC 2119 [RFC2119]. 2169 9. Acknowledgements 2171 This document includes substantial input from the following 2172 individuals: 2174 o Adam Langley, Wan-Teh Chang, Jim Morrison, Mark Nottingham, Alyssa 2175 Wilk, Costin Manolache, William Chan, Vitaliy Lvin, Joe Chan, Adam 2176 Barth, Ryan Hamilton, Gavin Peters, Kent Alstad, Kevin Lindsay, 2177 Paul Amer, Fan Yang, Jonathan Leighton (SPDY contributors). 2179 o Gabriel Montenegro and Willy Tarreau (Upgrade mechanism) 2181 o William Chan, Salvatore Loreto, Osama Mazahir, Gabriel Montenegro, 2182 Jitu Padhye, Roberto Peon, Rob Trace (Flow control principles) 2184 o Mark Nottingham and Julian Reschke 2186 10. Normative References 2188 [ASCII] "US-ASCII. Coded Character Set - 7-Bit American 2189 Standard Code for Information Interchange. 2190 Standard ANSI X3.4-1986, ANSI, 1986.". 2192 [HTTP-p1] Fielding, R. and J. Reschke, "Hypertext Transfer 2193 Protocol (HTTP/1.1): Message Syntax and Routing", 2194 draft-ietf-httpbis-p1-messaging-21 (work in 2195 progress), October 2012. 2197 [HTTP-p2] Fielding, R. and J. Reschke, "Hypertext Transfer 2198 Protocol (HTTP/1.1): Semantics and Content", 2199 draft-ietf-httpbis-p2-semantics-21 (work in 2200 progress), October 2012. 2202 [RFC0793] Postel, J., "Transmission Control Protocol", 2203 STD 7, RFC 793, September 1981. 2205 [RFC1738] Berners-Lee, T., Masinter, L., and M. McCahill, 2206 "Uniform Resource Locators (URL)", RFC 1738, 2207 December 1994. 2209 [RFC1950] Deutsch, L. and J. Gailly, "ZLIB Compressed Data 2210 Format Specification version 3.3", RFC 1950, 2211 May 1996. 2213 [RFC2119] Bradner, S., "Key words for use in RFCs to 2214 Indicate Requirement Levels", BCP 14, RFC 2119, 2215 March 1997. 2217 [RFC2616] Fielding, R., Gettys, J., Mogul, J., Frystyk, H., 2218 Masinter, L., Leach, P., and T. Berners-Lee, 2219 "Hypertext Transfer Protocol -- HTTP/1.1", 2220 RFC 2616, June 1999. 2222 [RFC2617] Franks, J., Hallam-Baker, P., Hostetler, J., 2223 Lawrence, S., Leach, P., Luotonen, A., and L. 2224 Stewart, "HTTP Authentication: Basic and Digest 2225 Access Authentication", RFC 2617, June 1999. 2227 [RFC4559] Jaganathan, K., Zhu, L., and J. Brezak, "SPNEGO- 2228 based Kerberos and NTLM HTTP Authentication in 2229 Microsoft Windows", RFC 4559, June 2006. 2231 [RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer 2232 Security (TLS) Protocol Version 1.2", RFC 5246, 2233 August 2008. 2235 [RFC6454] Barth, A., "The Web Origin Concept", RFC 6454, 2236 December 2011. 2238 [TLSNPN] Langley, A., "TLS Next Protocol Negotiation", 2239 draft-agl-tls-nextprotoneg-01 (work in progress), 2240 August 2010. 2242 [UDELCOMPRESSION] Yang, F., Amer, P., and J. Leighton, "A 2243 Methodology to Derive SPDY's Initial Dictionary 2244 for Zlib Compression", . 2247 Appendix A. Change Log (to be removed by RFC Editor before publication) 2249 A.1. Since draft-ietf-httpbis-http2-00 2251 Changed title throughout. 2253 Removed section on Incompatibilities with SPDY draft#2. 2255 Changed INTERNAL_ERROR on GOAWAY to have a value of 2 . 2258 Replaced abstract and introduction. 2260 Added section on starting HTTP/2.0, including upgrade mechanism. 2262 Removed unused references. 2264 Added flow control principles (Section 3.5.1) based on . 2267 A.2. Since draft-mbelshe-httpbis-spdy-00 2269 Adopted as base for draft-ietf-httpbis-http2. 2271 Updated authors/editors list. 2273 Added status note. 2275 Authors' Addresses 2277 Mike Belshe 2278 Twist 2280 EMail: mbelshe@chromium.org 2282 Roberto Peon 2283 Google, Inc 2285 EMail: fenix@google.com 2287 Martin Thomson (editor) 2288 Microsoft 2289 3210 Porter Drive 2290 Palo Alto 94043 2291 US 2293 EMail: martin.thomson@skype.net 2295 Alexey Melnikov (editor) 2296 Isode Ltd 2297 5 Castle Business Village 2298 36 Station Road 2299 Hampton, Middlesex TW12 2BX 2300 UK 2302 EMail: Alexey.Melnikov@isode.com