source: draft-ietf-httpbis-http2/latest/draft-ietf-httpbis-http2.xml @ 2174

Last change on this file since 2174 was 2174, checked in by martin.thomson@…, 9 years ago

Adding decisions on flow control, removing versions.

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/xml
File size: 113.2 KB
Line 
1<?xml version="1.0"?>
2<?xml-stylesheet type="text/xsl" href="rfc2629.xml"?>
3<?rfc toc="yes" ?>
4<?rfc symrefs="yes" ?>
5<?rfc sortrefs="yes" ?>
6<?rfc compact="yes"?>
7<?rfc subcompact="no" ?>
8<?rfc linkmailto="no" ?>
9<?rfc editing="no" ?>
10<?rfc comments="yes"?>
11<?rfc inline="yes"?>
12<?rfc rfcedstyle="yes"?>
13<?rfc-ext allow-markup-in-artwork="yes" ?>
14<?rfc-ext include-references-in-index="yes" ?>
15
16<rfc ipr="trust200902" docName="draft-ietf-httpbis-http2-latest" xmlns:x='http://purl.org/net/xml2rfc/ext'>
17  <x:feedback template="mailto:ietf-http-wg@w3.org?subject={docname},%20%22{section}%22&amp;body=&lt;{ref}&gt;:"/>
18  <front>
19    <title abbrev="HTTP/2.0">Hypertext Transfer Protocol version 2.0</title>
20    <author initials="M." surname="Belshe" fullname="Mike Belshe">
21      <organization>Twist</organization>
22      <address>
23        <email>mbelshe@chromium.org</email>
24      </address>
25    </author>
26    <author initials="R." surname="Peon" fullname="Roberto Peon">
27      <organization>Google, Inc</organization>
28      <address>
29        <email>fenix@google.com</email>
30      </address>
31    </author>
32    <author initials="M." surname="Thomson" fullname="Martin Thomson" role="editor">
33      <organization>Microsoft</organization>
34      <address>
35        <postal>
36          <street>3210 Porter Drive</street>
37          <city>Palo Alto</city>
38          <code>94043</code>
39          <country>US</country>
40        </postal>
41        <email>martin.thomson@skype.net</email>
42      </address>
43    </author>
44
45    <author initials="A." surname="Melnikov" fullname="Alexey Melnikov" role="editor">
46      <organization>Isode Ltd</organization>
47      <address>
48        <postal>
49          <street>5 Castle Business Village</street>
50          <street>36 Station Road</street>
51          <city>Hampton</city>
52          <region>Middlesex</region>
53
54          <code>TW12 2BX</code>
55          <country>UK</country>
56        </postal>
57        <email>Alexey.Melnikov@isode.com</email>
58      </address>
59    </author>
60    <date year="2013" />
61    <area>Applications</area>
62    <workgroup>HTTPbis Working Group</workgroup>
63    <keyword>HTTP</keyword>
64
65<abstract>
66  <t>
67    This document describes an optimised expression of the semantics of the HTTP protocol.  The
68    HTTP/2.0 encapsulation enables more efficient transfer of resources over HTTP by providing
69    compressed headers, simultaneous requests, and unsolicited push of resources from server to
70    client.
71  </t>
72  <t>
73    This document is an alternative to, but does not obsolete RFC{http-p1}.  The HTTP protocol
74    semantics described in RFC{http-p2..p7} are unmodified.
75  </t>
76</abstract>
77
78<note title="Editorial Note (To be removed by RFC Editor)">
79  <t>
80    This draft is a work-in-progress, and does not yet reflect Working Group
81    consensus.
82  </t>
83  <t>
84    This draft contains features from the SPDY Protocol as a starting point, as per the Working
85    Group's charter. Future drafts will add, remove and change text, based upon the Working Group's
86    decisions.
87  </t>
88  <t>
89    Discussion of this draft takes place on the HTTPBIS working group
90    mailing list (ietf-http-wg@w3.org), which is archived at
91    <eref target="http://lists.w3.org/Archives/Public/ietf-http-wg/"/>.
92  </t>
93  <t>
94    The current issues list is at
95    <eref target="http://tools.ietf.org/wg/httpbis/trac/report/21"/> and related
96    documents (including fancy diffs) can be found at
97    <eref target="http://tools.ietf.org/wg/httpbis/"/>.
98  </t>
99  <t>
100    The changes in this draft are summarized in <xref target="changes.since.draft-ietf-httpbis-http2-01"/>.
101  </t>
102</note>
103
104  </front>
105
106  <middle>
107    <section anchor="intro" title="Introduction">
108<t>
109  HTTP is a wildly successful protocol.  <xref target="HTTP-p1">HTTP/1.1
110  message encapsulation</xref> is optimized for implementation simplicity and accessibility, not
111  application performance.  As such it has several characteristics that have a negative overall
112  effect on application performance.
113</t>
114<t>
115  The HTTP/1.1 encapsulation ensures that only one request can be delivered at a time on a given
116  connection.  HTTP/1.1 pipelining, which is not widely deployed, only partially addresses these
117  concerns.  Clients that need to make multiple requests therefore use commonly multiple connections
118  to a server or servers in order to reduce the overall latency of those requests.
119</t>
120<t>
121  Furthermore, HTTP/1.1 headers are represented in an inefficient fashion, which, in addition to
122  generating more or larger network packets, can cause the small initial TCP window to fill more
123  quickly than is ideal.  This results in excessive latency where multiple requests are made on a
124  new TCP connection.
125</t>
126<t>
127  This document defines an optimized mapping of the HTTP semantics to a TCP connection.  This
128  optimization reduces the latency costs of HTTP by allowing parallel requests on the same
129  connection and by using an efficient coding for HTTP headers.  Prioritization of requests lets
130  more important requests complete faster, further improving application performance.
131</t>
132<t>
133  HTTP/2.0 applications have an improved impact on network congestion due to the use of fewer TCP
134  connections to achieve the same effect.  Fewer TCP connections compete more fairly with other
135  flows.  Long-lived connections are also more able to take better advantage of the available
136  network capacity, rather than operating in the slow start phase of TCP.
137</t>
138<t>
139  The HTTP/2.0 encapsulation also enables more efficient processing of messages by providing
140  efficient message framing.  Processing of headers in HTTP/2.0 messages is more efficient (for
141  entities that process many messages).
142</t>
143
144      <section title="Document Organization">
145<t>The HTTP/2.0 Specification is split into three parts: <xref target="starting">starting HTTP/2.0</xref>, which covers how a HTTP/2.0 is started; <xref target="FramingLayer">a framing layer</xref>, which multiplexes a TCP connection into independent, length-prefixed frames; and <xref target="HTTPLayer">an HTTP layer</xref>, which specifies the mechanism for overlaying HTTP request/response pairs on top of the framing layer. While some of the framing layer concepts are isolated from the HTTP layer, building a generic framing layer has not been a goal. The framing layer is tailored to the needs of the HTTP protocol and server push.</t>
146      </section>
147      <section title="Definitions">
148<t>
149<list>
150<t>client: The endpoint initiating the HTTP/2.0 session.</t>
151<t>connection: A transport-level connection between two endpoints.</t>
152<t>endpoint: Either the client or server of a connection.</t>
153<t>frame: A header-prefixed sequence of bytes sent over a HTTP/2.0 session.</t>
154<t>server: The endpoint which did not initiate the HTTP/2.0 session.</t>
155<t>session: A synonym for a connection.</t>
156<t>session error: An error on the HTTP/2.0 session.</t>
157<t>stream: A bi-directional flow of bytes across a virtual channel within a HTTP/2.0 session.</t>
158<t>stream error: An error on an individual HTTP/2.0 stream.</t>
159</list>
160</t>
161      </section>
162    </section>
163
164<section anchor="starting" title="Starting HTTP/2.0">
165<t>
166  Just as HTTP/1.1 does, HTTP/2.0 uses the "http:" and "https:" URI schemes.  An HTTP/2.0-capable
167  client is therefore required to discover whether a server (or intermediary) supports HTTP/2.0.
168</t>
169<t>
170  Different discovery mechanisms are defined for "http:" and "https:" URIs.  Discovery for "http:"
171  URIs is described in <xref target="discover-http"/>; discovery for "https:" URIs is described in
172  <xref target="discover-https"/>.
173</t>
174
175<section anchor="versioning" title="HTTP/2.0 Version Identification">
176<t>
177  HTTP/2.0 is identified using the string "HTTP/2.0".  This identification is used in the
178  HTTP/1.1 Upgrade header, in the <xref target="TLSNPN">TLS-NPN</xref> [[TBD]] field and other
179  places where protocol identification is required.
180</t>
181<t>
182  Negotiating "HTTP/2.0" implies the use of the transport, security, framing and message semantics
183  described in this document.
184</t>
185<t>
186  [[Editor's Note: please remove the following text prior to the publication of a final version of
187  this document.]]
188</t>
189<t>
190  Only implementations of the final, published RFC can identify themselves as "HTTP/2.0".  Until
191  such an RFC exists, implementations MUST NOT identify themselves using "HTTP/2.0".
192</t>
193<t>
194  Examples and text throughout the rest of this document use "HTTP/2.0" as a matter of editorial
195  convenience only.  Implementations of draft versions MUST NOT identify using this string.
196</t>
197<t>
198  Implementations of draft versions of the protocol MUST add the corresponding draft number to the
199  identifier before the separator ('/').  For example, draft-ietf-httpbis-http2-03 is identified
200  using the string "HTTP-03/2.0".
201</t>
202<t>
203  Non-compatible experiments that are based on these draft versions MUST include a further
204  identifier.  For example, an experimental implementation of packet mood-based encoding based on
205  draft-ietf-httpbis-http2-07 might identify itself as "HTTP-07-emo/2.0".  Note that any label MUST
206  conform with the "token" syntax defined in Section 3.2.4 of <xref target="HTTP-p1"/>.
207  Experimenters are encouraged to coordinate their experiments on the ietf-http-wg@w3.org mailing
208  list.
209</t>
210</section>
211<section anchor="discover-http" title="Starting HTTP/2.0 for &quot;http:&quot; URIs">
212<t>
213  A client that makes a request to an "http:" URI without prior knowledge about support for HTTP/2.0
214  uses the HTTP Upgrade mechanism <xref target="HTTP-p2"/>.  The client makes an HTTP/1.1 request
215  that includes an Upgrade header field identifying HTTP/2.0.
216</t>
217<t>
218For example:
219</t>
220<figure><artwork><![CDATA[
221   GET /default.htm HTTP/1.1
222   Host: server.example.com
223   Connection: Upgrade
224   Upgrade: HTTP/2.0
225]]></artwork></figure>
226<t>
227  A server that does not support HTTP/2.0 can respond to the request as though the Upgrade header
228  field were absent:
229</t>
230<figure><artwork><![CDATA[
231   HTTP/1.1 200 OK
232   Content-length: 243
233   Content-type: text/html
234      ...
235]]></artwork></figure>
236<t>
237  A server that supports HTTP/2.0 can accept the upgrade with a 101 (Switching Protocols) status
238  code.  After the empty line that terminates the 101 response, the server can begin sending
239  HTTP/2.0 frames.  These frames MUST include a response to the request that initiated the Upgrade.
240</t>
241<figure><artwork><![CDATA[
242   HTTP/1.1 101 Switching Protocols
243   Connection: Upgrade
244   Upgrade: HTTP/2.0
245
246   [ HTTP/2.0 frames ...
247]]></artwork></figure>
248<t>
249  A client can learn that a particular server supports HTTP/2.0 by other means.  A client MAY
250  immediately send HTTP/2.0 frames to a server that is known to support HTTP/2.0.  [[Open Issue:
251  This is not definite.  We may yet choose to perform negotiation for every connection.  Reasons
252  include intermediaries; phased upgrade of load-balanced server farms; etc...]] [[Open Issue: We
253  need to enumerate the ways that clients can learn of HTTP/2.0 support.]]
254</t>
255</section>
256<section anchor="discover-https" title="Starting HTTP/2.0 for &quot;https:&quot; URIs">
257<t>
258  [[TBD, maybe NPN]]
259</t>
260</section>
261     
262    </section>
263
264    <section anchor="FramingLayer" title="HTTP/2.0 Framing Layer">
265      <section title="Session (Connections)">
266<t>The HTTP/2.0 framing layer (or "session") runs atop a reliable transport layer such as <xref target="RFC0793">TCP</xref>. The client is the TCP connection initiator. HTTP/2.0 connections are persistent connections.</t>
267
268<t>For best performance, it is expected that clients will not close open connections until the user navigates away from all web pages referencing a connection, or until the server closes the connection. Servers are encouraged to leave connections open for as long as possible, but can terminate idle connections if necessary. When either endpoint closes the transport-level connection, it MUST first send a <xref target="GOAWAY">GOAWAY</xref> frame so that the endpoints can reliably determine if requests finished before the close.</t>
269      </section>
270      <section title="Framing">
271<t>Once the connection is established, clients and servers exchange framed messages. There are two types of frames: <xref target="ControlFrames">control frames</xref> and <xref target="DataFrames">data frames</xref>.  Frames always have a common header which is 8 bytes in length.</t>
272
273<t>The first bit is a control bit indicating whether a frame is a control frame or data frame. Control frames carry a frame type, flags, and a length. Data frames contain the stream ID, flags, and the length for the payload carried after the common header. The simple header is designed to make reading and writing of frames easy.</t>
274
275<t>All integer values, including length and type, are in network byte order.  HTTP/2.0 does not enforce alignment of types in dynamically sized frames.</t>
276        <section anchor="ControlFrames" title="Control frames">
277<figure>
278  <artwork>
279+----------------------------------+
280|C| Unused (15bits) | Type(16bits) |
281+----------------------------------+
282| Flags (8)  |  Length (24 bits)   |
283+----------------------------------+
284|               Data               |
285+----------------------------------+
286  </artwork>
287</figure>
288<t>Control bit: The 'C' bit is a single bit indicating if this is a control message. For control frames this value is always 1.</t>
289
290<t>
291  Unused: these 15 bits are unused.
292</t>
293
294<t>Type: The type of control frame. See Control Frames for the complete list of control frames.</t>
295
296<t>Flags: Flags related to this frame. Flags for control frames and data frames are different.</t>
297
298<t>Length: An unsigned 24-bit value representing the number of bytes after the length field.</t>
299
300<t>Data: data associated with this control frame. The format and length of this data is controlled by the control frame type.</t>
301
302<t>Control frame processing requirements:
303<list>
304<t>Note that full length control frames (16MB) can be large for implementations running on resource-limited hardware.  In such cases, implementations MAY limit the maximum length frame supported.  However, all implementations MUST be able to receive control frames of at least 8192 octets in length.</t>
305</list>
306</t>
307        </section>
308
309        <section anchor="DataFrames" title="Data frames">
310<figure>
311  <artwork>
312+----------------------------------+
313|C|       Stream-ID (31bits)       |
314+----------------------------------+
315| Flags (8)  |  Length (24 bits)   |
316+----------------------------------+
317|               Data               |
318+----------------------------------+
319  </artwork>
320</figure>
321<t>Control bit: For data frames this value is always 0.</t>
322
323<t>Stream-ID: A 31-bit value identifying the stream.</t>
324
325<t>Flags: Flags related to this frame. Valid flags are:
326<list>
327<t>0x01 = FLAG_FIN - signifies that this frame represents the last frame to be transmitted on this stream. See <xref target="StreamClose">Stream Close</xref> below.</t>
328<t>0x02 = FLAG_COMPRESS - indicates that the data in this frame has been compressed.</t>
329</list>
330</t>
331
332<t>Length: An unsigned 24-bit value representing the number of bytes after the length field. The total size of a data frame is 8 bytes + length. It is valid to have a zero-length data frame.</t>
333
334<t>Data: The variable-length data payload; the length was defined in the length field.</t>
335
336<t>Data frame processing requirements:
337<list>
338<t>If an endpoint receives a data frame for a stream-id which is not open and the endpoint has not sent a <xref target="GOAWAY">GOAWAY</xref> frame, it MUST send issue a <xref target="StreamErrorHandler">stream error</xref> with the error code INVALID_STREAM for the stream-id.</t>
339<t>If the endpoint which created the stream receives a data frame before receiving a SYN_REPLY on that stream, it is a protocol error, and the recipient MUST issue a <xref target="StreamErrorHandler">stream error</xref> with the status code PROTOCOL_ERROR for the stream-id.</t>
340<t>Implementors note: If an endpoint receives multiple data frames for invalid stream-ids, it MAY close the session.</t>
341<t>All HTTP/2.0 endpoints MUST accept compressed data frames.  Compression of data frames is always done using zlib compression.  Each stream initializes and uses its own compression context dedicated to use within that stream.  Endpoints are encouraged to use application level compression rather than HTTP/2.0 stream level compression.</t>
342<t>Each HTTP/2.0 stream sending compressed frames creates its own zlib context for that stream, and these compression contexts MUST be distinct from the compression contexts used with SYN_STREAM/SYN_REPLY/HEADER compression. (Thus, if both endpoints of a stream are compressing data on the stream, there will be two zlib contexts, one for sending and one for receiving).</t>
343</list>
344</t>
345        </section>
346      </section>
347
348      <section title="Streams">
349<t>Streams are independent sequences of bi-directional data divided into frames with several properties:
350<list>
351<t>Streams may be created by either the client or server.</t>
352<t>Streams optionally carry a set of name/value header pairs.</t>
353<t>Streams can concurrently send data interleaved with other streams.</t>
354<t>Streams may be cancelled.</t>
355</list>
356</t>
357
358        <section anchor="StreamFrames" title="Stream frames">
359<t>HTTP/2.0 defines 3 control frames to manage the lifecycle of a stream:
360    <list>
361        <t>SYN_STREAM - Open a new stream</t>
362        <t>SYN_REPLY - Remote acknowledgement of a new, open stream</t>
363        <t>RST_STREAM - Close a stream</t>
364    </list>
365</t>
366        </section>
367
368        <section anchor="StreamCreation" title="Stream creation">
369<t>A stream is created by sending a control frame with the type set to <xref target="SYN_STREAM">SYN_STREAM</xref>.  If the server is initiating the stream, the Stream-ID must be even.  If the client is initiating the stream, the Stream-ID must be odd.  0 is not a valid Stream-ID. Stream-IDs from each side of the connection must increase monotonically as new streams are created.  E.g. Stream 2 may be created after stream 3, but stream 7 must not be created after stream 9. Stream IDs do not wrap: when a client or server cannot create a new stream id without exceeding a 31 bit value, it MUST NOT create a new stream.</t>
370
371<t>The stream-id MUST increase with each new stream. If an endpoint receives a SYN_STREAM with a stream id which is less than any previously received SYN_STREAM, it MUST issue a <xref target="SessionErrorHandler">session error</xref> with the status PROTOCOL_ERROR.</t>
372
373<t>It is a protocol error to send two SYN_STREAMs with the same stream-id. If a recipient receives a second SYN_STREAM for the same stream, it MUST issue a <xref target="StreamErrorHandler">stream error</xref> with the status code PROTOCOL_ERROR.</t>
374
375<t>Upon receipt of a SYN_STREAM, the recipient can reject the stream by sending a <xref target="StreamErrorHandler">stream error</xref> with the error code REFUSED_STREAM. Note, however, that the creating endpoint may have already sent additional frames for that stream which cannot be immediately stopped.</t>
376
377<t>Once the stream is created, the creator may immediately send HEADERS or DATA frames for that stream, without needing to wait for the recipient to acknowledge.</t>
378
379          <section title="Unidirectional streams">
380<t>When an endpoint creates a stream with the FLAG_UNIDIRECTIONAL flag set, it creates a unidirectional stream which the creating endpoint can use to send frames, but the receiving endpoint cannot. The receiving endpoint is implicitly already in the <xref target="StreamHalfClose">half-closed</xref> state.</t>
381          </section>
382
383          <section title="Bidirectional streams">
384<t>SYN_STREAM frames which do not use the FLAG_UNIDIRECTIONAL flag are bidirectional streams.  Both endpoints can send data on a bi-directional stream.</t>
385          </section>
386        </section>
387
388        <section anchor="StreamPriority" title="Stream priority">
389<t>The creator of a stream assigns a priority for that stream.  Priority is represented as an integer from 0 to 7.  0 represents the highest priority and 7 represents the lowest priority.</t>
390
391<t>The sender and recipient SHOULD use best-effort to process streams in the order of highest priority to lowest priority.</t>
392        </section>
393
394        <section title="Stream headers">
395<t>Streams carry optional sets of name/value pair headers which carry metadata about the stream. After the stream has been created, and as long as the sender is not <xref target="StreamClose">closed</xref> or <xref target="StreamHalfClose">half-closed</xref>, each side may send HEADERS frame(s) containing the header data.  Header data can be sent in multiple HEADERS frames, and HEADERS frames may be interleaved with data frames.</t>
396        </section>
397
398        <section title="Stream data exchange">
399<t>Once a stream is created, it can be used to send arbitrary amounts of data. Generally this means that a series of data frames will be sent on the stream until a frame containing the FLAG_FIN flag is set. The FLAG_FIN can be set on a <xref target="SYN_STREAM">SYN_STREAM</xref>, <xref target="SYN_REPLY">SYN_REPLY</xref>, <xref target="HEADERS">HEADERS</xref> or a <xref target="DataFrames">DATA</xref> frame.  Once the FLAG_FIN has been sent, the stream is considered to be half-closed.</t>
400        </section>
401
402        <section anchor="StreamHalfClose" title="Stream half-close">
403<t>When one side of the stream sends a frame with the FLAG_FIN flag set, the stream is half-closed from that endpoint. The sender of the FLAG_FIN MUST NOT send further frames on that stream. When both sides have half-closed, the stream is closed.</t>
404
405<t>If an endpoint receives a data frame after the stream is half-closed from the sender (e.g. the endpoint has already received a prior frame for the stream with the FIN flag set), it MUST send a RST_STREAM to the sender with the status STREAM_ALREADY_CLOSED.</t>
406        </section>
407
408        <section anchor="StreamClose" title="Stream close">
409<t>There are 3 ways that streams can be terminated:
410<list>
411<t>Normal termination: Normal stream termination occurs when both sender and recipient have half-closed the stream by sending a FLAG_FIN.</t>
412<t>Abrupt termination: Either the client or server can send a RST_STREAM control frame at any time. A RST_STREAM contains an error code to indicate the reason for failure.  When a RST_STREAM is sent from the stream originator, it indicates a failure to complete the stream and that no further data will be sent on the stream.  When a RST_STREAM is sent from the stream recipient, the sender, upon receipt, should stop sending any data on the stream.  The stream recipient should be aware that there is a race between data already in transit from the sender and the time the RST_STREAM is received.  See <xref target="StreamErrorHandler">Stream Error Handling</xref></t>
413<t>TCP connection teardown: If the TCP connection is torn down while un-closed streams exist, then the endpoint must assume that the stream was abnormally interrupted and may be incomplete.</t>
414</list>
415</t>
416
417<t>If an endpoint receives a data frame after the stream is closed, it must send a RST_STREAM to the sender with the status PROTOCOL_ERROR.</t>
418        </section>
419      </section>
420
421      <section title="Error Handling">
422<t>The HTTP/2.0 framing layer has only two types of errors, and they are always handled consistently.  Any reference in this specification to "issue a session error" refers to <xref target="SessionErrorHandler"></xref>.  Any reference to "issue a stream error" refers to <xref target="StreamErrorHandler"></xref>.</t>
423
424        <section anchor="SessionErrorHandler" title="Session Error Handling">
425<t>A session error is any error which prevents further processing of the framing layer or which corrupts the session compression state. When a session error occurs, the endpoint encountering the error MUST first send a <xref target="GOAWAY">GOAWAY</xref> frame with the stream id of most recently received stream from the remote endpoint, and the error code for why the session is terminating.  After sending the GOAWAY frame, the endpoint MUST close the TCP connection.</t>
426
427<t>Note that the session compression state is dependent upon both endpoints always processing all compressed data.  If an endpoint partially processes a frame containing compressed data without updating compression state properly, future control frames which use compression will be always be errored.  Implementations SHOULD always try to process compressed data so that errors which could be handled as stream errors do not become session errors.</t>
428
429<t>Note that because this GOAWAY is sent during a session error case, it is possible that the GOAWAY will not be reliably received by the receiving endpoint.  It is a best-effort attempt to communicate with the remote about why the session is going down.</t>
430        </section>
431
432        <section anchor="StreamErrorHandler" title="Stream Error Handling">
433<t>A stream error is an error related to a specific stream-id which does not affect processing of other streams at the framing layer. Upon a stream error, the endpoint MUST send a <xref target="RST_STREAM">RST_STREAM</xref> frame which contains the stream id of the stream where the error occurred and the error status which caused the error.  After sending the RST_STREAM, the stream is closed to the sending endpoint.  After sending the RST_STREAM, if the sender receives any frames other than a RST_STREAM for that stream id, it will result in sending additional RST_STREAM frames.  An endpoint MUST NOT send a RST_STREAM in response to an RST_STREAM, as doing so would lead to RST_STREAM loops.  Sending a RST_STREAM does not cause the HTTP/2.0 session to be closed.</t>
434
435<t>If an endpoint has multiple RST_STREAM frames to send in succession for the same stream-id and the same error code, it MAY coalesce them into a single RST_STREAM frame.  (This can happen if a stream is closed, but the remote sends multiple data frames.  There is no reason to send a RST_STREAM for each frame in succession).</t>
436        </section>
437      </section>
438
439<section anchor="flowcontrol" title="Stream Flow Control">
440<t>
441  Multiplexing streams introduces contention for access to the shared TCP connection.  Stream
442  contention can result in streams being blocked by other streams.  A flow control scheme ensures
443  that streams do not destructively interfere with other streams on the same TCP connection.
444</t>
445
446<section anchor="fc-principles" title="Flow Control Principles">
447<t>
448  Experience with TCP congestion control has shown that algorithms can evolve over time
449  to become more sophisticated without requiring protocol changes.  TCP congestion control and its
450  evolution is clearly different from HTTP/2.0 flow control, though the evolution of TCP congestion
451  control algorithms shows that a similar approach could be feasible for HTTP/2.0 flow control.
452</t>
453<t>
454  HTTP/2.0 stream flow control aims to allow for future improvements to flow control algorithms
455  without requiring protocol changes.  Flow control in HTTP/2.0 has the following characteristics:
456  <list style="numbers">
457    <t>
458      Flow control is hop-by-hop, not end-to-end.
459    </t>
460    <t>
461      Flow control is based on window update messages.  Receivers advertise how many octets they
462      are prepared to receive on a stream.  This is a credit-based scheme.
463    </t>
464    <t>
465      Flow control is directional with overall control provided by the receiver.  A receiver MAY
466      choose to set any window size that it desires for each stream and for the entire
467      connection.  A sender MUST respect flow control limits imposed by a receiver.  Clients,
468      servers and intermediaries all independently advertise their flow control preferences as a
469      receiver and abide by the flow control limits set by their peer when sending.
470    </t>
471    <t>
472      The initial value for the flow control window is 65536 bytes for both new streams and the
473      overall connection.
474    </t>
475    <t>
476      Flow control only applies to data frames.  Control frames do not consume space in the
477      advertised flow control window.
478    </t>
479    <t>
480      Flow control can be disabled by a receiver.  A receiver can choose to either disable flow
481      control for a stream or connection by declaring an infinite flow control limit.
482    </t>
483    <t>
484      HTTP/2.0 standardizes only the format of the <xref target="WINDOW_UPDATE">window update
485      message</xref>.  This does not stipulate how a receiver decides when to send this message or
486      the value that it sends.  Nor does it specify how a sender chooses to send packets.
487      Implementations are able to select any algorithm that suits their needs.  An example flow
488      control algorithm is described in <xref target="fc-basic"/>.
489    </t>
490  </list>
491</t>
492<t>
493  Implementations are also responsible for managing how requests and responses are sent based on
494  priority; choosing how to avoid head of line blocking for requests; and managing the creation of
495  new streams.  Algorithm choices for these could interact with any flow control algorithm.
496</t>
497
498</section>
499<section anchor="fc-basic" title="Basic Flow Control Algorithm">
500<t>
501  This section describes a basic flow control algorithm.  This algorithm is provided as an example,
502  implementations can use any algorithm that complies with flow control requirements.
503</t>
504<t>
505  [[Algorithm TBD]]
506</t>
507</section>
508</section>
509
510      <section title="Control frame types">
511        <section anchor="SYN_STREAM" title="SYN_STREAM">
512<t>The SYN_STREAM control frame allows the sender to asynchronously create a stream between the endpoints.  See <xref target="StreamCreation">Stream Creation</xref></t>
513          <figure>
514            <artwork>
515+------------------------------------+
516|1|    unused     |         1        |
517+------------------------------------+
518|  Flags (8)  |  Length (24 bits)    |
519+------------------------------------+
520|X|           Stream-ID (31bits)     |
521+------------------------------------+
522|X| Associated-To-Stream-ID (31bits) |
523+------------------------------------+
524| Pri|Unused | Slot |                |
525+-------------------+                |
526| Number of Name/Value pairs (int32) |   &lt;+
527+------------------------------------+    |
528|     Length of name (int32)         |    | This section is the
529+------------------------------------+    | "Name/Value Header
530|           Name (string)            |    | Block", and is
531+------------------------------------+    | compressed.
532|     Length of value  (int32)       |    |
533+------------------------------------+    |
534|          Value   (string)          |    |
535+------------------------------------+    |
536|           (repeats)                |   &lt;+
537            </artwork>
538          </figure>
539
540<t>Flags: Flags related to this frame. Valid flags are:
541<list>
542<t>0x01 = FLAG_FIN - marks this frame as the last frame to be transmitted on this stream and puts the sender in the <xref target="StreamHalfClose">half-closed</xref> state.</t>
543<t>0x02 = FLAG_UNIDIRECTIONAL - a stream created with this flag puts the recipient in the <xref target="StreamHalfClose">half-closed</xref> state.</t>
544</list>
545</t>
546
547<t>Length: The length is the number of bytes which follow the length field in the frame.  For SYN_STREAM frames, this is 10 bytes plus the length of the compressed Name/Value block.</t>
548
549<t>Stream-ID: The 31-bit identifier for this stream.  This stream-id will be used in frames which are part of this stream.</t>
550
551<t>Associated-To-Stream-ID: The 31-bit identifier for a stream which this stream is associated to.  If this stream is independent of all other streams, it should be 0.</t>
552
553<t>Priority: A 3-bit <xref target="StreamPriority">priority</xref> field.</t>
554
555<t>Unused: 5 bits of unused space, reserved for future use.</t>
556
557<t>Slot: An 8 bit unsigned integer specifying the index in the server's CREDENTIAL vector of the client certificate to be used for this request. <xref target="CREDENTIAL">see CREDENTIAL frame</xref>.  The value 0 means no client certificate should be associated with this stream.</t>
558
559<t>Name/Value Header Block:  A set of name/value pairs carried as part of the SYN_STREAM.  <xref target="HeaderBlock">see Name/Value Header Block</xref>.</t>
560
561<t>If an endpoint receives a SYN_STREAM which is larger than the implementation supports, it MAY send a RST_STREAM with error code FRAME_TOO_LARGE.  All implementations MUST support the minimum size limits defined in <xref target="ControlFrames">the Control Frames section</xref>.</t>
562
563        </section>
564
565        <section anchor="SYN_REPLY" title="SYN_REPLY">
566<t>SYN_REPLY indicates the acceptance of a stream creation by the recipient of a SYN_STREAM frame.</t>
567          <figure>
568            <artwork>
569+------------------------------------+
570|1|    unused     |         2        |
571+------------------------------------+
572|  Flags (8)  |  Length (24 bits)    |
573+------------------------------------+
574|X|           Stream-ID (31bits)     |
575+------------------------------------+
576| Number of Name/Value pairs (int32) |   &lt;+
577+------------------------------------+    |
578|     Length of name (int32)         |    | This section is the
579+------------------------------------+    | "Name/Value Header
580|           Name (string)            |    | Block", and is
581+------------------------------------+    | compressed.
582|     Length of value  (int32)       |    |
583+------------------------------------+    |
584|          Value   (string)          |    |
585+------------------------------------+    |
586|           (repeats)                |   &lt;+
587            </artwork>
588          </figure>
589
590<t>Flags: Flags related to this frame. Valid flags are:
591<list>
592<t>0x01 = FLAG_FIN - marks this frame as the last frame to be transmitted on this stream and puts the sender in the <xref target="StreamHalfClose">half-closed</xref> state.</t>
593</list>
594</t>
595
596<t>Length: The length is the number of bytes which follow the length field in the frame.  For SYN_REPLY frames, this is 4 bytes plus the length of the compressed Name/Value block.</t>
597
598<t>Stream-ID: The 31-bit identifier for this stream.</t>
599
600<t>If an endpoint receives multiple SYN_REPLY frames for the same active stream ID, it MUST issue a <xref target="StreamErrorHandler">stream error</xref> with the error code STREAM_IN_USE.</t>
601
602<t>Name/Value Header Block:  A set of name/value pairs carried as part of the SYN_STREAM.  <xref target="HeaderBlock">see Name/Value Header Block</xref>.</t>
603
604<t>If an endpoint receives a SYN_REPLY which is larger than the implementation supports, it MAY send a RST_STREAM with error code FRAME_TOO_LARGE.  All implementations MUST support the minimum size limits defined in <xref target="ControlFrames">the Control Frames section</xref>.</t>
605        </section>
606
607        <section anchor="RST_STREAM" title="RST_STREAM">
608<t>The RST_STREAM frame allows for abnormal termination of a stream.  When sent by the creator of a stream, it indicates the creator wishes to cancel the stream.  When sent by the recipient of a stream, it indicates an error or that the recipient did not want to accept the stream, so the stream should be closed.</t>
609          <figure>
610            <artwork>
611+----------------------------------+
612|1|   unused     |         3       |
613+----------------------------------+
614| Flags (8)  |         8           |
615+----------------------------------+
616|X|          Stream-ID (31bits)    |
617+----------------------------------+
618|          Status code             |
619+----------------------------------+
620            </artwork>
621          </figure>
622<t>Flags: Flags related to this frame. RST_STREAM does not define any flags.  This value must be 0.</t>
623
624<t>Length: An unsigned 24-bit value representing the number of bytes after the length field. For RST_STREAM  control frames, this value is always 8.</t>
625
626<t>Stream-ID: The 31-bit identifier for this stream.</t>
627
628<t>Status code: (32 bits) An indicator for why the stream is being terminated.The following status codes are defined:
629<list>
630<t>1 - PROTOCOL_ERROR. This is a generic error, and should only be used if a more specific error is not available.</t>
631<t>2 - INVALID_STREAM. This is returned when a frame is received for a stream which is not active.</t>
632<t>3 - REFUSED_STREAM.  Indicates that the stream was refused before any processing has been done on the stream.</t>
633<t>4 - (UNUSED)</t>
634<t>5 - CANCEL.  Used by the creator of a stream to indicate that the stream is no longer needed.</t>
635<t>6 - INTERNAL_ERROR.  This is a generic error which can be used when the implementation has internally failed, not due to anything in the protocol.</t>
636<t>7 - FLOW_CONTROL_ERROR.  The endpoint detected that its peer violated the flow control protocol.</t>
637<t>8 - STREAM_IN_USE.  The endpoint received a SYN_REPLY for a stream already open.</t>
638<t>9 - STREAM_ALREADY_CLOSED.  The endpoint received a data or SYN_REPLY frame for a stream which is half closed.</t>
639<t>10 - INVALID_CREDENTIALS.  The server received a request for a resource whose origin does not have valid credentials in the client certificate vector.</t>
640<t>11 - FRAME_TOO_LARGE.  The endpoint received a frame which this implementation could not support.  If FRAME_TOO_LARGE is sent for a SYN_STREAM, HEADERS, or SYN_REPLY frame without fully processing the compressed portion of those frames, then the compression state will be out-of-sync with the other endpoint.  In this case, senders of FRAME_TOO_LARGE MUST close the session.</t>
641<t>Note:  0 is not a valid status code for a RST_STREAM.</t>
642</list>
643</t>
644
645<t>After receiving a RST_STREAM on a stream, the recipient must not send additional frames for that stream, and the stream moves into the closed state.</t>
646        </section>
647
648        <section anchor="SETTINGS" title="SETTINGS">
649<t>A SETTINGS frame contains a set of id/value pairs for communicating configuration data about how the two endpoints may communicate. SETTINGS frames can be sent at any time by either endpoint, are optionally sent, and are fully asynchronous.  When the server is the sender, the sender can request that configuration data be persisted by the client across HTTP/2.0 sessions and returned to the server in future communications.</t>
650
651<t>Persistence of SETTINGS ID/Value pairs is done on a per origin/IP pair (the "origin" is the set of scheme, host, and port from the URI.  See <xref target="RFC6454"></xref>).  That is, when a client connects to a server, and the server persists settings within the client, the client SHOULD return the persisted settings on future connections to the same origin AND IP address and TCP port. Clients MUST NOT request servers to use the persistence features of the SETTINGS frames, and servers MUST ignore persistence related flags sent by a client.</t>
652          <figure>
653            <artwork>
654+----------------------------------+
655|1|   unused     |         4       |
656+----------------------------------+
657| Flags (8)  |  Length (24 bits)   |
658+----------------------------------+
659|         Number of entries        |
660+----------------------------------+
661|          ID/Value Pairs          |
662|             ...                  |
663            </artwork>
664          </figure>
665<t>Control bit: The control bit is always 1 for this message.</t>
666
667<t>
668  Unused
669</t>
670
671<t>Type: The message type for a SETTINGS message is 4.</t>
672
673<t>Flags: FLAG_SETTINGS_CLEAR_SETTINGS (0x1): When set, the client should clear any previously persisted SETTINGS ID/Value pairs.  If this frame contains ID/Value pairs with the FLAG_SETTINGS_PERSIST_VALUE set, then the client will first clear its existing, persisted settings, and then persist the values with the flag set which are contained within this frame.  Because persistence is only implemented on the client, this flag can only be used when the sender is the server.</t>
674
675<t>Length: An unsigned 24-bit value representing the number of bytes after the length field. The total size of a SETTINGS frame is 8 bytes + length.</t>
676
677<t>Number of entries: A 32-bit value representing the number of ID/value pairs in this message.</t>
678
679<t>ID: A 32-bit ID number, comprised of 8 bits of flags and 24 bits of unique ID.
680<list>
681  <t>ID.flags:
682  <list>
683    <t>FLAG_SETTINGS_PERSIST_VALUE (0x1):   When set, the sender of this SETTINGS frame is requesting that the recipient persist the ID/Value and return it in future SETTINGS frames sent from the sender to this recipient.  Because persistence is only implemented on the client, this flag is only sent by the server.</t>
684    <t>FLAG_SETTINGS_PERSISTED (0x2):  When set, the sender is notifying the recipient that this ID/Value pair was previously sent to the sender by the recipient with the FLAG_SETTINGS_PERSIST_VALUE, and the sender is returning it.  Because persistence is only implemented on the client, this flag is only sent by the client.</t>
685  </list>
686  </t>
687
688  <t>Defined IDs:
689  <list>
690<t>1 - SETTINGS_UPLOAD_BANDWIDTH allows the sender to send its expected upload bandwidth on this channel. This number is an estimate. The value should be the integral number of kilobytes per second that the sender predicts as an expected maximum upload channel capacity.</t>
691<t>2 - SETTINGS_DOWNLOAD_BANDWIDTH allows the sender to send its expected download bandwidth on this channel. This number is an estimate. The value should be the integral number of kilobytes per second that the sender predicts as an expected maximum download channel capacity.</t>
692<t>3 - SETTINGS_ROUND_TRIP_TIME allows the sender to send its expected round-trip-time on this channel. The round trip time is defined as the minimum amount of time to send a control frame from this client to the remote and receive a response. The value is represented in milliseconds.</t>
693<t>4 - SETTINGS_MAX_CONCURRENT_STREAMS allows the sender to inform the remote endpoint the maximum number of concurrent streams which it will allow. By default there is no limit. For implementors it is recommended that this value be no smaller than 100.</t>
694<t>5 - SETTINGS_CURRENT_CWND allows the sender to inform the remote endpoint of the current TCP CWND value.</t>
695<t>6 - SETTINGS_DOWNLOAD_RETRANS_RATE allows the sender to inform the remote endpoint the retransmission rate (bytes retransmitted / total bytes transmitted).</t>
696<t>7 - SETTINGS_INITIAL_WINDOW_SIZE allows the sender to inform the remote endpoint the initial window size (in bytes) for new streams.</t>
697<t>8 - SETTINGS_CLIENT_CERTIFICATE_VECTOR_SIZE allows the server to inform the client of the new size of the client certificate vector.</t>
698  </list>
699  </t>
700</list>
701</t>
702
703<t>Value: A 32-bit value.</t>
704
705<t>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.</t>
706
707<t>A server may send multiple SETTINGS frames containing different ID/Value pairs.  When the same ID/Value is sent twice, the most recent value overrides any previously sent values.  If the server sends IDs 1, 2, and 3 with the FLAG_SETTINGS_PERSIST_VALUE in a first SETTINGS frame, and then sends IDs 4 and 5 with the FLAG_SETTINGS_PERSIST_VALUE, when the client returns the persisted state on its next SETTINGS frame, it SHOULD send all 5 settings (1, 2, 3, 4, and 5 in this example) to the server.</t>
708        </section>
709
710        <section anchor="PING" title="PING">
711<t>The PING control frame is a mechanism for measuring a minimal round-trip time from the sender.  It can be sent from the client or the server.  Recipients of a PING frame should send an identical frame to the sender as soon as possible (if there is other pending data waiting to be sent, PING should take highest priority).  Each ping sent by a sender should use a unique ID.</t>
712          <figure>
713            <artwork>
714+----------------------------------+
715|1|   unused     |         6       |
716+----------------------------------+
717| 0 (flags) |     4 (length)       |
718+----------------------------------|
719|            32-bit ID             |
720+----------------------------------+
721            </artwork>
722          </figure>
723<t>Control bit: The control bit is always 1 for this message.</t>
724
725<t>
726  Unused
727</t>
728
729<t>Type: The message type for a PING message is 6.</t>
730
731<t>Length: This frame is always 4 bytes long.</t>
732
733<t>ID: A unique ID for this ping, represented as an unsigned 32 bit value.  When the client initiates a ping, it must use an odd numbered ID.  When the server initiates a ping, it must use an even numbered ping.  Use of odd/even IDs is required in order to avoid accidental looping on PINGs (where each side initiates an identical PING at the same time).</t>
734
735<t>Note: If a sender uses all possible PING ids (e.g. has sent all 2^31 possible IDs), it can wrap and start re-using IDs.</t>
736
737<t>If a server receives an even numbered PING which it did not initiate, it must ignore the PING.
738If a client receives an odd numbered PING which it did not initiate, it must ignore the PING.</t>
739        </section>
740
741        <section anchor="GOAWAY" title="GOAWAY">
742<t>The GOAWAY control frame is a mechanism to tell the remote side of the connection to stop creating streams on this session.  It can be sent from the client or the server. Once sent, the sender will not respond to any new SYN_STREAMs on this session. Recipients of a GOAWAY frame must not send additional streams on this session, although a new session can be established for new streams.  The purpose of this message is to allow an endpoint to gracefully stop accepting new streams (perhaps for a reboot or maintenance), while still finishing processing of previously established streams.</t>
743
744<t>There is an inherent race condition between an endpoint sending SYN_STREAMs and the remote sending a GOAWAY message.  To deal with this case, the GOAWAY contains a last-stream-id indicating the stream-id of the last stream which was created on the sending endpoint in this session.  If the receiver of the GOAWAY sent new SYN_STREAMs for sessions after this last-stream-id, they were not processed by the server and the receiver may treat the stream as though it had never been created at all (hence the receiver may want to re-create the stream later on a new session).</t>
745
746<t>Endpoints should always send a GOAWAY message before closing a connection so that the remote can know whether a stream has been partially processed or not.  (For example, if an HTTP client sends a POST at the same time that a server closes a connection, the client cannot know if the server started to process that POST request if the server does not send a GOAWAY frame to indicate where it stopped working).</t>
747
748<t>After sending a GOAWAY message, the sender must ignore all SYN_STREAM frames for new streams.</t>
749          <figure>
750            <artwork>
751+----------------------------------+
752|1|   unused     |         7       |
753+----------------------------------+
754| 0 (flags) |     8 (length)       |
755+----------------------------------|
756|X|  Last-good-stream-ID (31 bits) |
757+----------------------------------+
758|          Status code             |
759+----------------------------------+
760            </artwork>
761          </figure>
762<t>Control bit: The control bit is always 1 for this message.</t>
763
764<t>
765  Unused
766</t>
767
768<t>Type: The message type for a GOAWAY message is 7.</t>
769
770<t>Length: This frame is always 8 bytes long.</t>
771
772<t>Last-good-stream-Id: The last stream id which was replied to (with either a SYN_REPLY or RST_STREAM) by the sender of the GOAWAY message.  If no streams were replied to, this value MUST be 0.</t>
773
774<t>Status: The reason for closing the session.
775<list>
776<t>0 - OK. This is a normal session teardown.</t>
777<t>1 - PROTOCOL_ERROR. This is a generic error, and should only be used if a more specific error is not available.</t>
778<t>2 - INTERNAL_ERROR.  This is a generic error which can be used when the implementation has internally failed, not due to anything in the protocol.</t>
779</list>
780</t>
781        </section>
782
783        <section anchor="HEADERS" title="HEADERS">
784<t>The HEADERS frame augments a stream with additional headers. It may be optionally sent on an existing stream at any time.  Specific application of the headers in this frame is application-dependent.  The name/value header block within this frame is compressed.</t>
785          <figure>
786            <artwork>
787+------------------------------------+
788|1|   unused      |          8       |
789+------------------------------------+
790| Flags (8)  |   Length (24 bits)    |
791+------------------------------------+
792|X|          Stream-ID (31bits)      |
793+------------------------------------+
794| Number of Name/Value pairs (int32) |   &lt;+
795+------------------------------------+    |
796|     Length of name (int32)         |    | This section is the
797+------------------------------------+    | "Name/Value Header
798|           Name (string)            |    | Block", and is
799+------------------------------------+    | compressed.
800|     Length of value  (int32)       |    |
801+------------------------------------+    |
802|          Value   (string)          |    |
803+------------------------------------+    |
804|           (repeats)                |   &lt;+
805            </artwork>
806          </figure>
807<t>Flags: Flags related to this frame. Valid flags are:
808<list>
809<t>0x01 = FLAG_FIN - marks this frame as the last frame to be transmitted on this stream and puts the sender in the <xref target="StreamHalfClose">half-closed</xref> state.</t>
810</list>
811</t>
812
813<t>Length: An unsigned 24 bit value representing the number of bytes after the length field. The minimum length of the length field is 4 (when the number of name value pairs is 0).</t>
814
815<t>Stream-ID: The stream this HEADERS block is associated with.</t>
816
817<t>Name/Value Header Block:  A set of name/value pairs carried as part of the SYN_STREAM.  <xref target="HeaderBlock">see Name/Value Header Block</xref>.</t>
818
819          </section>
820
821          <section anchor="WINDOW_UPDATE" title="WINDOW_UPDATE">
822<t>The WINDOW_UPDATE control frame is used to implement per stream flow control in HTTP/2.0. Flow control in HTTP/2.0 is per hop, that is, only between the two endpoints of a HTTP/2.0 connection. If there are one or more intermediaries between the client and the origin server, flow control signals are not explicitly forwarded by the intermediaries. (However, throttling of data transfer by any recipient may have the effect of indirectly propagating flow control information upstream back to the original sender.) Flow control only applies to the data portion of data frames. Recipients must buffer all control frames. If a recipient fails to buffer an entire control frame, it MUST issue a <xref target="StreamErrorHandler">stream error</xref> with the status code FLOW_CONTROL_ERROR for the stream.</t>
823
824<t>Flow control in HTTP/2.0 is implemented by a data transfer window kept by the sender of each stream. The data transfer window is a simple uint32 that indicates how many bytes of data the sender can transmit. After a stream is created, but before any data frames have been transmitted, the sender begins with the initial window size. This window size is a measure of the buffering capability of the recipient. The sender must not send a data frame with data length greater than the transfer window size. After sending each data frame, the sender decrements its transfer window size by the amount of data transmitted. When the window size becomes less than or equal to 0, the sender must pause transmitting data frames. At the other end of the stream, the recipient sends a WINDOW_UPDATE control back to notify the sender that it has consumed some data and freed up buffer space to receive more data.</t>
825          <figure>
826            <artwork>
827+----------------------------------+
828|1|   unused     |         9       |
829+----------------------------------+
830| 0 (flags) |     8 (length)       |
831+----------------------------------+
832|X|     Stream-ID (31-bits)        |
833+----------------------------------+
834|X|  Delta-Window-Size (31-bits)   |
835+----------------------------------+
836            </artwork>
837          </figure>
838<t>Control bit: The control bit is always 1 for this message.</t>
839
840<t>
841  Unused
842</t>
843
844<t>Type: The message type for a WINDOW_UPDATE message is 9.</t>
845
846<t>Length: The length field is always 8 for this frame (there are 8 bytes after the length field).</t>
847
848<t>Stream-ID: The stream ID that this WINDOW_UPDATE control frame is for.</t>
849
850<t>Delta-Window-Size: The additional number of bytes that the sender can transmit in addition to existing remaining window size. The legal range for this field is 1 to 2^31 - 1 (0x7fffffff) bytes.</t>
851
852<t>The window size as kept by the sender must never exceed 2^31 (although it can become negative in one special case). If a sender receives a WINDOW_UPDATE that causes the its window size to exceed this limit, it must send RST_STREAM with status code FLOW_CONTROL_ERROR to terminate the stream.</t>
853
854<t>When a HTTP/2.0 connection is first established, the default initial window size for all streams is 64KB. An endpoint can use the SETTINGS control frame to adjust the initial window size for the connection. That is, its peer can start out using the 64KB default initial window size when sending data frames before receiving the SETTINGS. Because SETTINGS  is asynchronous, there may be a race condition if the recipient wants to decrease the initial window size, but its peer immediately sends 64KB on the creation of a new connection, before waiting for the SETTINGS to arrive. This is one case where the window size kept by the sender will become negative. Once the sender detects this condition, it must stop sending data frames and wait for the recipient to catch up. The recipient has two choices:
855<list>
856<t>immediately send RST_STREAM with FLOW_CONTROL_ERROR status code.</t>
857<t>allow the head of line blocking (as there is only one stream for the session and the amount of data in flight is bounded by the default initial window size), and send WINDOW_UPDATE as it consumes data.</t>
858</list>
859</t>
860
861<t>In the case of option 2, both sides must compute the window size based on the initial window size in the SETTINGS. For example, if the recipient sets the initial window size to be 16KB, and the sender sends 64KB immediately on connection establishment, the sender will discover its window size is -48KB on receipt of the SETTINGS. As the recipient consumes the first 16KB, it must send a WINDOW_UPDATE of 16KB back to the sender. This interaction continues until the sender's window size becomes positive again, and it can resume transmitting data frames.</t>
862
863<t>After the recipient reads in a data frame with FLAG_FIN that marks the end of the data stream, it should not send WINDOW_UPDATE frames as it consumes the last data frame. A sender should ignore all the WINDOW_UPDATE frames associated with the stream after it send the last frame for the stream.</t>
864
865<t>The data frames from the sender and the WINDOW_UPDATE frames from the recipient are completely asynchronous with respect to each other. This property allows a recipient to aggressively update the window size kept by the sender to prevent the stream from stalling.</t>
866          </section>
867
868          <section anchor="CREDENTIAL" title="CREDENTIAL">
869<t>The CREDENTIAL control frame is used by the client to send additional client certificates to the server.  A HTTP/2.0 client may decide to send requests for resources from different origins on the same HTTP/2.0 session if it decides that that server handles both origins.  For example if the IP address associated with both hostnames matches and the SSL server certificate presented in the initial handshake is valid for both hostnames.  However, because the SSL connection can contain at most one client certificate, the client needs a mechanism to send additional client certificates to the server.</t>
870
871<t>The server is required to maintain a vector of client certificates associated with a HTTP/2.0 session. When the client needs to send a client certificate to the server, it will send a CREDENTIAL frame that specifies the index of the slot in which to store the certificate as well as proof that the client posesses the corresponding private key. The initial size of this vector must be 8. If the client provides a client certificate during the first TLS handshake, the contents of this certificate must be copied into the first slot (index 1) in the CREDENTIAL vector, though it may be overwritten by subsequent CREDENTIAL frames. The server must exclusively use the CREDENTIAL vector when evaluating the client certificates associated with an origin. The server may change the size of this vector by sending a SETTINGS frame with the setting SETTINGS_CLIENT_CERTIFICATE_VECTOR_SIZE value specified. In the event that the new size is smaller than the current size, truncation occurs preserving lower-index slots as possible.</t> 
872
873<t>TLS renegotiation with client authentication is incompatible with HTTP/2.0 given the multiplexed nature of HTTP/2.0.  Specifically, imagine that the client has 2 requests outstanding to the server for two different pages (in different tabs).  When the renegotiation + client certificate request comes in, the browser is unable to determine which resource triggered the client certificate request, in order to prompt the user accordingly.</t>
874
875          <figure>
876            <artwork>
877+----------------------------------+
878|1|000000000000001|0000000000001011|
879+----------------------------------+
880| flags (8)  |  Length (24 bits)   |
881+----------------------------------+
882|  Slot (16 bits) |                |
883+-----------------+                |
884|      Proof Length (32 bits)      |
885+----------------------------------+
886|               Proof              |
887+----------------------------------+ &lt;+
888|   Certificate Length (32 bits)   |  |
889+----------------------------------+  | Repeated until end of frame
890|            Certificate           |  |
891+----------------------------------+ &lt;+
892            </artwork>
893          </figure>
894
895<t>
896  Slot: The index in the server's client certificate vector where this
897  certificate should be stored.  If there is already a certificate stored at
898  this index, it will be overwritten.  The index is one based, not zero based;
899  zero is an invalid slot index.
900</t>
901<t>
902  Proof: Cryptographic proof that the client has possession of the private key
903  associated with the certificate.  The format is a TLS digitally-signed
904  element (<xref target="RFC5246" x:fmt="," x:sec="4.7"/>).  The signature
905  algorithm must be the same as that used in the CertificateVerify message.
906  However, since the MD5+SHA1 signature type used in TLS 1.0 connections can
907  not be correctly encoded in a digitally-signed element, SHA1 must be used
908  when MD5+SHA1 was used in the SSL connection.  The signature is calculated
909  over a 32 byte TLS extractor value (http://tools.ietf.org/html/rfc5705) with
910  a label of "EXPORTER HTTP/2.0 certificate proof" using the empty string as
911  context. ForRSA certificates the signature would be a PKCS#1 v1.5 signature.
912  For ECDSA, it would be an ECDSA-Sig-Value
913  (http://tools.ietf.org/html/rfc5480#appendix-A).  For a 1024-bit RSA key,
914  the CREDENTIAL message would be ~500 bytes.
915</t>
916<t>Certificate: The certificate chain, starting with the leaf certificate.  Each certificate must be encoded as a 32 bit length, followed by a DER encoded certificate.  The certificate must be of the same type (RSA, ECDSA, etc) as the client certificate associated with the SSL connection.</t>
917<t>If the server receives a request for a resource with unacceptable credential (either missing or invalid), it must reply with a RST_STREAM frame with the status code INVALID_CREDENTIALS. Upon receipt of a RST_STREAM frame with INVALID_CREDENTIALS, the client should initiate a new stream directly to the requested origin and resend the request.  Note, HTTP/2.0 does not allow the server to request different client authentication for different resources in the same origin.</t>
918<t>If the server receives an invalid CREDENTIAL frame, it MUST respond with a GOAWAY frame and shutdown the session.  </t>
919          </section>
920
921          <section anchor="HeaderBlock" title="Name/Value Header Block">
922            <t>The Name/Value Header Block is found in the SYN_STREAM, SYN_REPLY
923            and HEADERS control frames, and shares a common format:</t>
924          <figure>
925            <artwork>
926+------------------------------------+
927| Number of Name/Value pairs (int32) |
928+------------------------------------+
929|     Length of name (int32)         |
930+------------------------------------+
931|           Name (string)            |
932+------------------------------------+
933|     Length of value  (int32)       |
934+------------------------------------+
935|          Value   (string)          |
936+------------------------------------+
937|           (repeats)                |
938            </artwork>
939          </figure>
940
941<t>Number of Name/Value pairs: The number of repeating name/value pairs following this field.</t>
942
943<t>List of Name/Value pairs:
944<list>
945<t>Length of Name: a 32-bit value containing the number of octets in the name field.  Note that in practice, this length must not exceed 2^24, as that is the maximum size of a HTTP/2.0 frame.</t>
946<t>Name: 0 or more octets, 8-bit sequences of data, excluding 0.</t>
947<t>Length of Value: a 32-bit value containing the number of octets in the value field.  Note that in practice, this length must not exceed 2^24, as that is the maximum size of a HTTP/2.0 frame.</t>
948<t>Value: 0 or more octets, 8-bit sequences of data, excluding 0.</t>
949</list>
950</t>
951
952<t>Each header name must have at least one value. Header names are encoded using the <xref target="ASCII">US-ASCII character set</xref> and must be all lower case.  The length of each name must be greater than zero.  A recipient of a zero-length name MUST issue a <xref target="StreamErrorHandler">stream error</xref> with the status code PROTOCOL_ERROR for the stream-id.</t>
953
954<t>Duplicate header names are not allowed. To send two identically named headers, send a header with two values, where the values are separated by a single NUL (0) byte. A header value can either be empty (e.g. the length is zero) or it can contain multiple, NUL-separated values, each with length greater than zero. The value never starts nor ends with a NUL character. Recipients of illegal value fields MUST issue a <xref target="StreamErrorHandler">stream error</xref> with the status code PROTOCOL_ERROR for the stream-id.</t>
955
956      <section title="Compression" anchor="Compression">
957        <t>The Name/Value Header Block is a section of the SYN_STREAM, SYN_REPLY, and HEADERS frames used to carry header meta-data.  This block is always compressed using zlib compression.  Within this specification, any reference to 'zlib' is referring to the <xref target="RFC1950">ZLIB Compressed Data Format Specification Version 3.3 as part of RFC1950.</xref></t>
958
959        <t>For each HEADERS compression instance, the initial state is initialized using the following <xref target="UDELCOMPRESSION">dictionary</xref>:</t>
960
961<figure>
962  <artwork type="code" x:isCodeComponent="yes">
963const unsigned char http2_dictionary_txt[] = {
964  0x00, 0x00, 0x00, 0x07, 0x6f, 0x70, 0x74, 0x69,  \\ - - - - o p t i
965  0x6f, 0x6e, 0x73, 0x00, 0x00, 0x00, 0x04, 0x68,  \\ o n s - - - - h
966  0x65, 0x61, 0x64, 0x00, 0x00, 0x00, 0x04, 0x70,  \\ e a d - - - - p
967  0x6f, 0x73, 0x74, 0x00, 0x00, 0x00, 0x03, 0x70,  \\ o s t - - - - p
968  0x75, 0x74, 0x00, 0x00, 0x00, 0x06, 0x64, 0x65,  \\ u t - - - - d e
969  0x6c, 0x65, 0x74, 0x65, 0x00, 0x00, 0x00, 0x05,  \\ l e t e - - - -
970  0x74, 0x72, 0x61, 0x63, 0x65, 0x00, 0x00, 0x00,  \\ t r a c e - - -
971  0x06, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x00,  \\ - a c c e p t -
972  0x00, 0x00, 0x0e, 0x61, 0x63, 0x63, 0x65, 0x70,  \\ - - - a c c e p
973  0x74, 0x2d, 0x63, 0x68, 0x61, 0x72, 0x73, 0x65,  \\ t - c h a r s e
974  0x74, 0x00, 0x00, 0x00, 0x0f, 0x61, 0x63, 0x63,  \\ t - - - - a c c
975  0x65, 0x70, 0x74, 0x2d, 0x65, 0x6e, 0x63, 0x6f,  \\ e p t - e n c o
976  0x64, 0x69, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x0f,  \\ d i n g - - - -
977  0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x2d, 0x6c,  \\ a c c e p t - l
978  0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x00,  \\ a n g u a g e -
979  0x00, 0x00, 0x0d, 0x61, 0x63, 0x63, 0x65, 0x70,  \\ - - - a c c e p
980  0x74, 0x2d, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x73,  \\ t - r a n g e s
981  0x00, 0x00, 0x00, 0x03, 0x61, 0x67, 0x65, 0x00,  \\ - - - - a g e -
982  0x00, 0x00, 0x05, 0x61, 0x6c, 0x6c, 0x6f, 0x77,  \\ - - - a l l o w
983  0x00, 0x00, 0x00, 0x0d, 0x61, 0x75, 0x74, 0x68,  \\ - - - - a u t h
984  0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f,  \\ o r i z a t i o
985  0x6e, 0x00, 0x00, 0x00, 0x0d, 0x63, 0x61, 0x63,  \\ n - - - - c a c
986  0x68, 0x65, 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72,  \\ h e - c o n t r
987  0x6f, 0x6c, 0x00, 0x00, 0x00, 0x0a, 0x63, 0x6f,  \\ o l - - - - c o
988  0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e,  \\ n n e c t i o n
989  0x00, 0x00, 0x00, 0x0c, 0x63, 0x6f, 0x6e, 0x74,  \\ - - - - c o n t
990  0x65, 0x6e, 0x74, 0x2d, 0x62, 0x61, 0x73, 0x65,  \\ e n t - b a s e
991  0x00, 0x00, 0x00, 0x10, 0x63, 0x6f, 0x6e, 0x74,  \\ - - - - c o n t
992  0x65, 0x6e, 0x74, 0x2d, 0x65, 0x6e, 0x63, 0x6f,  \\ e n t - e n c o
993  0x64, 0x69, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x10,  \\ d i n g - - - -
994  0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d,  \\ c o n t e n t -
995  0x6c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65,  \\ l a n g u a g e
996  0x00, 0x00, 0x00, 0x0e, 0x63, 0x6f, 0x6e, 0x74,  \\ - - - - c o n t
997  0x65, 0x6e, 0x74, 0x2d, 0x6c, 0x65, 0x6e, 0x67,  \\ e n t - l e n g
998  0x74, 0x68, 0x00, 0x00, 0x00, 0x10, 0x63, 0x6f,  \\ t h - - - - c o
999  0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x6c, 0x6f,  \\ n t e n t - l o
1000  0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00,  \\ c a t i o n - -
1001  0x00, 0x0b, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e,  \\ - - c o n t e n
1002  0x74, 0x2d, 0x6d, 0x64, 0x35, 0x00, 0x00, 0x00,  \\ t - m d 5 - - -
1003  0x0d, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74,  \\ - c o n t e n t
1004  0x2d, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x00, 0x00,  \\ - r a n g e - -
1005  0x00, 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e,  \\ - - c o n t e n
1006  0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x00, 0x00,  \\ t - t y p e - -
1007  0x00, 0x04, 0x64, 0x61, 0x74, 0x65, 0x00, 0x00,  \\ - - d a t e - -
1008  0x00, 0x04, 0x65, 0x74, 0x61, 0x67, 0x00, 0x00,  \\ - - e t a g - -
1009  0x00, 0x06, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74,  \\ - - e x p e c t
1010  0x00, 0x00, 0x00, 0x07, 0x65, 0x78, 0x70, 0x69,  \\ - - - - e x p i
1011  0x72, 0x65, 0x73, 0x00, 0x00, 0x00, 0x04, 0x66,  \\ r e s - - - - f
1012  0x72, 0x6f, 0x6d, 0x00, 0x00, 0x00, 0x04, 0x68,  \\ r o m - - - - h
1013  0x6f, 0x73, 0x74, 0x00, 0x00, 0x00, 0x08, 0x69,  \\ o s t - - - - i
1014  0x66, 0x2d, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x00,  \\ f - m a t c h -
1015  0x00, 0x00, 0x11, 0x69, 0x66, 0x2d, 0x6d, 0x6f,  \\ - - - i f - m o
1016  0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x2d, 0x73,  \\ d i f i e d - s
1017  0x69, 0x6e, 0x63, 0x65, 0x00, 0x00, 0x00, 0x0d,  \\ i n c e - - - -
1018  0x69, 0x66, 0x2d, 0x6e, 0x6f, 0x6e, 0x65, 0x2d,  \\ i f - n o n e -
1019  0x6d, 0x61, 0x74, 0x63, 0x68, 0x00, 0x00, 0x00,  \\ m a t c h - - -
1020  0x08, 0x69, 0x66, 0x2d, 0x72, 0x61, 0x6e, 0x67,  \\ - i f - r a n g
1021  0x65, 0x00, 0x00, 0x00, 0x13, 0x69, 0x66, 0x2d,  \\ e - - - - i f -
1022  0x75, 0x6e, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69,  \\ u n m o d i f i
1023  0x65, 0x64, 0x2d, 0x73, 0x69, 0x6e, 0x63, 0x65,  \\ e d - s i n c e
1024  0x00, 0x00, 0x00, 0x0d, 0x6c, 0x61, 0x73, 0x74,  \\ - - - - l a s t
1025  0x2d, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65,  \\ - m o d i f i e
1026  0x64, 0x00, 0x00, 0x00, 0x08, 0x6c, 0x6f, 0x63,  \\ d - - - - l o c
1027  0x61, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00,  \\ a t i o n - - -
1028  0x0c, 0x6d, 0x61, 0x78, 0x2d, 0x66, 0x6f, 0x72,  \\ - m a x - f o r
1029  0x77, 0x61, 0x72, 0x64, 0x73, 0x00, 0x00, 0x00,  \\ w a r d s - - -
1030  0x06, 0x70, 0x72, 0x61, 0x67, 0x6d, 0x61, 0x00,  \\ - p r a g m a -
1031  0x00, 0x00, 0x12, 0x70, 0x72, 0x6f, 0x78, 0x79,  \\ - - - p r o x y
1032  0x2d, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74,  \\ - a u t h e n t
1033  0x69, 0x63, 0x61, 0x74, 0x65, 0x00, 0x00, 0x00,  \\ i c a t e - - -
1034  0x13, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2d, 0x61,  \\ - p r o x y - a
1035  0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61,  \\ u t h o r i z a
1036  0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00, 0x05,  \\ t i o n - - - -
1037  0x72, 0x61, 0x6e, 0x67, 0x65, 0x00, 0x00, 0x00,  \\ r a n g e - - -
1038  0x07, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x72,  \\ - r e f e r e r
1039  0x00, 0x00, 0x00, 0x0b, 0x72, 0x65, 0x74, 0x72,  \\ - - - - r e t r
1040  0x79, 0x2d, 0x61, 0x66, 0x74, 0x65, 0x72, 0x00,  \\ y - a f t e r -
1041  0x00, 0x00, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65,  \\ - - - s e r v e
1042  0x72, 0x00, 0x00, 0x00, 0x02, 0x74, 0x65, 0x00,  \\ r - - - - t e -
1043  0x00, 0x00, 0x07, 0x74, 0x72, 0x61, 0x69, 0x6c,  \\ - - - t r a i l
1044  0x65, 0x72, 0x00, 0x00, 0x00, 0x11, 0x74, 0x72,  \\ e r - - - - t r
1045  0x61, 0x6e, 0x73, 0x66, 0x65, 0x72, 0x2d, 0x65,  \\ a n s f e r - e
1046  0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x00,  \\ n c o d i n g -
1047  0x00, 0x00, 0x07, 0x75, 0x70, 0x67, 0x72, 0x61,  \\ - - - u p g r a
1048  0x64, 0x65, 0x00, 0x00, 0x00, 0x0a, 0x75, 0x73,  \\ d e - - - - u s
1049  0x65, 0x72, 0x2d, 0x61, 0x67, 0x65, 0x6e, 0x74,  \\ e r - a g e n t
1050  0x00, 0x00, 0x00, 0x04, 0x76, 0x61, 0x72, 0x79,  \\ - - - - v a r y
1051  0x00, 0x00, 0x00, 0x03, 0x76, 0x69, 0x61, 0x00,  \\ - - - - v i a -
1052  0x00, 0x00, 0x07, 0x77, 0x61, 0x72, 0x6e, 0x69,  \\ - - - w a r n i
1053  0x6e, 0x67, 0x00, 0x00, 0x00, 0x10, 0x77, 0x77,  \\ n g - - - - w w
1054  0x77, 0x2d, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e,  \\ w - a u t h e n
1055  0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x00, 0x00,  \\ t i c a t e - -
1056  0x00, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64,  \\ - - m e t h o d
1057  0x00, 0x00, 0x00, 0x03, 0x67, 0x65, 0x74, 0x00,  \\ - - - - g e t -
1058  0x00, 0x00, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75,  \\ - - - s t a t u
1059  0x73, 0x00, 0x00, 0x00, 0x06, 0x32, 0x30, 0x30,  \\ s - - - - 2 0 0
1060  0x20, 0x4f, 0x4b, 0x00, 0x00, 0x00, 0x07, 0x76,  \\ - O K - - - - v
1061  0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x00, 0x00,  \\ e r s i o n - -
1062  0x00, 0x08, 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31,  \\ - - H T T P - 1
1063  0x2e, 0x31, 0x00, 0x00, 0x00, 0x03, 0x75, 0x72,  \\ - 1 - - - - u r
1064  0x6c, 0x00, 0x00, 0x00, 0x06, 0x70, 0x75, 0x62,  \\ l - - - - p u b
1065  0x6c, 0x69, 0x63, 0x00, 0x00, 0x00, 0x0a, 0x73,  \\ l i c - - - - s
1066  0x65, 0x74, 0x2d, 0x63, 0x6f, 0x6f, 0x6b, 0x69,  \\ e t - c o o k i
1067  0x65, 0x00, 0x00, 0x00, 0x0a, 0x6b, 0x65, 0x65,  \\ e - - - - k e e
1068  0x70, 0x2d, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x00,  \\ p - a l i v e -
1069  0x00, 0x00, 0x06, 0x6f, 0x72, 0x69, 0x67, 0x69,  \\ - - - o r i g i
1070  0x6e, 0x31, 0x30, 0x30, 0x31, 0x30, 0x31, 0x32,  \\ n 1 0 0 1 0 1 2
1071  0x30, 0x31, 0x32, 0x30, 0x32, 0x32, 0x30, 0x35,  \\ 0 1 2 0 2 2 0 5
1072  0x32, 0x30, 0x36, 0x33, 0x30, 0x30, 0x33, 0x30,  \\ 2 0 6 3 0 0 3 0
1073  0x32, 0x33, 0x30, 0x33, 0x33, 0x30, 0x34, 0x33,  \\ 2 3 0 3 3 0 4 3
1074  0x30, 0x35, 0x33, 0x30, 0x36, 0x33, 0x30, 0x37,  \\ 0 5 3 0 6 3 0 7
1075  0x34, 0x30, 0x32, 0x34, 0x30, 0x35, 0x34, 0x30,  \\ 4 0 2 4 0 5 4 0
1076  0x36, 0x34, 0x30, 0x37, 0x34, 0x30, 0x38, 0x34,  \\ 6 4 0 7 4 0 8 4
1077  0x30, 0x39, 0x34, 0x31, 0x30, 0x34, 0x31, 0x31,  \\ 0 9 4 1 0 4 1 1
1078  0x34, 0x31, 0x32, 0x34, 0x31, 0x33, 0x34, 0x31,  \\ 4 1 2 4 1 3 4 1
1079  0x34, 0x34, 0x31, 0x35, 0x34, 0x31, 0x36, 0x34,  \\ 4 4 1 5 4 1 6 4
1080  0x31, 0x37, 0x35, 0x30, 0x32, 0x35, 0x30, 0x34,  \\ 1 7 5 0 2 5 0 4
1081  0x35, 0x30, 0x35, 0x32, 0x30, 0x33, 0x20, 0x4e,  \\ 5 0 5 2 0 3 - N
1082  0x6f, 0x6e, 0x2d, 0x41, 0x75, 0x74, 0x68, 0x6f,  \\ o n - A u t h o
1083  0x72, 0x69, 0x74, 0x61, 0x74, 0x69, 0x76, 0x65,  \\ r i t a t i v e
1084  0x20, 0x49, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61,  \\ - I n f o r m a
1085  0x74, 0x69, 0x6f, 0x6e, 0x32, 0x30, 0x34, 0x20,  \\ t i o n 2 0 4 -
1086  0x4e, 0x6f, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x65,  \\ N o - C o n t e
1087  0x6e, 0x74, 0x33, 0x30, 0x31, 0x20, 0x4d, 0x6f,  \\ n t 3 0 1 - M o
1088  0x76, 0x65, 0x64, 0x20, 0x50, 0x65, 0x72, 0x6d,  \\ v e d - P e r m
1089  0x61, 0x6e, 0x65, 0x6e, 0x74, 0x6c, 0x79, 0x34,  \\ a n e n t l y 4
1090  0x30, 0x30, 0x20, 0x42, 0x61, 0x64, 0x20, 0x52,  \\ 0 0 - B a d - R
1091  0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x34, 0x30,  \\ e q u e s t 4 0
1092  0x31, 0x20, 0x55, 0x6e, 0x61, 0x75, 0x74, 0x68,  \\ 1 - U n a u t h
1093  0x6f, 0x72, 0x69, 0x7a, 0x65, 0x64, 0x34, 0x30,  \\ o r i z e d 4 0
1094  0x33, 0x20, 0x46, 0x6f, 0x72, 0x62, 0x69, 0x64,  \\ 3 - F o r b i d
1095  0x64, 0x65, 0x6e, 0x34, 0x30, 0x34, 0x20, 0x4e,  \\ d e n 4 0 4 - N
1096  0x6f, 0x74, 0x20, 0x46, 0x6f, 0x75, 0x6e, 0x64,  \\ o t - F o u n d
1097  0x35, 0x30, 0x30, 0x20, 0x49, 0x6e, 0x74, 0x65,  \\ 5 0 0 - I n t e
1098  0x72, 0x6e, 0x61, 0x6c, 0x20, 0x53, 0x65, 0x72,  \\ r n a l - S e r
1099  0x76, 0x65, 0x72, 0x20, 0x45, 0x72, 0x72, 0x6f,  \\ v e r - E r r o
1100  0x72, 0x35, 0x30, 0x31, 0x20, 0x4e, 0x6f, 0x74,  \\ r 5 0 1 - N o t
1101  0x20, 0x49, 0x6d, 0x70, 0x6c, 0x65, 0x6d, 0x65,  \\ - I m p l e m e
1102  0x6e, 0x74, 0x65, 0x64, 0x35, 0x30, 0x33, 0x20,  \\ n t e d 5 0 3 -
1103  0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x20,  \\ S e r v i c e -
1104  0x55, 0x6e, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61,  \\ U n a v a i l a
1105  0x62, 0x6c, 0x65, 0x4a, 0x61, 0x6e, 0x20, 0x46,  \\ b l e J a n - F
1106  0x65, 0x62, 0x20, 0x4d, 0x61, 0x72, 0x20, 0x41,  \\ e b - M a r - A
1107  0x70, 0x72, 0x20, 0x4d, 0x61, 0x79, 0x20, 0x4a,  \\ p r - M a y - J
1108  0x75, 0x6e, 0x20, 0x4a, 0x75, 0x6c, 0x20, 0x41,  \\ u n - J u l - A
1109  0x75, 0x67, 0x20, 0x53, 0x65, 0x70, 0x74, 0x20,  \\ u g - S e p t -
1110  0x4f, 0x63, 0x74, 0x20, 0x4e, 0x6f, 0x76, 0x20,  \\ O c t - N o v -
1111  0x44, 0x65, 0x63, 0x20, 0x30, 0x30, 0x3a, 0x30,  \\ D e c - 0 0 - 0
1112  0x30, 0x3a, 0x30, 0x30, 0x20, 0x4d, 0x6f, 0x6e,  \\ 0 - 0 0 - M o n
1113  0x2c, 0x20, 0x54, 0x75, 0x65, 0x2c, 0x20, 0x57,  \\ - - T u e - - W
1114  0x65, 0x64, 0x2c, 0x20, 0x54, 0x68, 0x75, 0x2c,  \\ e d - - T h u -
1115  0x20, 0x46, 0x72, 0x69, 0x2c, 0x20, 0x53, 0x61,  \\ - F r i - - S a
1116  0x74, 0x2c, 0x20, 0x53, 0x75, 0x6e, 0x2c, 0x20,  \\ t - - S u n - -
1117  0x47, 0x4d, 0x54, 0x63, 0x68, 0x75, 0x6e, 0x6b,  \\ G M T c h u n k
1118  0x65, 0x64, 0x2c, 0x74, 0x65, 0x78, 0x74, 0x2f,  \\ e d - t e x t -
1119  0x68, 0x74, 0x6d, 0x6c, 0x2c, 0x69, 0x6d, 0x61,  \\ h t m l - i m a
1120  0x67, 0x65, 0x2f, 0x70, 0x6e, 0x67, 0x2c, 0x69,  \\ g e - p n g - i
1121  0x6d, 0x61, 0x67, 0x65, 0x2f, 0x6a, 0x70, 0x67,  \\ m a g e - j p g
1122  0x2c, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x67,  \\ - i m a g e - g
1123  0x69, 0x66, 0x2c, 0x61, 0x70, 0x70, 0x6c, 0x69,  \\ i f - a p p l i
1124  0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x78,  \\ c a t i o n - x
1125  0x6d, 0x6c, 0x2c, 0x61, 0x70, 0x70, 0x6c, 0x69,  \\ m l - a p p l i
1126  0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x78,  \\ c a t i o n - x
1127  0x68, 0x74, 0x6d, 0x6c, 0x2b, 0x78, 0x6d, 0x6c,  \\ h t m l - x m l
1128  0x2c, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x70, 0x6c,  \\ - t e x t - p l
1129  0x61, 0x69, 0x6e, 0x2c, 0x74, 0x65, 0x78, 0x74,  \\ a i n - t e x t
1130  0x2f, 0x6a, 0x61, 0x76, 0x61, 0x73, 0x63, 0x72,  \\ - j a v a s c r
1131  0x69, 0x70, 0x74, 0x2c, 0x70, 0x75, 0x62, 0x6c,  \\ i p t - p u b l
1132  0x69, 0x63, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74,  \\ i c p r i v a t
1133  0x65, 0x6d, 0x61, 0x78, 0x2d, 0x61, 0x67, 0x65,  \\ e m a x - a g e
1134  0x3d, 0x67, 0x7a, 0x69, 0x70, 0x2c, 0x64, 0x65,  \\ - g z i p - d e
1135  0x66, 0x6c, 0x61, 0x74, 0x65, 0x2c, 0x73, 0x64,  \\ f l a t e - s d
1136  0x63, 0x68, 0x63, 0x68, 0x61, 0x72, 0x73, 0x65,  \\ c h c h a r s e
1137  0x74, 0x3d, 0x75, 0x74, 0x66, 0x2d, 0x38, 0x63,  \\ t - u t f - 8 c
1138  0x68, 0x61, 0x72, 0x73, 0x65, 0x74, 0x3d, 0x69,  \\ h a r s e t - i
1139  0x73, 0x6f, 0x2d, 0x38, 0x38, 0x35, 0x39, 0x2d,  \\ s o - 8 8 5 9 -
1140  0x31, 0x2c, 0x75, 0x74, 0x66, 0x2d, 0x2c, 0x2a,  \\ 1 - u t f - - -
1141  0x2c, 0x65, 0x6e, 0x71, 0x3d, 0x30, 0x2e         \\ - e n q - 0 -
1142};
1143</artwork>
1144</figure>
1145
1146<t>The entire contents of the name/value header block is compressed using zlib.  There is a single zlib stream for all name value pairs in one direction on a connection.   HTTP/2.0 uses a SYNC_FLUSH between each compressed frame.</t>
1147
1148<t>Implementation notes: the compression engine can be tuned to favor speed or size. Optimizing for size increases memory use and CPU consumption.  Because header blocks are generally small, implementors may want to reduce the window-size of the compression engine from the default 15bits (a 32KB window) to more like 11bits (a 2KB window).  The exact setting is chosen by the compressor, the decompressor will work with any setting.</t>
1149          </section>
1150        </section>
1151      </section>
1152    </section>
1153
1154    <section anchor="HTTPLayer" title="HTTP Layering over HTTP/2.0">
1155<t>HTTP/2.0 is intended to be as compatible as possible with current web-based applications. This means that, from the perspective of the server business logic or application API, the features of HTTP are unchanged. To achieve this, all of the application request and response header semantics are preserved, although the syntax of conveying those semantics has changed. Thus, the rules from the <xref target="RFC2616">HTTP/1.1 specification in RFC2616</xref> apply with the changes in the sections below.</t>
1156
1157      <section title="Connection Management">
1158<t>Clients SHOULD NOT open more than one HTTP/2.0 session to a given <xref target="RFC6454">origin</xref> concurrently.</t>
1159<t>Note that it is possible for one HTTP/2.0 session to be finishing (e.g. a GOAWAY message has been sent, but not all streams have finished), while another HTTP/2.0 session is starting.</t>
1160        <section title="Use of GOAWAY">
1161<t>HTTP/2.0 provides a GOAWAY message which can be used when closing a connection from either the client or server.  Without a server GOAWAY message, HTTP has a race condition where the client sends a request (a new SYN_STREAM)  just as the server is closing the connection, and the client cannot know if the server received the stream or not.  By using the last-stream-id in the GOAWAY, servers can indicate to the client if a request was processed or not.</t>
1162
1163<t>Note that some servers will choose to send the GOAWAY and immediately terminate the connection without waiting for active streams to finish.  The client will be able to determine this because HTTP/2.0 streams are determinstically closed.  This abrupt termination will force the client to heuristically decide whether to retry the pending requests.  Clients always need to be capable of dealing with this case because they must deal with accidental connection termination cases, which are the same as the server never having sent a GOAWAY.</t>
1164
1165<t>More sophisticated servers will use GOAWAY to implement a graceful teardown. They will send the GOAWAY and provide some time for the active streams to finish before terminating the connection.</t>
1166
1167<t>If a HTTP/2.0 client closes the connection, it should also send a GOAWAY message.  This allows the server to know if any server-push streams were received by the client.</t>
1168
1169<t>If the endpoint closing the connection has not received any SYN_STREAMs from the remote, the GOAWAY will contain a last-stream-id of 0.</t>
1170
1171        </section>
1172      </section>
1173
1174      <section title="HTTP Request/Response">
1175        <section title="Request">
1176<t>The client initiates a request by sending a SYN_STREAM frame.  For requests which do not contain a body, the SYN_STREAM frame MUST set the FLAG_FIN, indicating that the client intends to send no further data on this stream.  For requests which do contain a body, the SYN_STREAM will not contain the FLAG_FIN, and the body will follow the SYN_STREAM in a series of DATA frames. The last DATA frame will set the FLAG_FIN to indicate the end of the body.</t>
1177
1178<t>The SYN_STREAM Name/Value section will contain all of the HTTP headers which are associated with an HTTP request. The header block in HTTP/2.0 is mostly unchanged from today's HTTP header block, with the following differences:
1179<list>
1180<t>The first line of the request is unfolded into name/value pairs like other HTTP headers and MUST be present:
1181<list>
1182<t>":method" - the HTTP method for this request (e.g. "GET", "POST", "HEAD", etc)</t>
1183<t>":path" - the url-path for this url with "/" prefixed. (See <xref target="RFC1738">RFC1738</xref>).  For example, for "http://www.google.com/search?q=dogs" the path would be "/search?q=dogs".</t>
1184<t>":version" - the HTTP version of this request (e.g. "HTTP/1.1")</t>
1185</list>
1186</t>
1187<t>In addition, the following two name/value pairs must also be present in every request:
1188<list>
1189<t>":host" - the hostport (See <xref target="RFC1738">RFC1738</xref>) portion of the URL for this request (e.g. "www.google.com:1234"). This header is the same as the HTTP 'Host' header. </t>
1190<t>":scheme" - the scheme portion of the URL for this request (e.g. "https"))</t>
1191</list></t>
1192<t>Header names are all lowercase.</t>
1193<t>The Connection, Host, Keep-Alive, Proxy-Connection, and Transfer-Encoding headers are not valid and MUST not be sent.</t>
1194<t>User-agents MUST support gzip compression. Regardless of the Accept-Encoding sent by the user-agent, the server may always send content encoded with gzip or deflate encoding.</t>
1195<t>If a server receives a request where the sum of the data frame payload lengths does not equal the size of the Content-Length header, the server MUST return a 400 (Bad Request) error.</t>
1196<t>POST-specific changes:
1197<list>
1198<t>Although POSTs are inherently chunked, POST requests SHOULD also be accompanied by a Content-Length header.  There are two reasons for this:  First, it assists with upload progress meters for an improved user experience.  More importantly, failure to send a Content-Length header is incompatible with many existing HTTP server implementations.  Existing user agents do not omit the Content-Length header, and server implementations have come to depend upon this.</t>
1199</list>
1200</t>
1201</list>
1202</t>
1203
1204<t>The user-agent is free to prioritize requests as it sees fit. If the user-agent cannot make progress without receiving a resource, it should attempt to raise the priority of that resource. Resources such as images, SHOULD generally use the lowest priority.</t>
1205
1206<t>If a client sends a SYN_STREAM without all of the method, host, path, scheme, and version headers, the server MUST reply with a HTTP 400 Bad Request reply.</t>
1207        </section>
1208
1209        <section title="Response">
1210<t>The server responds to a client request with a SYN_REPLY frame. Symmetric to the client's upload stream, server will send data after the SYN_REPLY frame via a series of DATA frames, and the last data frame will contain the FLAG_FIN to indicate successful end-of-stream.  If a response (like a 202 or 204 response) contains no body, the SYN_REPLY frame may contain the FLAG_FIN flag to indicate no further data will be sent on the stream.</t>
1211
1212<t>
1213<list>
1214<t>The response status line is unfolded into name/value pairs like other HTTP headers and must be present:
1215<list>
1216<t>":status" - The HTTP response status code (e.g. "200" or "200 OK")</t>
1217<t>":version" - The HTTP response version (e.g. "HTTP/1.1")</t>
1218</list>
1219</t>
1220<t>All header names must be lowercase.</t>
1221<t>The Connection, Keep-Alive, Proxy-Connection, and Transfer-Encoding headers are not valid and MUST not be sent.</t>
1222<t>Responses MAY be accompanied by a Content-Length header for advisory purposes.  (e.g. for UI progress meters)</t>
1223<t>If a client receives a response where the sum of the data frame payload lengths does not equal the size of the Content-Length header, the client MUST ignore the content length header.</t>
1224</list>
1225</t>
1226
1227<t>If a client receives a SYN_REPLY without a status or without a version header, the client must reply with a RST_STREAM frame indicating a PROTOCOL ERROR.</t>
1228        </section>
1229
1230        <section title="Authentication" anchor="Authentication">
1231<t>When a client sends a request to an origin server that requires authentication, the server can reply with a "401 Unauthorized" response, and include a WWW-Authenticate challenge header that defines the authentication scheme to be used.  The client then retries the request with an Authorization header appropriate to the specified authentication scheme.</t>
1232
1233<t>There are four options for proxy authentication, Basic, Digest, NTLM and Negotiate (SPNEGO).  The first two options were defined in <xref target="RFC2617">RFC2617</xref>, and are stateless.  The second two options were developed by Microsoft and specified in <xref target="RFC4559">RFC4559</xref>, and are stateful; otherwise known as multi-round authentication, or connection authentication.</t>
1234
1235          <section title="Stateless Authentication">
1236<t>Stateless Authentication over HTTP/2.0 is identical to how it is performed over HTTP. If multiple HTTP/2.0 streams are concurrently sent to a single server, each will authenticate independently, similar to how two HTTP connections would independently authenticate to a proxy server.</t>
1237          </section>
1238
1239          <section title="Stateful Authentication">
1240<t>Unfortunately, the stateful authentication mechanisms were implemented and defined in a such a way that directly violates RFC2617 - they do not include a "realm" as part of the request.  This is problematic in HTTP/2.0 because it makes it impossible for a client to disambiguate two concurrent server authentication challenges.</t>
1241
1242<t>To deal with this case, HTTP/2.0 servers using Stateful Authentication MUST implement one of two changes:
1243<list>
1244<t>Servers can add a "realm=&lt;desired realm&gt;" header so that the two authentication requests can be disambiguated and run concurrently.  Unfortunately, given how these mechanisms work, this is probably not practical.</t>
1245<t>Upon sending the first stateful challenge response, the server MUST buffer and defer all further frames which are not part of completing the challenge until the challenge has completed.  Completing the authentication challenge may take multiple round trips.  Once the client receives a "401 Authenticate" response for a stateful authentication type, it MUST stop sending new requests to the server until the authentication has completed by receiving a non-401 response on at least one stream.</t>
1246</list>
1247</t>
1248          </section>
1249        </section>
1250      </section>
1251
1252      <section title="Server Push Transactions">
1253<t>HTTP/2.0 enables a server to send multiple replies to a client for a single request.  The rationale for this feature is that sometimes a server knows that it will need to send multiple resources in response to a single request.  Without server push features, the client must first download the primary resource, then discover the secondary resource(s), and request them.  Pushing of resources avoids the round-trip delay, but also creates a potential race where a server can be pushing content which a user-agent is in the process of requesting.  The following mechanics attempt to prevent the race condition while enabling the performance benefit.</t>
1254
1255<t>Browsers receiving a pushed response MUST validate that the server is authorized to push the URL using the <xref target="RFC6454">browser same-origin</xref> policy.  For example, a HTTP/2.0 connection to www.foo.com is generally not permitted to push a response for www.evil.com.</t>
1256
1257<t>If the browser accepts a pushed response (e.g. it does not send a RST_STREAM), the browser MUST attempt to cache the pushed response in same way that it would cache any other response.  This means validating the response headers and inserting into the disk cache.</t>
1258
1259<t>Because pushed responses have no request, they have no request headers associated with them.  At the framing layer, HTTP/2.0 pushed streams contain an "associated-stream-id" which indicates the requested stream for which the pushed stream is related.  The pushed stream inherits all of the headers from the associated-stream-id with the exception of ":host", ":scheme", and ":path", which are provided as part of the pushed response stream headers.  The browser MUST store these inherited and implied request headers with the cached resource.</t>
1260
1261<t>Implementation note:  With server push, it is theoretically possible for servers to push unreasonable amounts of content or resources to the user-agent.  Browsers MUST implement throttles to protect against unreasonable push attacks.</t>
1262
1263        <section title="Server implementation">
1264<t>When the server intends to push a resource to the user-agent, it opens a new stream by sending a unidirectional SYN_STREAM.  The SYN_STREAM MUST include an Associated-To-Stream-ID, and MUST set the FLAG_UNIDIRECTIONAL flag.  The SYN_STREAM MUST include headers for ":scheme", ":host", ":path", which represent the URL for the resource being pushed. Subsequent headers may follow in HEADERS frames. The purpose of the association is so that the user-agent can differentiate which request induced the pushed stream; without it, if the user-agent had two tabs open to the same page, each pushing unique content under a fixed URL, the user-agent would not be able to differentiate the requests.</t>
1265
1266<t>The Associated-To-Stream-ID must be the ID of an existing, open stream.  The reason for this restriction is to have a clear endpoint for pushed content.  If the user-agent requested a resource on stream 11, the server replies on stream 11.  It can push any number of additional streams to the client before sending a FLAG_FIN on stream 11.  However, once the originating stream is closed no further push streams may be associated with it.  The pushed streams do not need to be closed (FIN set) before the originating stream is closed, they only need to be created before the originating stream closes.</t>
1267
1268<t>It is illegal for a server to push a resource with the Associated-To-Stream-ID of 0.</t>
1269
1270<t>To minimize race conditions with the client, the SYN_STREAM for the pushed resources MUST be sent prior to sending any content which could allow the client to discover the pushed resource and request it.</t>
1271
1272<t>The server MUST only push resources which would have been returned from a GET request.</t>
1273
1274<t>Note:  If the server does not have all of the Name/Value Response headers available at the time it issues the HEADERS frame for the pushed resource, it may later use an additional HEADERS frame to augment the name/value pairs to be associated with the pushed stream.  The subsequent HEADERS frame(s) must not contain a header for ':host', ':scheme', or ':path' (e.g. the server can't change the identity of the resource to be pushed).  The HEADERS frame must not contain duplicate headers with a previously sent HEADERS frame.  The server must send a HEADERS frame including the scheme/host/port headers before sending any data frames on the stream.</t>
1275        </section>
1276
1277        <section title="Client implementation">
1278<t>When fetching a resource the client has 3 possibilities:
1279<list>
1280<t>the resource is not being pushed</t>
1281<t>the resource is being pushed, but the data has not yet arrived</t>
1282<t>the resource is being pushed, and the data has started to arrive</t>
1283</list>
1284</t>
1285
1286<t>When a SYN_STREAM and HEADERS frame which contains an Associated-To-Stream-ID is received, the client must not issue GET requests for the resource in the pushed stream, and instead wait for the pushed stream to arrive.  </t>
1287
1288<t>If a client receives a server push stream with stream-id 0, it
1289 MUST issue a <xref target="SessionErrorHandler">session error</xref> with the status code PROTOCOL_ERROR.</t>
1290
1291<t>When a client receives a SYN_STREAM from the server without a the ':host', ':scheme', and ':path' headers in the Name/Value section, it MUST reply with a RST_STREAM with error code HTTP_PROTOCOL_ERROR.</t>
1292
1293<t>To cancel individual server push streams, the client can issue a <xref target="StreamErrorHandler">stream error</xref> with error code CANCEL.  Upon receipt, the server MUST stop sending on this stream immediately (this is an Abrupt termination).</t>
1294
1295<t>To cancel all server push streams related to a request, the client may issue a <xref target="StreamErrorHandler">stream error</xref> with error code CANCEL on the associated-stream-id.  By cancelling that stream, the server MUST immediately stop sending frames for any streams with in-association-to for the original stream.</t>
1296
1297<t>If the server sends a HEADER frame containing duplicate headers with a previous HEADERS frame for the same stream, the client must issue a <xref target="StreamErrorHandler">stream error</xref> with error code PROTOCOL ERROR.</t>
1298
1299<t>If the server sends a HEADERS frame after sending a data frame for the same stream, the client MAY ignore the HEADERS frame.  Ignoring the HEADERS frame after a data frame prevents handling of HTTP's trailing headers (http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.40).</t>
1300        </section>
1301      </section>
1302
1303    </section>
1304
1305    <section title="Design Rationale and Notes">
1306<t>Authors' notes:  The notes in this section have no bearing on the HTTP/2.0 protocol as specified within this document, and none of these notes should be considered authoritative about how the protocol works.  However, these notes may prove useful in future debates about how to resolve protocol ambiguities or how to evolve the protocol going forward.  They may be removed before the final draft.</t>
1307
1308      <section title="Separation of Framing Layer and Application Layer">
1309<t>Readers may note that this specification sometimes blends the <xref target="FramingLayer">framing layer</xref> with requirements of a specific application - <xref target="HTTPLayer">HTTP</xref>.  This is reflected in the request/response nature of the streams, the definition of the HEADERS and compression contexts which are very similar to HTTP, and other areas as well.</t>
1310
1311<t>This blending is intentional - the primary goal of this protocol is to create a low-latency protocol for use with HTTP.  Isolating the two layers is convenient for description of the protocol and how it relates to existing HTTP implementations.  However, the ability to reuse the HTTP/2.0 framing layer is a non goal.</t>
1312      </section>
1313
1314      <section title="Error handling - Framing Layer">
1315<t>Error handling at the HTTP/2.0 layer splits errors into two groups:  Those that affect an individual HTTP/2.0 stream, and those that do not.</t>
1316
1317<t>When an error is confined to a single stream, but general framing is in tact, HTTP/2.0 attempts to use the RST_STREAM as a mechanism to invalidate the stream but move forward without aborting the connection altogether.</t>
1318
1319<t>For errors occuring outside of a single stream context, HTTP/2.0 assumes the entire session is hosed.  In this case, the endpoint detecting the error should initiate a connection close.</t>
1320      </section>
1321      <section title="One Connection Per Domain">
1322<t>HTTP/2.0 attempts to use fewer connections than other protocols have traditionally used.  The rationale for this behavior is because it is very difficult to provide a consistent level of service (e.g. TCP slow-start), prioritization, or optimal compression when the client is connecting to the server through multiple channels.</t>
1323
1324<t>Through lab measurements, we have seen consistent latency benefits by using fewer connections from the client.  The overall number of packets sent by HTTP/2.0 can be as much as 40% less than HTTP.  Handling large numbers of concurrent connections on the server also does become a scalability problem, and HTTP/2.0 reduces this load.</t>
1325
1326<t>The use of multiple connections is not without benefit, however.  Because HTTP/2.0 multiplexes multiple, independent streams onto a single stream, it creates a potential for head-of-line blocking problems at the transport level.  In tests so far, the negative effects of head-of-line blocking (especially in the presence of packet loss) is outweighed by the benefits of compression and prioritization.</t>
1327      </section>
1328      <section title="Fixed vs Variable Length Fields">
1329<t>HTTP/2.0 favors use of fixed length 32bit fields in cases where smaller, variable length encodings could have been used.  To some, this seems like a tragic waste of bandwidth.  HTTP/2.0 choses the simple encoding for speed and simplicity.</t>
1330
1331<t>The goal of HTTP/2.0 is to reduce latency on the network.  The overhead of HTTP/2.0 frames is generally quite low.  Each data frame is only an 8 byte overhead for a 1452 byte payload (~0.6%).  At the time of this writing, bandwidth is already plentiful, and there is a strong trend indicating that bandwidth will continue to increase.  With an average worldwide bandwidth of 1Mbps, and assuming that a variable length encoding could reduce the overhead by 50%, the latency saved by using a variable length encoding would be less than 100 nanoseconds.  More interesting are the effects when the larger encodings force a packet boundary, in which case a round-trip could be induced.  However, by addressing other aspects of HTTP/2.0 and TCP interactions, we believe this is completely mitigated.</t>
1332      </section>
1333      <section title="Compression Context(s)">
1334<t>When isolating the compression contexts used for communicating with multiple origins, we had a few choices to make.  We could have maintained a map (or list) of compression contexts usable for each origin.  The basic case is easy - each HEADERS frame would need to identify the context to use for that frame.  However, compression contexts are not cheap, so the lifecycle of each context would need to be bounded.  For proxy servers, where we could churn through many contexts, this would be a concern.  We considered using a static set of contexts, say 16 of them, which would bound the memory use.  We also considered dynamic contexts, which could be created on the fly, and would need to be subsequently destroyed.  All of these are complicated, and ultimately we decided that such a mechanism creates too many problems to solve.</t>
1335
1336<t>Alternatively, we've chosen the simple approach, which is to simply provide a flag for resetting the compression context.  For the common case (no proxy), this fine because most requests are to the same origin and we never need to reset the context.  For cases where we are using two different origins over a single HTTP/2.0 session, we simply reset the compression state between each transition.</t>
1337      </section>
1338      <section title="Unidirectional streams">
1339<t>Many readers notice that unidirectional streams are both a bit confusing in concept and also somewhat redundant.  If the recipient of a stream doesn't wish to send data on a stream, it could simply send a SYN_REPLY with the FLAG_FIN bit set.  The FLAG_UNIDIRECTIONAL is, therefore, not necessary.</t>
1340
1341<t>It is true that we don't need the UNIDIRECTIONAL markings.  It is added because it avoids the recipient of pushed streams from needing to send a set of empty frames (e.g. the SYN_STREAM w/ FLAG_FIN) which otherwise serve no purpose.</t>
1342      </section>
1343      <section title="Data Compression">
1344<t>Generic compression of data portion of the streams (as opposed to compression of the headers) without knowing the content of the stream is redundant.  There is no value in compressing a stream which is already compressed.  Because of this, HTTP/2.0 does allow data compression to be optional.  We included it because study of existing websites shows that many sites are not using compression as they should, and users suffer because of it.  We wanted a mechanism where, at the HTTP/2.0 layer, site administrators could simply force compression - it is better to compress twice than to not compress.</t>
1345
1346<t>Overall, however, with this feature being optional and sometimes redundant, it is unclear if it is useful at all.  We will likely remove it from the specification.</t>
1347      </section>
1348      <section title="Server Push">
1349<t>A subtle but important point is that server push streams must be declared before the associated stream is closed.  The reason for this is so that proxies have a lifetime for which they can discard information about previous streams.  If a pushed stream could associate itself with an already-closed stream, then endpoints would not have a specific lifecycle for when they could disavow knowledge of the streams which went before.</t>
1350      </section>
1351    </section>
1352
1353    <section title="Security Considerations">
1354      <section title="Use of Same-origin constraints">
1355<t>This specification uses the <xref target="RFC6454">same-origin policy</xref> in all cases where verification of content is required.</t>
1356      </section>
1357
1358      <section title="HTTP Headers and HTTP/2.0 Headers">
1359<t>At the application level, HTTP uses name/value pairs in its headers.  Because HTTP/2.0 merges the existing HTTP headers with HTTP/2.0 headers, there is a possibility that some HTTP applications already use a particular header name.  To avoid any conflicts, all headers introduced for layering HTTP over HTTP/2.0 are prefixed with ":".  ":" is not a valid sequence in HTTP header naming, preventing any possible conflict.</t>
1360      </section>
1361
1362      <section title="Cross-Protocol Attacks">
1363<t>By utilizing TLS, we believe that HTTP/2.0 introduces no new cross-protocol attacks.  TLS encrypts the contents of all transmission (except the handshake itself), making it difficult for attackers to control the data which could be used in a cross-protocol attack.</t>
1364      </section>
1365
1366      <section title="Server Push Implicit Headers">
1367<t>Pushed resources do not have an associated request.  In order for existing HTTP cache control validations (such as the Vary header) to work, however, all cached resources must have a set of request headers.  For this reason, browsers MUST be careful to inherit request headers from the associated stream for the push.  This includes the 'Cookie' header.</t>
1368      </section>
1369    </section>
1370
1371    <section title="Privacy Considerations">
1372      <section title="Long Lived Connections">
1373<t>HTTP/2.0 aims to keep connections open longer between clients and servers in order to reduce the latency when a user makes a request.  The maintenance of these connections over time could be used to expose private information.  For example, a user using a browser hours after the previous user stopped using that browser may be able to learn about what the previous user was doing.  This is a problem with HTTP in its current form as well, however the short lived connections make it less of a risk.</t>
1374      </section>
1375
1376      <section title="SETTINGS frame">
1377<t>The HTTP/2.0 SETTINGS frame allows servers to store out-of-band transmitted information about the communication between client and server on the client.  Although this is intended only to be used to reduce latency, renegade servers could use it as a mechanism to store identifying information about the client in future requests.</t>
1378
1379<t>Clients implementing privacy modes, such as Google Chrome's "incognito mode", may wish to disable client-persisted SETTINGS storage.</t>
1380
1381<t>Clients MUST clear persisted SETTINGS information when clearing the cookies.</t>
1382
1383<t>TODO: Put range maximums on each type of setting to limit inappropriate uses.</t>
1384      </section>
1385    </section>
1386
1387<section title="Requirements Notation">
1388  <t>
1389    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT",
1390    "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in
1391    <xref target="RFC2119">RFC 2119</xref>.
1392  </t>
1393</section>
1394
1395<section title="Acknowledgements">
1396  <t>This document includes substantial input from the following individuals:
1397  <list style="symbols">
1398    <t>
1399      Adam Langley, Wan-Teh Chang, Jim Morrison, Mark Nottingham, Alyssa Wilk, Costin Manolache,
1400      William Chan, Vitaliy Lvin, Joe Chan, Adam Barth, Ryan Hamilton, Gavin Peters, Kent Alstad,
1401      Kevin Lindsay, Paul Amer, Fan Yang, Jonathan Leighton (SPDY contributors).
1402    </t>
1403    <t>
1404      Gabriel Montenegro and Willy Tarreau (Upgrade mechanism)
1405    </t>
1406    <t>
1407      William Chan, Salvatore Loreto, Osama Mazahir, Gabriel Montenegro, Jitu Padhye, Roberto Peon,
1408      Rob Trace (Flow control principles)
1409    </t>
1410    <t>
1411      Mark Nottingham and Julian Reschke
1412    </t>
1413  </list>
1414  </t>
1415
1416</section>
1417</middle>
1418
1419  <back>
1420  <references title="Normative References">
1421
1422    <reference anchor='RFC0793'>
1423      <front>
1424        <title abbrev='Transmission Control Protocol'>Transmission Control Protocol</title>
1425        <author initials='J.' surname='Postel' fullname='Jon Postel'>
1426          <organization>University of Southern California (USC)/Information Sciences Institute</organization>
1427        </author>
1428        <date year='1981' day='1' month='September' />
1429      </front>
1430      <seriesInfo name='STD' value='7' />
1431      <seriesInfo name='RFC' value='793' />
1432    </reference>
1433
1434    <reference anchor='RFC1738'>
1435      <front>
1436        <title>Uniform Resource Locators (URL)</title>
1437        <author initials='T.' surname='Berners-Lee' fullname='Tim Berners-Lee'>
1438          <organization>CERN, World-Wide Web project</organization>
1439        </author>
1440        <author initials='L.' surname='Masinter' fullname='Larry Masinter'>
1441          <organization>Xerox PARC</organization>
1442        </author>
1443        <author initials='M.' surname='McCahill' fullname='Mark McCahill'>
1444          <organization>University of Minnesota, Computer and Information Services</organization>
1445        </author>
1446        <date year='1994' month='December' />
1447      </front>
1448      <seriesInfo name='RFC' value='1738' />
1449    </reference>
1450
1451    <reference anchor="RFC1950">
1452      <front>
1453        <title>ZLIB Compressed Data Format Specification version 3.3</title>
1454        <author initials="L.P." surname="Deutsch" fullname="L. Peter Deutsch">
1455          <organization>Aladdin Enterprises</organization>
1456          <address><email>ghost@aladdin.com</email></address>
1457        </author>
1458        <author initials="J.-L." surname="Gailly" fullname="Jean-Loup Gailly"/>
1459        <date month="May" year="1996"/>
1460      </front>
1461      <seriesInfo name="RFC" value="1950"/>
1462    </reference>
1463
1464    <reference anchor="RFC2119">
1465      <front>
1466        <title>Key words for use in RFCs to Indicate Requirement Levels</title>
1467        <author initials="S." surname="Bradner" fullname="Scott Bradner">
1468          <organization>Harvard University</organization>
1469          <address><email>sob@harvard.edu</email></address>
1470        </author>
1471        <date month="March" year="1997"/>
1472      </front>
1473      <seriesInfo name="BCP" value="14"/>
1474      <seriesInfo name="RFC" value="2119"/>
1475    </reference>
1476
1477    <reference anchor="RFC2616">
1478      <front>
1479        <title>Hypertext Transfer Protocol -- HTTP/1.1</title>
1480        <author initials="R." surname="Fielding" fullname="R. Fielding">
1481          <organization>University of California, Irvine</organization>
1482          <address><email>fielding@ics.uci.edu</email></address>
1483        </author>
1484        <author initials="J." surname="Gettys" fullname="J. Gettys">
1485          <organization>W3C</organization>
1486          <address><email>jg@w3.org</email></address>
1487        </author>
1488        <author initials="J." surname="Mogul" fullname="J. Mogul">
1489          <organization>Compaq Computer Corporation</organization>
1490          <address><email>mogul@wrl.dec.com</email></address>
1491        </author>
1492        <author initials="H." surname="Frystyk" fullname="H. Frystyk">
1493          <organization>MIT Laboratory for Computer Science</organization>
1494          <address><email>frystyk@w3.org</email></address>
1495        </author>
1496        <author initials="L." surname="Masinter" fullname="L. Masinter">
1497          <organization>Xerox Corporation</organization>
1498          <address><email>masinter@parc.xerox.com</email></address>
1499        </author>
1500        <author initials="P." surname="Leach" fullname="P. Leach">
1501          <organization>Microsoft Corporation</organization>
1502          <address><email>paulle@microsoft.com</email></address>
1503        </author>
1504        <author initials="T." surname="Berners-Lee" fullname="T. Berners-Lee">
1505          <organization>W3C</organization>
1506          <address><email>timbl@w3.org</email></address>
1507        </author>
1508        <date month="June" year="1999"/>
1509      </front>
1510      <seriesInfo name="RFC" value="2616"/>
1511    </reference>
1512
1513    <reference anchor="RFC2617">
1514      <front>
1515        <title abbrev="HTTP Authentication">HTTP Authentication: Basic and Digest Access Authentication</title>
1516        <author initials="J." surname="Franks" fullname="John Franks">
1517          <organization>Northwestern University, Department of Mathematics</organization>
1518          <address><email>john@math.nwu.edu</email></address>
1519        </author>
1520        <author initials="P.M." surname="Hallam-Baker" fullname="Phillip M. Hallam-Baker">
1521          <organization>Verisign Inc.</organization>
1522          <address><email>pbaker@verisign.com</email></address>
1523        </author>
1524        <author initials="J.L." surname="Hostetler" fullname="Jeffery L. Hostetler">
1525          <organization>AbiSource, Inc.</organization>
1526          <address><email>jeff@AbiSource.com</email></address>
1527        </author>
1528        <author initials="S.D." surname="Lawrence" fullname="Scott D. Lawrence">
1529          <organization>Agranat Systems, Inc.</organization>
1530          <address><email>lawrence@agranat.com</email></address>
1531        </author>
1532        <author initials="P.J." surname="Leach" fullname="Paul J. Leach">
1533          <organization>Microsoft Corporation</organization>
1534          <address><email>paulle@microsoft.com</email></address>
1535        </author>
1536        <author initials="A." surname="Luotonen" fullname="Ari Luotonen">
1537          <organization>Netscape Communications Corporation</organization>
1538        </author>
1539        <author initials="L." surname="Stewart" fullname="Lawrence C. Stewart">
1540          <organization>Open Market, Inc.</organization>
1541          <address><email>stewart@OpenMarket.com</email></address>
1542        </author>
1543        <date month="June" year="1999"/>
1544      </front>
1545      <seriesInfo name="RFC" value="2617"/>
1546    </reference>
1547
1548    <reference anchor="RFC4559">
1549      <front>
1550        <title>SPNEGO-based Kerberos and NTLM HTTP Authentication in Microsoft Windows</title>
1551        <author initials="K." surname="Jaganathan" fullname="K. Jaganathan"/>
1552        <author initials="L." surname="Zhu" fullname="L. Zhu"/>
1553        <author initials="J." surname="Brezak" fullname="J. Brezak"/>
1554        <date year="2006" month="June"/>
1555      </front>
1556      <seriesInfo name="RFC" value="4559"/>
1557    </reference>
1558
1559    <reference anchor='RFC5246'>
1560      <front>
1561        <title>The Transport Layer Security (TLS) Protocol Version 1.2</title>
1562        <author initials='T.' surname='Dierks' fullname='T. Dierks'/>
1563        <author initials='E.' surname='Rescorla' fullname='E. Rescorla'/>
1564        <date year='2008' month='August' />
1565      </front>
1566      <seriesInfo name='RFC' value='5246' />
1567    </reference>
1568
1569    <reference anchor='RFC6454'>
1570      <front>
1571        <title>The Web Origin Concept</title>
1572        <author initials='A.' surname='Barth' fullname='A. Barth'/>
1573        <date year='2011' month='December' />
1574      </front>
1575      <seriesInfo name='RFC' value='6454' />
1576    </reference>
1577
1578    <reference anchor="TLSNPN">
1579      <front>
1580        <title>TLS Next Protocol Negotiation</title>
1581        <author initials="A." surname="Langley"/>
1582        <date year='2010' month='August' />
1583      </front>
1584      <seriesInfo name='Internet-Draft' value='draft-agl-tls-nextprotoneg-01' />
1585    </reference>
1586
1587    <reference anchor="ASCII">
1588      <front>
1589        <title>US-ASCII. Coded Character Set - 7-Bit American Standard Code for Information Interchange. Standard ANSI X3.4-1986, ANSI, 1986.</title>
1590        <author/>
1591        <date/>
1592      </front>
1593    </reference>
1594
1595    <reference anchor="UDELCOMPRESSION" target="http://www.eecis.udel.edu/~amer/PEL/poc/pdf/SPDY-Fan.pdf">
1596      <front>
1597        <title>A Methodology to Derive SPDY's Initial Dictionary for Zlib Compression</title>
1598        <author initials="F." surname="Yang"></author>
1599        <author initials="P." surname="Amer"></author>
1600        <author initials="J." surname="Leighton"></author>
1601        <date/>
1602      </front>
1603    </reference>
1604    <reference anchor='HTTP-p1'>
1605      <front>
1606        <title>Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing</title>
1607        <author initials='R.' surname='Fielding' fullname='Roy Fielding'></author>
1608        <author initials='J.' surname='Reschke' fullname='Julian Reschke'></author>
1609        <date month='October' day='4' year='2012' />
1610        <abstract><t>The Hypertext Transfer Protocol (HTTP) is an application-level protocol for distributed, collaborative, hypertext information systems.  HTTP has been in use by the World Wide Web global information initiative since 1990.  This document provides an overview of HTTP architecture and its associated terminology, defines the "http" and "https" Uniform Resource Identifier (URI) schemes, defines the HTTP/1.1 message syntax and parsing requirements, and describes general security concerns for implementations.</t></abstract>
1611      </front>
1612      <seriesInfo name='Internet-Draft' value='draft-ietf-httpbis-p1-messaging-21' />
1613      <format type='TXT'
1614              target='http://www.ietf.org/internet-drafts/draft-ietf-httpbis-p1-messaging-21.txt' />
1615    </reference>
1616    <reference anchor='HTTP-p2'>
1617      <front>
1618        <title>Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content</title>
1619        <author initials='R.' surname='Fielding' fullname='Roy Fielding'></author>
1620        <author initials='J.' surname='Reschke' fullname='Julian Reschke'></author>
1621        <date month='October' day='4' year='2012' />
1622        <abstract><t>The Hypertext Transfer Protocol (HTTP) is an application-level protocol for distributed, collaborative, hypertext information systems.  This document defines the semantics of HTTP/1.1 messages, as expressed by request methods, request header fields, response status codes, and response header fields, along with the payload of messages (metadata and body content) and mechanisms for content negotiation.</t></abstract>
1623      </front>
1624      <seriesInfo name='Internet-Draft' value='draft-ietf-httpbis-p2-semantics-21' />
1625      <format type='TXT'
1626              target='http://www.ietf.org/internet-drafts/draft-ietf-httpbis-p2-semantics-21.txt' />
1627    </reference>
1628  </references>
1629
1630<section title="Change Log (to be removed by RFC Editor before publication)" anchor="change.log">
1631
1632<section title="Since draft-ietf-httpbis-http2-01" anchor="changes.since.draft-ietf-httpbis-http2-01">
1633<t>
1634  None yet
1635</t>
1636</section>
1637<section title="Since draft-ietf-httpbis-http2-00" anchor="changes.since.draft-ietf-httpbis-http2-00">
1638<t>
1639  Changed title throughout.
1640</t>
1641<t>
1642  Removed section on Incompatibilities with SPDY draft#2.
1643</t>
1644<t>
1645  Changed INTERNAL_ERROR on GOAWAY to have a value of 2 <eref
1646  target="https://groups.google.com/forum/?fromgroups#!topic/spdy-dev/cfUef2gL3iU"/>.
1647</t>
1648<t>
1649  Replaced abstract and introduction.
1650</t>
1651<t>
1652  Added section on starting HTTP/2.0, including upgrade mechanism.
1653</t>
1654<t>
1655  Removed unused references.
1656</t>
1657<t>
1658  Added <xref target="fc-principles">flow control principles</xref> based on <eref
1659  target="http://tools.ietf.org/html/draft-montenegro-httpbis-http2-fc-principles-01"/>.
1660</t>
1661</section>
1662<section title="Since draft-mbelshe-httpbis-spdy-00" anchor="changes.since.draft-mbelshe-httpbis-spdy-00">
1663<t>
1664  Adopted as base for draft-ietf-httpbis-http2.
1665</t>
1666<t>
1667  Updated authors/editors list.
1668</t>
1669<t>
1670  Added status note.
1671</t>
1672</section>
1673
1674</section>
1675
1676  </back>
1677</rfc>
1678
Note: See TracBrowser for help on using the repository browser.