HTTPbis Working Group M. Belshe Internet-Draft Twist Expires: June 1, 2013 R. Peon Google, Inc M. Thomson, Ed. Microsoft A. Melnikov, Ed. Isode Ltd November 28, 2012 SPDY Protocol draft-ietf-httpbis-http2-00 Abstract This document describes SPDY, a protocol designed for low-latency transport of content over the World Wide Web. SPDY introduces two layers of protocol. The lower layer is a general purpose framing layer which can be used atop a reliable transport (likely TCP) for multiplexed, prioritized, and compressed data communication of many concurrent streams. The upper layer of the protocol provides HTTP- like RFC2616 [RFC2616] semantics for compatibility with existing HTTP application servers. Editorial Note (To be removed by RFC Editor) This draft is a work-in-progress, and does not yet reflect Working Group consensus. This first draft uses the SPDY Protocol as a starting point, as per the Working Group's charter. Future drafts will add, remove and change text, based upon the Working Group's decisions. Discussion of this draft takes place on the HTTPBIS working group mailing list (ietf-http-wg@w3.org), which is archived at <http://lists.w3.org/Archives/Public/ietf-http-wg/>. The current issues list is at <http://tools.ietf.org/wg/httpbis/trac/report/21> and related documents (including fancy diffs) can be found at <http://tools.ietf.org/wg/httpbis/>. The changes in this draft are summarized in Appendix A.1. Status of This Memo This Internet-Draft is submitted in full conformance with the Belshe, et al. Expires June 1, 2013 [Page 1]

Internet-Draft SPDY November 2012 provisions of BCP 78 and BCP 79. Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet- Drafts is at http://datatracker.ietf.org/drafts/current/. Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress." This Internet-Draft will expire on June 1, 2013. Copyright Notice Copyright (c) 2012 IETF Trust and the persons identified as the document authors. All rights reserved. This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (http://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License. Table of Contents 1. Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.1. Document Organization . . . . . . . . . . . . . . . . . . 4 1.2. Definitions . . . . . . . . . . . . . . . . . . . . . . . 5 2. SPDY Framing Layer . . . . . . . . . . . . . . . . . . . . . . 5 2.1. Session (Connections) . . . . . . . . . . . . . . . . . . 5 2.2. Framing . . . . . . . . . . . . . . . . . . . . . . . . . 5 2.2.1. Control frames . . . . . . . . . . . . . . . . . . . . 6 2.2.2. Data frames . . . . . . . . . . . . . . . . . . . . . 7 2.3. Streams . . . . . . . . . . . . . . . . . . . . . . . . . 8 2.3.1. Stream frames . . . . . . . . . . . . . . . . . . . . 8 2.3.2. Stream creation . . . . . . . . . . . . . . . . . . . 8 2.3.3. Stream priority . . . . . . . . . . . . . . . . . . . 9 2.3.4. Stream headers . . . . . . . . . . . . . . . . . . . . 9 2.3.5. Stream data exchange . . . . . . . . . . . . . . . . . 10 2.3.6. Stream half-close . . . . . . . . . . . . . . . . . . 10 2.3.7. Stream close . . . . . . . . . . . . . . . . . . . . . 10 2.4. Error Handling . . . . . . . . . . . . . . . . . . . . . . 11 Belshe, et al. Expires June 1, 2013 [Page 2]

Internet-Draft SPDY November 2012 1 . Overview 1.1 . Document Organization Section 2), which multiplexes a TCP connection into independent, length-prefixed frames, and an HTTP layer (Section 3), 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 Belshe, et al. Expires June 1, 2013 [Page 4]

Internet-Draft SPDY November 2012 has not been a goal. The framing layer is tailored to the needs of the HTTP protocol and server push. 1.2 . Definitions 2 . SPDY Framing Layer 2.1 . Session (Connections) RFC0793]. The client is the TCP connection initiator. SPDY connections are persistent connections. 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 GOAWAY (Section 2.6.6) frame so that the endpoints can reliably determine if requests finished before the close. 2.2 . Framing Section 2.2.1) and data frames (Section 2.2.2). Frames always have a common header which is 8 bytes in length. Belshe, et al. Expires June 1, 2013 [Page 5]

Internet-Draft SPDY November 2012 The first bit is a control bit indicating whether a frame is a control frame or data frame. Control frames carry a version number, 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. All integer values, including length, version, and type, are in network byte order. SPDY does not enforce alignment of types in dynamically sized frames. 2.2.1 . Control frames Belshe, et al. Expires June 1, 2013 [Page 6]

Internet-Draft SPDY November 2012 2.2.2 . Data frames Section 2.3.7) below. 0x02 = FLAG_COMPRESS - indicates that the data in this frame has been compressed. 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. Data: The variable-length data payload; the length was defined in the length field. Data frame processing requirements: If an endpoint receives a data frame for a stream-id which is not open and the endpoint has not sent a GOAWAY (Section 2.6.6) frame, it MUST send issue a stream error (Section 2.4.2) with the error code INVALID_STREAM for the stream-id. 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 stream error (Section 2.4.2) with the status code PROTOCOL_ERROR for the stream-id. Implementors note: If an endpoint receives multiple data frames for invalid stream-ids, it MAY close the session. All SPDY 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 Belshe, et al. Expires June 1, 2013 [Page 7]

Internet-Draft SPDY November 2012 dedicated to use within that stream. Endpoints are encouraged to use application level compression rather than SPDY stream level compression. Each SPDY 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). 2.3 . Streams 2.3.1 . Stream frames 2.3.2 . Stream creation Section 2.6.1). 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. 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 Belshe, et al. Expires June 1, 2013 [Page 8]

Internet-Draft SPDY November 2012 previously received SYN_STREAM, it MUST issue a session error (Section 2.4.1) with the status PROTOCOL_ERROR. 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 stream error (Section 2.4.2) with the status code PROTOCOL_ERROR. Upon receipt of a SYN_STREAM, the recipient can reject the stream by sending a stream error (Section 2.4.2) 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. 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. 2.3.2.1 . Unidirectional streams Section 2.3.6) state. 2.3.2.2 . Bidirectional streams 2.3.3 . Stream priority 2.3.4 . Stream headers Section 2.3.7) or half-closed (Section 2.3.6), each side may send HEADERS frame(s) containing the header data. Header data can be sent in multiple HEADERS frames, and Belshe, et al. Expires June 1, 2013 [Page 9]

Internet-Draft SPDY November 2012 HEADERS frames may be interleaved with data frames. 2.3.5 . Stream data exchange Section 2.6.1), SYN_REPLY (Section 2.6.2), HEADERS (Section 2.6.7) or a DATA (Section 2.2.2) frame. Once the FLAG_FIN has been sent, the stream is considered to be half-closed. 2.3.6 . Stream half-close 2.3.7 . Stream close Section 2.4.2) 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. If an endpoint receives a data frame after the stream is closed, it Belshe, et al. Expires June 1, 2013 [Page 10]

Internet-Draft SPDY November 2012 must send a RST_STREAM to the sender with the status PROTOCOL_ERROR. 2.4 . Error Handling Section 2.4.1. Any reference to "issue a stream error" refers to Section 2.4.2. 2.4.1 . Session Error Handling Section 2.6.6) 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. 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. 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. 2.4.2 . Stream Error Handling Section 2.6.3) 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 SPDY session to be closed. If an endpoint has multiple RST_STREAM frames to send in succession Belshe, et al. Expires June 1, 2013 [Page 11]

Internet-Draft SPDY November 2012 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). 2.5 . Data flow 2.6 . Control frame types 2.6.1 . SYN_STREAM Section 2.3.2) +------------------------------------+ |1| version | 1 | +------------------------------------+ | Flags (8) | Length (24 bits) | +------------------------------------+ |X| Stream-ID (31bits) | +------------------------------------+ |X| Associated-To-Stream-ID (31bits) | +------------------------------------+ | Pri|Unused | Slot | | +-------------------+ | | Number of Name/Value pairs (int32) | <+ +------------------------------------+ | | Length of name (int32) | | This section is the +------------------------------------+ | "Name/Value Header | Name (string) | | Block", and is +------------------------------------+ | compressed. | Length of value (int32) | | +------------------------------------+ | | Value (string) | | +------------------------------------+ | | (repeats) | <+ Flags: Flags related to this frame. Valid flags are: 0x01 = FLAG_FIN - marks this frame as the last frame to be transmitted on this stream and puts the sender in the half-closed (Section 2.3.6) state. Belshe, et al. Expires June 1, 2013 [Page 12]

Internet-Draft SPDY November 2012 0x02 = FLAG_UNIDIRECTIONAL - a stream created with this flag puts the recipient in the half-closed (Section 2.3.6) state. 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. Stream-ID: The 31-bit identifier for this stream. This stream-id will be used in frames which are part of this stream. 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. Priority: A 3-bit priority (Section 2.3.3) field. Unused: 5 bits of unused space, reserved for future use. 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. see CREDENTIAL frame (Section 2.6.9). The value 0 means no client certificate should be associated with this stream. Name/Value Header Block: A set of name/value pairs carried as part of the SYN_STREAM. see Name/Value Header Block (Section 2.6.10). 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 the Control Frames section (Section 2.2.1). 2.6.2 . SYN_REPLY Belshe, et al. Expires June 1, 2013 [Page 13]

Internet-Draft SPDY November 2012 +------------------------------------+ |1| version | 2 | +------------------------------------+ | Flags (8) | Length (24 bits) | +------------------------------------+ |X| Stream-ID (31bits) | +------------------------------------+ | Number of Name/Value pairs (int32) | <+ +------------------------------------+ | | Length of name (int32) | | This section is the +------------------------------------+ | "Name/Value Header | Name (string) | | Block", and is +------------------------------------+ | compressed. | Length of value (int32) | | +------------------------------------+ | | Value (string) | | +------------------------------------+ | | (repeats) | <+ Flags: Flags related to this frame. Valid flags are: 0x01 = FLAG_FIN - marks this frame as the last frame to be transmitted on this stream and puts the sender in the half-closed (Section 2.3.6) state. 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. Stream-ID: The 31-bit identifier for this stream. If an endpoint receives multiple SYN_REPLY frames for the same active stream ID, it MUST issue a stream error (Section 2.4.2) with the error code STREAM_IN_USE. Name/Value Header Block: A set of name/value pairs carried as part of the SYN_STREAM. see Name/Value Header Block (Section 2.6.10). 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 the Control Frames section (Section 2.2.1). 2.6.3 . RST_STREAM Belshe, et al. Expires June 1, 2013 [Page 14]

Internet-Draft SPDY November 2012 indicates an error or that the recipient did not want to accept the stream, so the stream should be closed. +----------------------------------+ |1| version | 3 | +----------------------------------+ | Flags (8) | 8 | +----------------------------------+ |X| Stream-ID (31bits) | +----------------------------------+ | Status code | +----------------------------------+ Flags: Flags related to this frame. RST_STREAM does not define any flags. This value must be 0. 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. Stream-ID: The 31-bit identifier for this stream. Status code: (32 bits) An indicator for why the stream is being terminated.The following status codes are defined: 1 - PROTOCOL_ERROR. This is a generic error, and should only be used if a more specific error is not available. 2 - INVALID_STREAM. This is returned when a frame is received for a stream which is not active. 3 - REFUSED_STREAM. Indicates that the stream was refused before any processing has been done on the stream. 4 - UNSUPPORTED_VERSION. Indicates that the recipient of a stream does not support the SPDY version requested. 5 - CANCEL. Used by the creator of a stream to indicate that the stream is no longer needed. 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. 7 - FLOW_CONTROL_ERROR. The endpoint detected that its peer violated the flow control protocol. Belshe, et al. Expires June 1, 2013 [Page 15]

Internet-Draft SPDY November 2012 8 - STREAM_IN_USE. The endpoint received a SYN_REPLY for a stream already open. 9 - STREAM_ALREADY_CLOSED. The endpoint received a data or SYN_REPLY frame for a stream which is half closed. 10 - INVALID_CREDENTIALS. The server received a request for a resource whose origin does not have valid credentials in the client certificate vector. 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. Note: 0 is not a valid status code for a RST_STREAM. 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. 2.6.4 . SETTINGS RFC6454]). 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. Belshe, et al. Expires June 1, 2013 [Page 16]

Internet-Draft SPDY November 2012 +----------------------------------+ |1| version | 4 | +----------------------------------+ | Flags (8) | Length (24 bits) | +----------------------------------+ | Number of entries | +----------------------------------+ | ID/Value Pairs | | ... | Control bit: The control bit is always 1 for this message. Version: The SPDY version number. Type: The message type for a SETTINGS message is 4. 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. 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. Number of entries: A 32-bit value representing the number of ID/value pairs in this message. ID: A 32-bit ID number, comprised of 8 bits of flags and 24 bits of unique ID. ID.flags: 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. 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. Belshe, et al. Expires June 1, 2013 [Page 17]

Internet-Draft SPDY November 2012 Because persistence is only implemented on the client, this flag is only sent by the client. Defined IDs: 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. 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. 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. 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. 5 - SETTINGS_CURRENT_CWND allows the sender to inform the remote endpoint of the current TCP CWND value. 6 - SETTINGS_DOWNLOAD_RETRANS_RATE allows the sender to inform the remote endpoint the retransmission rate (bytes retransmitted / total bytes transmitted). 7 - SETTINGS_INITIAL_WINDOW_SIZE allows the sender to inform the remote endpoint the initial window size (in bytes) for new streams. 8 - SETTINGS_CLIENT_CERTIFICATE_VECTOR_SIZE allows the server to inform the client if the new size of the client certificate vector. Value: A 32-bit value. The message is intentionally extensible for future information which may improve client-server communications. The sender does not need Belshe, et al. Expires June 1, 2013 [Page 18]

Internet-Draft SPDY November 2012 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. 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. 2.6.5 . PING Belshe, et al. Expires June 1, 2013 [Page 19]

Internet-Draft SPDY November 2012 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. If a server receives an even numbered PING which it did not initiate, it must ignore the PING. If a client receives an odd numbered PING which it did not initiate, it must ignore the PING. 2.6.6 . GOAWAY Belshe, et al. Expires June 1, 2013 [Page 20]

Internet-Draft SPDY November 2012 +----------------------------------+ Control bit: The control bit is always 1 for this message. Version: The SPDY version number. Type: The message type for a GOAWAY message is 7. Length: This frame is always 8 bytes long. 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. Status: The reason for closing the session. 0 - OK. This is a normal session teardown. 1 - PROTOCOL_ERROR. This is a generic error, and should only be used if a more specific error is not available. 11 - INTERNAL_ERROR. This is a generic error which can be used when the implementation has internally failed, not due to anything in the protocol. 2.6.7 . HEADERS Belshe, et al. Expires June 1, 2013 [Page 21]

Internet-Draft SPDY November 2012 +------------------------------------+ |1| version | 8 | +------------------------------------+ | Flags (8) | Length (24 bits) | +------------------------------------+ |X| Stream-ID (31bits) | +------------------------------------+ | Number of Name/Value pairs (int32) | <+ +------------------------------------+ | | Length of name (int32) | | This section is the +------------------------------------+ | "Name/Value Header | Name (string) | | Block", and is +------------------------------------+ | compressed. | Length of value (int32) | | +------------------------------------+ | | Value (string) | | +------------------------------------+ | | (repeats) | <+ Flags: Flags related to this frame. Valid flags are: 0x01 = FLAG_FIN - marks this frame as the last frame to be transmitted on this stream and puts the sender in the half-closed (Section 2.3.6) state. 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). Stream-ID: The stream this HEADERS block is associated with. Name/Value Header Block: A set of name/value pairs carried as part of the SYN_STREAM. see Name/Value Header Block (Section 2.6.10). 2.6.8 . WINDOW_UPDATE Section 2.4.2) with the status code FLOW_CONTROL_ERROR for the stream. Belshe, et al. Expires June 1, 2013 [Page 22]

Internet-Draft SPDY November 2012 Flow control in SPDY 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. +----------------------------------+ |1| version | 9 | +----------------------------------+ | 0 (flags) | 8 (length) | +----------------------------------+ |X| Stream-ID (31-bits) | +----------------------------------+ |X| Delta-Window-Size (31-bits) | +----------------------------------+ Control bit: The control bit is always 1 for this message. Version: The SPDY version number. Type: The message type for a WINDOW_UPDATE message is 9. Length: The length field is always 8 for this frame (there are 8 bytes after the length field). Stream-ID: The stream ID that this WINDOW_UPDATE control frame is for. 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. 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. When a SPDY connection is first established, the default initial Belshe, et al. Expires June 1, 2013 [Page 23]

Internet-Draft SPDY November 2012 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: immediately send RST_STREAM with FLOW_CONTROL_ERROR status code. 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. 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. 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. 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. 2.6.9 . CREDENTIAL Belshe, et al. Expires June 1, 2013 [Page 24]

Internet-Draft SPDY November 2012 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. The server is required to maintain a vector of client certificates associated with a SPDY 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 CREDNETIAL 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. TLS renegotiation with client authentication is incompatible with SPDY given the multiplexed nature of SPDY. 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. +----------------------------------+ |1|000000000000001|0000000000001011| +----------------------------------+ | flags (8) | Length (24 bits) | +----------------------------------+ | Slot (16 bits) | | +-----------------+ | | Proof Length (32 bits) | +----------------------------------+ | Proof | +----------------------------------+ <+ | Certificate Length (32 bits) | | +----------------------------------+ | Repeated until end of frame | Certificate | | +----------------------------------+ <+ Slot: The index in the server's client certificate vector where this certificate should be stored. If there is already a certificate Belshe, et al. Expires June 1, 2013 [Page 25]

Internet-Draft SPDY November 2012 stored at this index, it will be overwritten. The index is one based, not zero based; zero is an invalid slot index. Proof: Cryptographic proof that the client has possession of the private key associated with the certificate. The format is a TLS digitally-signed element ([RFC5246], Section 4.7). The signature algorithm must be the same as that used in the CertificateVerify message. However, since the MD5+SHA1 signature type used in TLS 1.0 connections can not be correctly encoded in a digitally-signed element, SHA1 must be used when MD5+SHA1 was used in the SSL connection. The signature is calculated over a 32 byte TLS extractor value (http://tools.ietf.org/html/rfc5705) with a label of "EXPORTER SPDY certificate proof" using the empty string as context. ForRSA certificates the signature would be a PKCS#1 v1.5 signature. For ECDSA, it would be an ECDSA-Sig-Value (http://tools.ietf.org/html/rfc5480#appendix-A). For a 1024-bit RSA key, the CREDENTIAL message would be ~500 bytes. 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. 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, SPDY does not allow the server to request different client authentication for different resources in the same origin. If the server receives an invalid CREDENTIAL frame, it MUST respond with a GOAWAY frame and shutdown the session. 2.6.10 . Name/Value Header Block Belshe, et al. Expires June 1, 2013 [Page 26]

Internet-Draft SPDY November 2012 +------------------------------------+ | Number of Name/Value pairs (int32) | +------------------------------------+ | Length of name (int32) | +------------------------------------+ | Name (string) | +------------------------------------+ | Length of value (int32) | +------------------------------------+ | Value (string) | +------------------------------------+ | (repeats) | Number of Name/Value pairs: The number of repeating name/value pairs following this field. List of Name/Value pairs: 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 SPDY frame. Name: 0 or more octets, 8-bit sequences of data, excluding 0. 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 SPDY frame. Value: 0 or more octets, 8-bit sequences of data, excluding 0. Each header name must have at least one value. Header names are encoded using the US-ASCII character set [ASCII] 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 stream error (Section 2.4.2) with the status code PROTOCOL_ERROR for the stream-id. 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 stream error (Section 2.4.2) with the status code PROTOCOL_ERROR for the stream-id. Belshe, et al. Expires June 1, 2013 [Page 27]

Internet-Draft SPDY November 2012 2.6.10.1 . Compression RFC1950. [RFC1950] For each HEADERS compression instance, the initial state is initialized using the following dictionary [UDELCOMPRESSION]: <CODE BEGINS> const unsigned char SPDY_dictionary_txt[] = { 0x00, 0x00, 0x00, 0x07, 0x6f, 0x70, 0x74, 0x69, \\ - - - - o p t i 0x6f, 0x6e, 0x73, 0x00, 0x00, 0x00, 0x04, 0x68, \\ o n s - - - - h 0x65, 0x61, 0x64, 0x00, 0x00, 0x00, 0x04, 0x70, \\ e a d - - - - p 0x6f, 0x73, 0x74, 0x00, 0x00, 0x00, 0x03, 0x70, \\ o s t - - - - p 0x75, 0x74, 0x00, 0x00, 0x00, 0x06, 0x64, 0x65, \\ u t - - - - d e 0x6c, 0x65, 0x74, 0x65, 0x00, 0x00, 0x00, 0x05, \\ l e t e - - - - 0x74, 0x72, 0x61, 0x63, 0x65, 0x00, 0x00, 0x00, \\ t r a c e - - - 0x06, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x00, \\ - a c c e p t - 0x00, 0x00, 0x0e, 0x61, 0x63, 0x63, 0x65, 0x70, \\ - - - a c c e p 0x74, 0x2d, 0x63, 0x68, 0x61, 0x72, 0x73, 0x65, \\ t - c h a r s e 0x74, 0x00, 0x00, 0x00, 0x0f, 0x61, 0x63, 0x63, \\ t - - - - a c c 0x65, 0x70, 0x74, 0x2d, 0x65, 0x6e, 0x63, 0x6f, \\ e p t - e n c o 0x64, 0x69, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x0f, \\ d i n g - - - - 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x2d, 0x6c, \\ a c c e p t - l 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x00, \\ a n g u a g e - 0x00, 0x00, 0x0d, 0x61, 0x63, 0x63, 0x65, 0x70, \\ - - - a c c e p 0x74, 0x2d, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x73, \\ t - r a n g e s 0x00, 0x00, 0x00, 0x03, 0x61, 0x67, 0x65, 0x00, \\ - - - - a g e - 0x00, 0x00, 0x05, 0x61, 0x6c, 0x6c, 0x6f, 0x77, \\ - - - a l l o w 0x00, 0x00, 0x00, 0x0d, 0x61, 0x75, 0x74, 0x68, \\ - - - - a u t h 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, \\ o r i z a t i o 0x6e, 0x00, 0x00, 0x00, 0x0d, 0x63, 0x61, 0x63, \\ n - - - - c a c 0x68, 0x65, 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72, \\ h e - c o n t r 0x6f, 0x6c, 0x00, 0x00, 0x00, 0x0a, 0x63, 0x6f, \\ o l - - - - c o 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, \\ n n e c t i o n 0x00, 0x00, 0x00, 0x0c, 0x63, 0x6f, 0x6e, 0x74, \\ - - - - c o n t 0x65, 0x6e, 0x74, 0x2d, 0x62, 0x61, 0x73, 0x65, \\ e n t - b a s e 0x00, 0x00, 0x00, 0x10, 0x63, 0x6f, 0x6e, 0x74, \\ - - - - c o n t 0x65, 0x6e, 0x74, 0x2d, 0x65, 0x6e, 0x63, 0x6f, \\ e n t - e n c o 0x64, 0x69, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x10, \\ d i n g - - - - 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, \\ c o n t e n t - 0x6c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, \\ l a n g u a g e 0x00, 0x00, 0x00, 0x0e, 0x63, 0x6f, 0x6e, 0x74, \\ - - - - c o n t Belshe, et al. Expires June 1, 2013 [Page 28]

Internet-Draft SPDY November 2012 0x65, 0x6e, 0x74, 0x2d, 0x6c, 0x65, 0x6e, 0x67, \\ e n t - l e n g 0x74, 0x68, 0x00, 0x00, 0x00, 0x10, 0x63, 0x6f, \\ t h - - - - c o 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x6c, 0x6f, \\ n t e n t - l o 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, \\ c a t i o n - - 0x00, 0x0b, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, \\ - - c o n t e n 0x74, 0x2d, 0x6d, 0x64, 0x35, 0x00, 0x00, 0x00, \\ t - m d 5 - - - 0x0d, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, \\ - c o n t e n t 0x2d, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x00, 0x00, \\ - r a n g e - - 0x00, 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, \\ - - c o n t e n 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x00, 0x00, \\ t - t y p e - - 0x00, 0x04, 0x64, 0x61, 0x74, 0x65, 0x00, 0x00, \\ - - d a t e - - 0x00, 0x04, 0x65, 0x74, 0x61, 0x67, 0x00, 0x00, \\ - - e t a g - - 0x00, 0x06, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, \\ - - e x p e c t 0x00, 0x00, 0x00, 0x07, 0x65, 0x78, 0x70, 0x69, \\ - - - - e x p i 0x72, 0x65, 0x73, 0x00, 0x00, 0x00, 0x04, 0x66, \\ r e s - - - - f 0x72, 0x6f, 0x6d, 0x00, 0x00, 0x00, 0x04, 0x68, \\ r o m - - - - h 0x6f, 0x73, 0x74, 0x00, 0x00, 0x00, 0x08, 0x69, \\ o s t - - - - i 0x66, 0x2d, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x00, \\ f - m a t c h - 0x00, 0x00, 0x11, 0x69, 0x66, 0x2d, 0x6d, 0x6f, \\ - - - i f - m o 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x2d, 0x73, \\ d i f i e d - s 0x69, 0x6e, 0x63, 0x65, 0x00, 0x00, 0x00, 0x0d, \\ i n c e - - - - 0x69, 0x66, 0x2d, 0x6e, 0x6f, 0x6e, 0x65, 0x2d, \\ i f - n o n e - 0x6d, 0x61, 0x74, 0x63, 0x68, 0x00, 0x00, 0x00, \\ m a t c h - - - 0x08, 0x69, 0x66, 0x2d, 0x72, 0x61, 0x6e, 0x67, \\ - i f - r a n g 0x65, 0x00, 0x00, 0x00, 0x13, 0x69, 0x66, 0x2d, \\ e - - - - i f - 0x75, 0x6e, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, \\ u n m o d i f i 0x65, 0x64, 0x2d, 0x73, 0x69, 0x6e, 0x63, 0x65, \\ e d - s i n c e 0x00, 0x00, 0x00, 0x0d, 0x6c, 0x61, 0x73, 0x74, \\ - - - - l a s t 0x2d, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, \\ - m o d i f i e 0x64, 0x00, 0x00, 0x00, 0x08, 0x6c, 0x6f, 0x63, \\ d - - - - l o c 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00, \\ a t i o n - - - 0x0c, 0x6d, 0x61, 0x78, 0x2d, 0x66, 0x6f, 0x72, \\ - m a x - f o r 0x77, 0x61, 0x72, 0x64, 0x73, 0x00, 0x00, 0x00, \\ w a r d s - - - 0x06, 0x70, 0x72, 0x61, 0x67, 0x6d, 0x61, 0x00, \\ - p r a g m a - 0x00, 0x00, 0x12, 0x70, 0x72, 0x6f, 0x78, 0x79, \\ - - - p r o x y 0x2d, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, \\ - a u t h e n t 0x69, 0x63, 0x61, 0x74, 0x65, 0x00, 0x00, 0x00, \\ i c a t e - - - 0x13, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2d, 0x61, \\ - p r o x y - a 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, \\ u t h o r i z a 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00, 0x05, \\ t i o n - - - - 0x72, 0x61, 0x6e, 0x67, 0x65, 0x00, 0x00, 0x00, \\ r a n g e - - - 0x07, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x72, \\ - r e f e r e r 0x00, 0x00, 0x00, 0x0b, 0x72, 0x65, 0x74, 0x72, \\ - - - - r e t r 0x79, 0x2d, 0x61, 0x66, 0x74, 0x65, 0x72, 0x00, \\ y - a f t e r - 0x00, 0x00, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, \\ - - - s e r v e 0x72, 0x00, 0x00, 0x00, 0x02, 0x74, 0x65, 0x00, \\ r - - - - t e - 0x00, 0x00, 0x07, 0x74, 0x72, 0x61, 0x69, 0x6c, \\ - - - t r a i l 0x65, 0x72, 0x00, 0x00, 0x00, 0x11, 0x74, 0x72, \\ e r - - - - t r Belshe, et al. Expires June 1, 2013 [Page 29]

Internet-Draft SPDY November 2012 0x61, 0x6e, 0x73, 0x66, 0x65, 0x72, 0x2d, 0x65, \\ a n s f e r - e 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x00, \\ n c o d i n g - 0x00, 0x00, 0x07, 0x75, 0x70, 0x67, 0x72, 0x61, \\ - - - u p g r a 0x64, 0x65, 0x00, 0x00, 0x00, 0x0a, 0x75, 0x73, \\ d e - - - - u s 0x65, 0x72, 0x2d, 0x61, 0x67, 0x65, 0x6e, 0x74, \\ e r - a g e n t 0x00, 0x00, 0x00, 0x04, 0x76, 0x61, 0x72, 0x79, \\ - - - - v a r y 0x00, 0x00, 0x00, 0x03, 0x76, 0x69, 0x61, 0x00, \\ - - - - v i a - 0x00, 0x00, 0x07, 0x77, 0x61, 0x72, 0x6e, 0x69, \\ - - - w a r n i 0x6e, 0x67, 0x00, 0x00, 0x00, 0x10, 0x77, 0x77, \\ n g - - - - w w 0x77, 0x2d, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, \\ w - a u t h e n 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x00, 0x00, \\ t i c a t e - - 0x00, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, \\ - - m e t h o d 0x00, 0x00, 0x00, 0x03, 0x67, 0x65, 0x74, 0x00, \\ - - - - g e t - 0x00, 0x00, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, \\ - - - s t a t u 0x73, 0x00, 0x00, 0x00, 0x06, 0x32, 0x30, 0x30, \\ s - - - - 2 0 0 0x20, 0x4f, 0x4b, 0x00, 0x00, 0x00, 0x07, 0x76, \\ - O K - - - - v 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x00, 0x00, \\ e r s i o n - - 0x00, 0x08, 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, \\ - - H T T P - 1 0x2e, 0x31, 0x00, 0x00, 0x00, 0x03, 0x75, 0x72, \\ - 1 - - - - u r 0x6c, 0x00, 0x00, 0x00, 0x06, 0x70, 0x75, 0x62, \\ l - - - - p u b 0x6c, 0x69, 0x63, 0x00, 0x00, 0x00, 0x0a, 0x73, \\ l i c - - - - s 0x65, 0x74, 0x2d, 0x63, 0x6f, 0x6f, 0x6b, 0x69, \\ e t - c o o k i 0x65, 0x00, 0x00, 0x00, 0x0a, 0x6b, 0x65, 0x65, \\ e - - - - k e e 0x70, 0x2d, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x00, \\ p - a l i v e - 0x00, 0x00, 0x06, 0x6f, 0x72, 0x69, 0x67, 0x69, \\ - - - o r i g i 0x6e, 0x31, 0x30, 0x30, 0x31, 0x30, 0x31, 0x32, \\ n 1 0 0 1 0 1 2 0x30, 0x31, 0x32, 0x30, 0x32, 0x32, 0x30, 0x35, \\ 0 1 2 0 2 2 0 5 0x32, 0x30, 0x36, 0x33, 0x30, 0x30, 0x33, 0x30, \\ 2 0 6 3 0 0 3 0 0x32, 0x33, 0x30, 0x33, 0x33, 0x30, 0x34, 0x33, \\ 2 3 0 3 3 0 4 3 0x30, 0x35, 0x33, 0x30, 0x36, 0x33, 0x30, 0x37, \\ 0 5 3 0 6 3 0 7 0x34, 0x30, 0x32, 0x34, 0x30, 0x35, 0x34, 0x30, \\ 4 0 2 4 0 5 4 0 0x36, 0x34, 0x30, 0x37, 0x34, 0x30, 0x38, 0x34, \\ 6 4 0 7 4 0 8 4 0x30, 0x39, 0x34, 0x31, 0x30, 0x34, 0x31, 0x31, \\ 0 9 4 1 0 4 1 1 0x34, 0x31, 0x32, 0x34, 0x31, 0x33, 0x34, 0x31, \\ 4 1 2 4 1 3 4 1 0x34, 0x34, 0x31, 0x35, 0x34, 0x31, 0x36, 0x34, \\ 4 4 1 5 4 1 6 4 0x31, 0x37, 0x35, 0x30, 0x32, 0x35, 0x30, 0x34, \\ 1 7 5 0 2 5 0 4 0x35, 0x30, 0x35, 0x32, 0x30, 0x33, 0x20, 0x4e, \\ 5 0 5 2 0 3 - N 0x6f, 0x6e, 0x2d, 0x41, 0x75, 0x74, 0x68, 0x6f, \\ o n - A u t h o 0x72, 0x69, 0x74, 0x61, 0x74, 0x69, 0x76, 0x65, \\ r i t a t i v e 0x20, 0x49, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, \\ - I n f o r m a 0x74, 0x69, 0x6f, 0x6e, 0x32, 0x30, 0x34, 0x20, \\ t i o n 2 0 4 - 0x4e, 0x6f, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x65, \\ N o - C o n t e 0x6e, 0x74, 0x33, 0x30, 0x31, 0x20, 0x4d, 0x6f, \\ n t 3 0 1 - M o 0x76, 0x65, 0x64, 0x20, 0x50, 0x65, 0x72, 0x6d, \\ v e d - P e r m 0x61, 0x6e, 0x65, 0x6e, 0x74, 0x6c, 0x79, 0x34, \\ a n e n t l y 4 0x30, 0x30, 0x20, 0x42, 0x61, 0x64, 0x20, 0x52, \\ 0 0 - B a d - R 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x34, 0x30, \\ e q u e s t 4 0 0x31, 0x20, 0x55, 0x6e, 0x61, 0x75, 0x74, 0x68, \\ 1 - U n a u t h Belshe, et al. Expires June 1, 2013 [Page 30]

Internet-Draft SPDY November 2012 0x6f, 0x72, 0x69, 0x7a, 0x65, 0x64, 0x34, 0x30, \\ o r i z e d 4 0 0x33, 0x20, 0x46, 0x6f, 0x72, 0x62, 0x69, 0x64, \\ 3 - F o r b i d 0x64, 0x65, 0x6e, 0x34, 0x30, 0x34, 0x20, 0x4e, \\ d e n 4 0 4 - N 0x6f, 0x74, 0x20, 0x46, 0x6f, 0x75, 0x6e, 0x64, \\ o t - F o u n d 0x35, 0x30, 0x30, 0x20, 0x49, 0x6e, 0x74, 0x65, \\ 5 0 0 - I n t e 0x72, 0x6e, 0x61, 0x6c, 0x20, 0x53, 0x65, 0x72, \\ r n a l - S e r 0x76, 0x65, 0x72, 0x20, 0x45, 0x72, 0x72, 0x6f, \\ v e r - E r r o 0x72, 0x35, 0x30, 0x31, 0x20, 0x4e, 0x6f, 0x74, \\ r 5 0 1 - N o t 0x20, 0x49, 0x6d, 0x70, 0x6c, 0x65, 0x6d, 0x65, \\ - I m p l e m e 0x6e, 0x74, 0x65, 0x64, 0x35, 0x30, 0x33, 0x20, \\ n t e d 5 0 3 - 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x20, \\ S e r v i c e - 0x55, 0x6e, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, \\ U n a v a i l a 0x62, 0x6c, 0x65, 0x4a, 0x61, 0x6e, 0x20, 0x46, \\ b l e J a n - F 0x65, 0x62, 0x20, 0x4d, 0x61, 0x72, 0x20, 0x41, \\ e b - M a r - A 0x70, 0x72, 0x20, 0x4d, 0x61, 0x79, 0x20, 0x4a, \\ p r - M a y - J 0x75, 0x6e, 0x20, 0x4a, 0x75, 0x6c, 0x20, 0x41, \\ u n - J u l - A 0x75, 0x67, 0x20, 0x53, 0x65, 0x70, 0x74, 0x20, \\ u g - S e p t - 0x4f, 0x63, 0x74, 0x20, 0x4e, 0x6f, 0x76, 0x20, \\ O c t - N o v - 0x44, 0x65, 0x63, 0x20, 0x30, 0x30, 0x3a, 0x30, \\ D e c - 0 0 - 0 0x30, 0x3a, 0x30, 0x30, 0x20, 0x4d, 0x6f, 0x6e, \\ 0 - 0 0 - M o n 0x2c, 0x20, 0x54, 0x75, 0x65, 0x2c, 0x20, 0x57, \\ - - T u e - - W 0x65, 0x64, 0x2c, 0x20, 0x54, 0x68, 0x75, 0x2c, \\ e d - - T h u - 0x20, 0x46, 0x72, 0x69, 0x2c, 0x20, 0x53, 0x61, \\ - F r i - - S a 0x74, 0x2c, 0x20, 0x53, 0x75, 0x6e, 0x2c, 0x20, \\ t - - S u n - - 0x47, 0x4d, 0x54, 0x63, 0x68, 0x75, 0x6e, 0x6b, \\ G M T c h u n k 0x65, 0x64, 0x2c, 0x74, 0x65, 0x78, 0x74, 0x2f, \\ e d - t e x t - 0x68, 0x74, 0x6d, 0x6c, 0x2c, 0x69, 0x6d, 0x61, \\ h t m l - i m a 0x67, 0x65, 0x2f, 0x70, 0x6e, 0x67, 0x2c, 0x69, \\ g e - p n g - i 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x6a, 0x70, 0x67, \\ m a g e - j p g 0x2c, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x67, \\ - i m a g e - g 0x69, 0x66, 0x2c, 0x61, 0x70, 0x70, 0x6c, 0x69, \\ i f - a p p l i 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x78, \\ c a t i o n - x 0x6d, 0x6c, 0x2c, 0x61, 0x70, 0x70, 0x6c, 0x69, \\ m l - a p p l i 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x78, \\ c a t i o n - x 0x68, 0x74, 0x6d, 0x6c, 0x2b, 0x78, 0x6d, 0x6c, \\ h t m l - x m l 0x2c, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x70, 0x6c, \\ - t e x t - p l 0x61, 0x69, 0x6e, 0x2c, 0x74, 0x65, 0x78, 0x74, \\ a i n - t e x t 0x2f, 0x6a, 0x61, 0x76, 0x61, 0x73, 0x63, 0x72, \\ - j a v a s c r 0x69, 0x70, 0x74, 0x2c, 0x70, 0x75, 0x62, 0x6c, \\ i p t - p u b l 0x69, 0x63, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, \\ i c p r i v a t 0x65, 0x6d, 0x61, 0x78, 0x2d, 0x61, 0x67, 0x65, \\ e m a x - a g e 0x3d, 0x67, 0x7a, 0x69, 0x70, 0x2c, 0x64, 0x65, \\ - g z i p - d e 0x66, 0x6c, 0x61, 0x74, 0x65, 0x2c, 0x73, 0x64, \\ f l a t e - s d 0x63, 0x68, 0x63, 0x68, 0x61, 0x72, 0x73, 0x65, \\ c h c h a r s e 0x74, 0x3d, 0x75, 0x74, 0x66, 0x2d, 0x38, 0x63, \\ t - u t f - 8 c 0x68, 0x61, 0x72, 0x73, 0x65, 0x74, 0x3d, 0x69, \\ h a r s e t - i 0x73, 0x6f, 0x2d, 0x38, 0x38, 0x35, 0x39, 0x2d, \\ s o - 8 8 5 9 - 0x31, 0x2c, 0x75, 0x74, 0x66, 0x2d, 0x2c, 0x2a, \\ 1 - u t f - - - Belshe, et al. Expires June 1, 2013 [Page 31]

Internet-Draft SPDY November 2012 0x2c, 0x65, 0x6e, 0x71, 0x3d, 0x30, 0x2e \\ - e n q - 0 - }; <CODE ENDS> 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. SPDY uses a SYNC_FLUSH between each compressed frame. 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. 3 . HTTP Layering over SPDY RFC2616 [RFC2616] apply with the changes in the sections below. 3.1 . Connection Management RFC6454] concurrently. Note that it is possible for one SPDY session to be finishing (e.g. a GOAWAY message has been sent, but not all streams have finished), while another SPDY session is starting. 3.1.1 . Use of GOAWAY Belshe, et al. Expires June 1, 2013 [Page 32]

Internet-Draft SPDY November 2012 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 SPDY 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. 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. If a SPDY 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. 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. 3.2 . HTTP Request/Response 3.2.1 . Request RFC1738 [RFC1738]). For example, for "http://www.google.com/search?q=dogs" the path would be "/search?q=dogs". Belshe, et al. Expires June 1, 2013 [Page 33]

Internet-Draft SPDY November 2012 ":version" - the HTTP version of this request (e.g. "HTTP/1.1") In addition, the following two name/value pairs must also be present in every request: ":host" - the hostport (See RFC1738 [RFC1738]) portion of the URL for this request (e.g. "www.google.com:1234"). This header is the same as the HTTP 'Host' header. ":scheme" - the scheme portion of the URL for this request (e.g. "https")) Header names are all lowercase. The Connection, Host, Keep-Alive, Proxy-Connection, and Transfer- Encoding headers are not valid and MUST not be sent. 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. 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. POST-specific changes: 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. But second, we know from early versions of SPDY that 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. 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. 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. Belshe, et al. Expires June 1, 2013 [Page 34]

Internet-Draft SPDY November 2012 3.2.2 . Response 3.2.3 . Authentication RFC2617 [RFC2617], and are stateless. The second two options were developed by Microsoft and specified in RFC4559 [RFC4559], and are stateful; otherwise known as multi-round authentication, or Belshe, et al. Expires June 1, 2013 [Page 35]

Internet-Draft SPDY November 2012 connection authentication. 3.2.3.1 . Stateless Authentication 3.2.3.2 . Stateful Authentication RFC2617 - they do not include a "realm" as part of the request. This is problematic in SPDY because it makes it impossible for a client to disambiguate two concurrent server authentication challenges. To deal with this case, SPDY servers using Stateful Authentication MUST implement one of two changes: Servers can add a "realm=<desired realm>" header so that the two authentication requests can be disambiguated and run concurrently. Unfortunately, given how these mechanisms work, this is probably not practical. 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. 3.3 . Server Push Transactions Belshe, et al. Expires June 1, 2013 [Page 36]

Internet-Draft SPDY November 2012 Browsers receiving a pushed response MUST validate that the server is authorized to push the URL using the browser same-origin [RFC6454] policy. For example, a SPDY connection to www.foo.com is generally not permitted to push a response for www.evil.com. 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. Because pushed responses have no request, they have no request headers associated with them. At the framing layer, SPDY 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. 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. 3.3.1 . Server implementation Belshe, et al. Expires June 1, 2013 [Page 37]

Internet-Draft SPDY November 2012 It is illegal for a server to push a resource with the Associated-To- Stream-ID of 0. 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. The server MUST only push resources which would have been returned from a GET request. 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. 3.3.2 . Client implementation Section 2.4.1) with the status code PROTOCOL_ERROR. 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. To cancel individual server push streams, the client can issue a stream error (Section 2.4.2) with error code CANCEL. Upon receipt, the server MUST stop sending on this stream immediately (this is an Belshe, et al. Expires June 1, 2013 [Page 38]

Internet-Draft SPDY November 2012 Abrupt termination). To cancel all server push streams related to a request, the client may issue a stream error (Section 2.4.2) 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. If the server sends a HEADER frame containing duplicate headers with a previous HEADERS frame for the same stream, the client must issue a stream error (Section 2.4.2) with error code PROTOCOL ERROR. 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). 4 . Design Rationale and Notes 4.1 . Separation of Framing Layer and Application Layer Section 2) with requirements of a specific application - HTTP (Section 3). 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. 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 SPDY framing layer is a non goal. 4.2 . Error handling - Framing Layer Belshe, et al. Expires June 1, 2013 [Page 39]

Internet-Draft SPDY November 2012 invalidate the stream but move forward without aborting the connection altogether. For errors occuring outside of a single stream context, SPDY assumes the entire session is hosed. In this case, the endpoint detecting the error should initiate a connection close. 4.3 . One Connection Per Domain 4.4 . Fixed vs Variable Length Fields Belshe, et al. Expires June 1, 2013 [Page 40]

Internet-Draft SPDY November 2012 4.5 . Compression Context(s) 4.6 . Unidirectional streams 4.7 . Data Compression Belshe, et al. Expires June 1, 2013 [Page 41]

Internet-Draft SPDY November 2012 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. 4.8 . Server Push 5 . Security Considerations 5.1 . Use of Same-origin constraints RFC6454] in all cases where verification of content is required. 5.2 . HTTP Headers and SPDY Headers 5.3 . Cross-Protocol Attacks 5.4 . Server Push Implicit Headers Belshe, et al. Expires June 1, 2013 [Page 42]

Internet-Draft SPDY November 2012 6 . Privacy Considerations 6.1 . Long Lived Connections 6.2 . SETTINGS frame 7 . Incompatibilities with SPDY draft #2 Belshe, et al. Expires June 1, 2013 [Page 43]

Internet-Draft SPDY November 2012 Authors' Addresses Mike Belshe Twist EMail: mbelshe@chromium.org Roberto Peon Google, Inc EMail: fenix@google.com Martin Thomson (editor) Microsoft 3210 Porter Drive Palo Alto 94043 US EMail: martin.thomson@skype.net Alexey Melnikov (editor) Isode Ltd 5 Castle Business Village 36 Station Road Hampton, Middlesex TW12 2BX UK EMail: Alexey.Melnikov@isode.com Belshe, et al. Expires June 1, 2013 [Page 46]