This appendix is a quick reference for the HTTP/2 framing layer. Each section includes the frame type number, the binary layout for the frame, a description of the frame, and a list of flags specific to that frame.
DATA frames contain arbitrary sequences of octets. This is a fancy way of saying these frames contain the requested/sent objects. Object data is split up across one or more frames depending on the maximum frame length. The padding length field and the padding itself are conditionally included to hide the size of the message for security purposes:
| Name | Length | Description |
|---|---|---|
Pad Length |
1 byte |
Indicates the length of the padding field. Will only be present if the |
Data |
Variable |
The content of the frame. |
Padding |
Variable |
Length set by the Pad Length field. All bytes are set to zero. |
| Name | Bit | Description |
|---|---|---|
END_STREAM |
0x1 |
Indicates this is the frame in the stream |
PADDED |
0x8 |
Indicates that the Pad Length and Padding fields are used |
HEADERS frames are used to start streams and send message headers to an endpoint:
| Name | Length | Description |
|---|---|---|
Pad Length |
1 byte |
Indicates the length of the padding field. Will only be present if the |
E |
1 bit |
Indicates whether the stream dependency is exclusive. Only present if the |
Stream Dependency |
31 bits |
Indicates which stream this stream is dependent on, if any. Only present if the |
Weight |
1 byte |
Indicates the relative priority of the stream. Only present if the |
Header Block Fragment |
Variable |
The headers for the message. |
Padding |
Variable |
Length set by the Pad Length field. All bytes are set to zero. |
| Name | Bit | Description |
|---|---|---|
|
0x1 |
Indicates this is the frame in the stream. |
|
0x4 |
Indicates this is the last HEADERS frame in the stream. If this is flag not set it implies a CONTINUATION frame is next. |
PADDED |
0x8 |
Indicates that the Pad Length and Padding fields are used. |
|
0x20 |
When set it indicates that the E, Stream Dependency, and weight fields are used. |
The PRIORITY frame is sent to indicate the priority of the stream. It can be sent multiple times and will change the advised priority if previously set:
| Name | Length | Description |
|---|---|---|
E |
1 bit |
Indicates whether the stream dependency is exclusive. |
Stream Dependency |
31 bits |
Communicates the stream this stream is dependent on, if any. |
Weight |
1 byte |
Indicates the relative priority of the stream. |
A PRIORITY frame does not have any frame-specific flags.
RST_STREAM is used by either end of a stream to terminate the stream immediately. This is usually in response to an error condition.
The Error Code field in the frame is used to communicate the reason for the reset. See section 7 of RFC 75401 for a listing of those fields:
The SETTINGS frame is a sequence of key/value pairs. The number of pairs is defined by the frame length divided by the individual setting length (six):
| Name | ID | Default | Description |
|---|---|---|---|
|
0x1 |
4096 |
Changes the maximum size of the header table used for HPACK. |
|
0x2 |
1 |
If set to 0 the peer may not send a PUSH_PROMISE frame. |
|
0x3 |
No limit |
Indicates the maximum number of streams that the sender will allow. |
|
0x4 |
65353 |
Indicates the sender’s initial window size for flow control. |
|
0x5 |
16384 |
Indicates the maximum frame size the sender is willing to receive. This value must be between this initial value and 16,777,215 (224-1). |
|
0x6 |
No limit |
This setting is used to advise a peer of the maximum size of the header the sender is willing to accept. |
When an endpoint receives and processes a SETTINGS frame, it must return a SETTINGS frame with the ACK flag (0x1) set in the frame header. This is the only flag defined for the SETTINGS frame. In this way the sender gets acknowledgment that the endpoint received the new SETTINGS and should be abiding by them.
The PUSH_PROMISE frame is sent by a server to indicate to the client that it is about to send an object that the client has not explicitly requested. It is effectively the complement to a HEADERS frame sent by the client:
| Name | Length | Description |
|---|---|---|
Pad Length |
1 byte |
Indicates the length of the padding field. Will only be present if the PADDED flag is set in the frame header. |
R |
1 bit |
A single reserved bit. Do not set this or else. |
Promised Stream ID |
31 bits |
Communicates the stream ID that the sender will use (will always be an even number as this is coming from the server by definition). |
Header Block Fragment |
Varible |
The pushed headers for the message. |
Padding |
Variable |
Length set by the Pad Length field. All bytes are set to zero. |
| Name | Bit | Description |
|---|---|---|
|
0x4 |
Indicates this is the last HEADERS frame in the stream. If this is not set it implies a CONTINUATION frame is next. |
PADDED |
0x8 |
Indicates that the Pad Length and Padding fields are used. |
The PING frame is intended to be used to measure the round-trip time between endpoints. The frame has one flag, ACK (0x1). When an endpoint receives a PING frame without an ACK sent, it must send a PING frame back with the ACK flag set and the same opaque data. It should be noted that PING frames are not associated with any particular stream (they are connection level), and thus should have their stream identifier set to 0x0:
The GOAWAY frame is used to gracefully shut down a connection. This is a connection-level frame and must be sent on stream identifier 0x0. By sending a GOAWAY frame, the endpoint is able to clearly define to the receiver what it has and has not received and what problem (if any) may have contributed to the GOAWAY. In the case of a problem, the error code will be set to one of the codes defined in section 7 of RFC 7540, and the Last Stream ID will be set to the highest stream ID that was processed. If there has been no error but the endpoint is about to tear down the connection (browser tab closed, connection timer exceeded, etc.), it sends the NO_ERROR (0x0) code and sets the Last Stream ID to 231-1:
| Name | Length | Description |
|---|---|---|
R |
1 bit |
A single reserved bit. |
Last Stream ID |
31 bits |
The highest number stream ID the GOAWAY sender has received/processed. By sending this the receiver knows precisely what the sender has and has not received. |
Error Code |
4 bytes |
The h2-defined error code or |
Additional Debug Data |
Variable |
Opaque data the sender may send to indicate more information into the state or any problems. |
The WINDOW_UPDATE frame is used for stream flow control. Sending a WINDOW_UPDATE frame to a peer tells that peer how many bytes the sender is willing to accept at that time. Flow control can apply to individual streams or all streams on a connection (Stream ID 0x0). Note that a WINDOW_UPDATE on a specific stream applies to the connection-level flow control as well:
| Name | Length | Description |
|---|---|---|
R |
1 bit |
A single reserved bit. |
Window Size Increment |
31 bits |
The number of bytes to increase the current window by. |
The WINDOW_UPDATE frame has no frame-specific flags.