Back

HTTP/2 帧定义 (上编)

帧定义(Frame Definitions)

This specification defines a number of frame types, each identified by a unique 8-bit type code. Each frame type serves a distinct purpose in the establishment and management either of the connection as a whole or of individual streams.

这份文档定义了多种帧类型,每种都由一个唯一的8位类型码标识。每种帧类型都服务于建立和管理整个连接或独立的流方面的一个不同的目的。

The transmission of specific frame types can alter the state of a connection. If endpoints fail to maintain a synchronized view of the connection state, successful communication within the connection will no longer be possible. Therefore, it is important that endpoints have a shared comprehension of how the state is affected by the use any given frame.

特定帧类型的传输可能改变连接的状态。如果终端不能维护连接状态视图的一致性,连接内成功的通信将是不可能的。因此,终端之间,关于特定帧的使用对状态所产生的影响具有相同的理解就变得非常重要。

6.1 DATA

DATA frames (type=0x0) convey arbitrary, variable-length sequences of octets associated with a stream. One or more DATA frames are used, for instance, to carry HTTP request or response payloads.

DATA帧(type=0x0)传送与一个流关联的任意的,可变长度的字节序列。一个或多个DATA帧被用于,比如,携带HTTP请求或响应载荷。

DATA frames MAY also contain padding. Padding can be added to DATA frames to obscure the size of messages. Padding is a security feature; see Section 10.7.

DATA帧也 可以(MAY) 包含填充字节。填充字节可以被加进DATA帧来掩盖消息的大小。填充字节是一个安全性的功能;参见 Section 10.7

 +---------------+
 |Pad Length? (8)|
 +---------------+-----------------------------------------------+
 |                            Data (*)                         ...
 +---------------------------------------------------------------+
 |                           Padding (*)                       ...
 +---------------------------------------------------------------+

Figure 6: DATA Frame Payload

图 6:DATA帧载荷

The DATA frame contains the following fields:

DATA帧包含如下的字段:

Pad Length:
An 8-bit field containing the length of the frame padding in units of octets. This field is conditional (as signified by a "?" in the diagram) and is only present if the PADDED flag is set.

填充长度:

一个8位的字段,包含了以字节为单位的帧的填充的长度。这个字段是有条件的(如图中的"?"所指的),只有在PADDED标记设置时才出现。

Data:
Application data. The amount of data is the remainder of the frame payload after subtracting the length of the other fields that are present.

数据:

应用数据。数据的大小是帧载荷减去出现的其它字段的长度剩余的大小。

Padding:
Padding octets that contain no application semantic value. Padding octets MUST be set to zero when sending. A receiver is not obligated to verify padding but MAY treat non-zero padding as a connection error (Section 5.4.1) of type PROTOCOL_ERROR.

填充:

填充字节包含了无应用语义的值。当填充时填充字节 必须(MUST) 被设置为0。接收者没有义务去验证填充,而 可以(MAY) 将非零的填充当做一个类型为PROTOCOL_ERROR的连接错误(Section 5.4.1)。

The DATA frame defines the following flags:

DATA帧定义了如下的标记:

END_STREAM (0x1):
When set, bit 0 indicates that this frame is the last that the endpoint will send for the identified stream. Setting this flag causes the stream to enter one of the "half-closed" states or the "closed" state (Section 5.1).

END_STREAM (0x1):

当设置了这个标记时,位0表示这个帧是终端将为标识的流发送的最后一帧。设置这个标记使得流进入某种"half-closed"状态或"closed"状态(Section 5.1)。

PADDED (0x8):
When set, bit 3 indicates that the Pad Length field and any padding that it describes are present.

PADDED (0x8):

当设置了这个标记时,位3表示上面描述的 填充长度 字段及填充存在。

DATA frames MUST be associated with a stream. If a DATA frame is received whose stream identifier field is 0x0, the recipient MUST respond with a connection error (Section 5.4.1) of type PROTOCOL_ERROR.

DATA帧 必须(MUST) 与一个流关联。如果收到了一个流标识符为0x0的DATA帧,接收者 必须(MUST) 以一个类型为PROTOCOL_ERROR的连接错误(Section 5.4.1)来响应。

DATA frames are subject to flow control and can only be sent when a stream is in the "open" or "half-closed (remote)" state. The entire DATA frame payload is included in flow control, including the Pad Length and Padding fields if present. If a DATA frame is received whose stream is not in "open" or "half-closed (local)" state, the recipient MUST respond with a stream error (Section 5.4.2) of type STREAM_CLOSED.

DATA帧受控于flow control,而且只能在流处于"open"或"half-closed (remote)"状态时发送。整个的DATA帧载荷被包含在flow control中,可能包括 填充长度 和填充字段。如果收到DATA帧的流不处于"open"或"half-closed (remote)"状态,则接收者 必须(MUST) 以一个类型为STREAM_CLOSED的流错误(Section 5.4.2)来响应。

The total number of padding octets is determined by the value of the Pad Length field. If the length of the padding is the length of the frame payload or greater, the recipient MUST treat this as a connection error (Section 5.4.1) of type PROTOCOL_ERROR.

填充字节的总大小由填充长度字段决定。如果填充的长度是帧载荷的长度或更大,则接收者 必须(MUST) 将这作为一个类型为PROTOCOL_ERROR的连接错误(Section 5.4.1)来处理应。

Note: A frame can be increased in size by one octet by including a Pad Length field with a value of zero.

注意:一个帧可以通过包含一个值为零的填充长度字段来使帧长度只增加一个字节。

6.2 HEADERS

The HEADERS frame (type=0x1) is used to open a stream (Section 5.1), and additionally carries a header block fragment. HEADERS frames can be sent on a stream in the "idle", "reserved (local)", "open", or "half-closed (remote)" state.

HEADERS帧(type=0x1)用于打开一个流(Section 5.1),此外还携带一个首部块片段。HEADERS帧可以在一个"idle","reserved (local)","open",或"half-closed (remote)"状态的流上发送。

 +---------------+
 |Pad Length? (8)|
 +-+-------------+-----------------------------------------------+
 |E|                 Stream Dependency? (31)                     |
 +-+-------------+-----------------------------------------------+
 |  Weight? (8)  |
 +-+-------------+-----------------------------------------------+
 |                   Header Block Fragment (*)                 ...
 +---------------------------------------------------------------+
 |                           Padding (*)                       ...
 +---------------------------------------------------------------+

Figure 7: HEADERS Frame Payload

图 7: HEADERS帧载荷

The HEADERS frame payload has the following fields:

HEADERS帧具有如下的字段:

Pad Length:
An 8-bit field containing the length of the frame padding in units of octets. This field is only present if the PADDED flag is set.

填充长度:

一个8位的字段,包含了以字节为单位的帧的填充的长度。只有在PADDED标记设置时这个字段才出现。

E:
A single-bit flag indicating that the stream dependency is exclusive (see Section 5.3). This field is only present if the PRIORITY flag is set.

E:

一个单独的位标记,指示了流依赖是独占的(参见Section 5.3)。这个字段只有在PRIORITY标记设置时才会出现。

Stream Dependency:
A 31-bit stream identifier for the stream that this stream depends on (see Section 5.3). This field is only present if the PRIORITY flag is set.

流依赖:一个31位的标识了这个流依赖的流的流标识符(参见Section 5.3)。这个字段只有在PRIORITY标记设置时才会出现。

Weight:
An unsigned 8-bit integer representing a priority weight for the stream (see Section 5.3). Add one to the value to obtain a weight between 1 and 256. This field is only present if the PRIORITY flag is set.

权值:

一个无符号8位整型值,表示流的优先级权值(see Section 5.3)。这个值的范围为1到256。这个字段只有在PRIORITY标记设置时才会出现。

Header Block Fragment:
A header block fragment (Section 4.3).

首部块片段:

一个首部块片段(Section 4.3)。

Padding:
Padding octets.

填充:

填充字节。

The HEADERS frame defines the following flags:

HEADERS帧定义了如下的标记:

END_STREAM (0x1):
When set, bit 0 indicates that the header block (Section 4.3) is the last that the endpoint will send for the identified stream.

END_STREAM (0x1):

当设置时,位0表示这个首部块(Section 4.3)是终端将会为标识的流发送的最后一个块。

A HEADERS frame carries the END_STREAM flag that signals the end of a stream. However, a HEADERS frame with the END_STREAM flag set can be followed by CONTINUATION frames on the same stream. Logically, the CONTINUATION frames are part of the HEADERS frame.

HEADERS帧携带了 END_STREAM标记,表明了流的结束。然而,在相同的流上,一个设置了END_STREAM标记的HEADERS帧后面可以跟着CONTINUATION帧。逻辑上来说,着CONTINUATION帧是HEADERS帧的一部分。

END_HEADERS (0x4):
When set, bit 2 indicates that this frame contains an entire header block (Section 4.3) and is not followed by any CONTINUATION frames.

END_HEADERS (0x4):

当设置时,位2表示这个帧包含了这个首部块(Section 4.3),而且后面没有任何的CONTINUATION帧。

A HEADERS frame without the END_HEADERS flag set MUST be followed by a CONTINUATION frame for the same stream. A receiver MUST treat the receipt of any other type of frame or a frame on a different stream as a connection error (Section 5.4.1) of type PROTOCOL_ERROR.

相同的流上,一个没有设置END_HEADERS标记的HEADERS帧后面 必须(MUST) 跟着一个CONTINUATION帧。接收者 必须(MUST) 将 接收到其它类型的帧,或在其它流上接收到了帧,当做是类型为PROTOCOL_ERROR的连接错误。

PADDED (0x8):
When set, bit 3 indicates that the Pad Length field and any padding that it describes are present.

PADDED (0x8):

当设置时,位3表示将会有填充长度和它对应的填充出现。

PRIORITY (0x20):
When set, bit 5 indicates that the Exclusive Flag (E), Stream Dependency, and Weight fields are present; see Section 5.3.

PRIORITY (0x20):

当设置时,位5指明独占标记(E),流依赖和权值字段将出现;参见Section 5.3

The payload of a HEADERS frame contains a header block fragment (Section 4.3). A header block that does not fit within a HEADERS frame is continued in a CONTINUATION frame (Section 6.10).

HEADERS帧的载荷包含一个首部块片段(Section 4.3)。一个首部块无法装进一个HEADERS帧的话,将通过CONTINUATION帧来继续发送(Section 6.10)。

HEADERS frames MUST be associated with a stream. If a HEADERS frame is received whose stream identifier field is 0x0, the recipient MUST respond with a connection error (Section 5.4.1) of type PROTOCOL_ERROR.

HEADERS帧 必须(MUST) 与一个流关联。如果接收到了一个流标识符字段为0x0的HEADERS帧,则接收者 必须(MUST) 响应一个类型为PROTOCOL_ERROR的连接错误(Section 5.4.1)。

The HEADERS frame changes the connection state as described in Section 4.3.

HEADERS帧如Section 4.3中所述的那样改变连接的状态。

The HEADERS frame can include padding. Padding fields and flags are identical to those defined for DATA frames (Section 6.1). Padding that exceeds the size remaining for the header block fragment MUST be treated as a PROTOCOL_ERROR.

HEADERS帧可以包含填充。填充字段和标记与DATA帧(Section 6.1)中定义的一致。填充超出了首部块片段的剩余大小 必须(MUST) 被当做一个 PROTOCOL_ERROR

Prioritization information in a HEADERS frame is logically equivalent to a separate PRIORITY frame, but inclusion in HEADERS avoids the potential for churn in stream prioritization when new streams are created. Prioritization fields in HEADERS frames subsequent to the first on a stream reprioritize the stream (Section 5.3.3).

HEADERS帧中包含的优先级信息在逻辑上等于另一个 PRIORITY帧,但是包含在HEADERS中可以避免在创建新流时流优先级潜在的扰动。一个流中第一个之后的HEADERS帧中的优先级字段改变流的优先级(Section 5.3.3)。

6.3 PRIORITY

The PRIORITY frame (type=0x2) specifies the sender-advised priority of a stream (Section 5.3). It can be sent in any stream state, including idle or closed streams.

PRIORITY帧 (type=0x2) 描述了给发送者建议的一个流的优先级(Section 5.3)。它可以在任何流状态下发送,包括idle和closed流。

 +-+-------------------------------------------------------------+
 |E|                  Stream Dependency (31)                     |
 +-+-------------+-----------------------------------------------+
 |   Weight (8)  |
 +-+-------------+

Figure 8: PRIORITY Frame Payload

图 8: PRIORITY帧载荷

The payload of a PRIORITY frame contains the following fields:

PRIORITY帧包含如下的字段:

E:
A single-bit flag indicating that the stream dependency is exclusive (see Section 5.3).

E: 一个单独的位标记指明流依赖是独占的(参见Section 5.3)。

Stream Dependency:
A 31-bit stream identifier for the stream that this stream depends on (see Section 5.3).

流依赖:
一个31位的流标识符,指明了这个流依赖的流(参见 Section 5.3)。

Weight:
An unsigned 8-bit integer representing a priority weight for the stream (see Section 5.3). Add one to the value to obtain a weight between 1 and 256.

权值:
一个无符号8位整型值,表示流的优先级权值(参见 Section 5.3)。该值的取值范围为1到256。

The PRIORITY frame does not define any flags.

PRIORITY帧不定义任何标记。

The PRIORITY frame always identifies a stream. If a PRIORITY frame is received with a stream identifier of 0x0, the recipient MUST respond with a connection error (Section 5.4.1) of type PROTOCOL_ERROR.

PRIORITY帧总是标识一个流。如果接收到了一个流标识符为0x0的PRIORITY帧,则接收者 必须(MUST) 响应一个类型为PROTOCOL_ERROR的连接错误(Section 5.4.1)。

The PRIORITY frame can be sent on a stream in any state, though it cannot be sent between consecutive frames that comprise a single header block (Section 4.3). Note that this frame could arrive after processing or frame sending has completed, which would cause it to have no effect on the identified stream. For a stream that is in the "half-closed (remote)" or "closed" state, this frame can only affect processing of the identified stream and its dependent streams; it does not affect frame transmission on that stream.

可以在任何状态的流上发送RIORITY帧,尽管不能在包含了一个单独的首部块(Section 4.3)的连续两帧之间发送。注意,这个帧可能在处理或帧发送已经完成时到达,这将不对标识的流产生影响。对于处在"half-closed (remote)"或"closed"状态的流,这个帧只影响标识的流和依赖于它的流的处理;它不影响那些流的帧传输。

The PRIORITY frame can be sent for a stream in the "idle" or "closed" state. This allows for the reprioritization of a group of dependent streams by altering the priority of an unused or closed parent stream.

可以为处于"idle"或"closed"状态的流发送PRIORITY帧。这允许通过改变未使用或已关闭的父流的优先级来改变一组依赖流的优先级。

A PRIORITY frame with a length other than 5 octets MUST be treated as a stream error (Section 5.4.2) of type FRAME_SIZE_ERROR.

PRIORITY帧的长度不是5个字节的话, 必须(MUST) 被当做一个类型为FRAME_SIZE_ERROR的流错误(Section 5.4.2)。

6.4 RST_STREAM

The RST_STREAM frame (type=0x3) allows for immediate termination of a stream. RST_STREAM is sent to request cancellation of a stream or to indicate that an error condition has occurred.

RST_STREAM帧 (type=0x3)可以用于立即终止一个流。发送RST_STREAM来请求取消一个流,或者指明发生了一个错误状态。

 +---------------------------------------------------------------+
 |                        Error Code (32)                        |
 +---------------------------------------------------------------+

Figure 9: RST_STREAM Frame Payload

Figure 9: RST_STREAM帧载荷

The RST_STREAM frame contains a single unsigned, 32-bit integer identifying the error code (Section 7). The error code indicates why the stream is being terminated.

RST_STREAM帧包含了一个单独的无符号32位整型值的错误码(Section 7)。错误码指明了为什么要终止流。

The RST_STREAM frame does not define any flags.

RST_STREAM帧不定义任何标记。

The RST_STREAM frame fully terminates the referenced stream and causes it to enter the "closed" state. After receiving a RST_STREAM on a stream, the receiver MUST NOT send additional frames for that stream, with the exception of PRIORITY. However, after sending the RST_STREAM, the sending endpoint MUST be prepared to receive and process additional frames sent on the stream that might have been sent by the peer prior to the arrival of the RST_STREAM.

RST_STREAM帧完全终止引用的流,并使它进入"closed"状态。在一个流中收到一个RST_STREAM之后,接收者 一定不能(MUST NOT) 再为那个流发送额外的帧,PRIORITY是例外。然而,在发送RST_STREAM之后,发送端 必须(MUST) 准备接收和处理额外的,可能由对端在RST_STREAM到达之前在那个流上发送的帧。

RST_STREAM frames MUST be associated with a stream. If a RST_STREAM frame is received with a stream identifier of 0x0, the recipient MUST treat this as a connection error (Section 5.4.1) of type PROTOCOL_ERROR.

RST_STREAM帧 必须(MUST) 关联一个流。如果RST_STREAM帧的流标识符是0x0,则接收者 必须(MUST) 将其作为一个类型是PROTOCOL_ERROR的连接错误(Section 5.4.1)处理。

RST_STREAM frames MUST NOT be sent for a stream in the "idle" state. If a RST_STREAM frame identifying an idle stream is received, the recipient MUST treat this as a connection error (Section 5.4.1) of type PROTOCOL_ERROR.

RST_STREAM帧 一定不能(MUST NOT) 为"idle"状态的流而发送。如果接收了一个RST_STREAM帧,而它标识了一个idle流,则接收者 必须(MUST) 将其作为一个类型是PROTOCOL_ERROR的连接错误(Section 5.4.1)处理。

A RST_STREAM frame with a length other than 4 octets MUST be treated as a connection error (Section 5.4.1) of type FRAME_SIZE_ERROR.

RST_STREAM帧的长度不是4字节的话, 必须(MUST) 被作为一个类型是FRAME_SIZE_ERROR的连接错误(Section 5.4.1)处理。

6.5 SETTINGS

The SETTINGS frame (type=0x4) conveys configuration parameters that affect how endpoints communicate, such as preferences and constraints on peer behavior. The SETTINGS frame is also used to acknowledge the receipt of those parameters. Individually, a SETTINGS parameter can also be referred to as a "setting".

SETTINGS帧 (type=0x4) 携带影响端点间如何通信的配置参数,比如关于对端行为的首选项和限制。SETTINGS帧也用于确认接收到了那些参数。个别地,一个SETTINGS参数也可以被称为一个"setting"。

SETTINGS parameters are not negotiated; they describe characteristics of the sending peer, which are used by the receiving peer. Different values for the same parameter can be advertised by each peer. For example, a client might set a high initial flow-control window, whereas a server might set a lower value to conserve resources.

不协商SETTINGS参数;它们描述了发送端的特性,而由接收端使用。端点之间对于相同参数可以广告不同的值。比如,一个客户端可以设置一个较大的初始flow-control窗口,然而服务器可以设置一个小的值来保留资源。

A SETTINGS frame MUST be sent by both endpoints at the start of a connection and MAY be sent at any other time by either endpoint over the lifetime of the connection. Implementations MUST support all of the parameters defined by this specification.

SETTINGS帧 必须(MUST) 在连接开始时,两端都发送,而在连接整个生命期中其它的任何时间点,其中的一个端点 可以(MAY) 发送。实现 必须(MUST) 支持这份规范定义的所有参数。

Each parameter in a SETTINGS frame replaces any existing value for that parameter. Parameters are processed in the order in which they appear, and a receiver of a SETTINGS frame does not need to maintain any state other than the current value of its parameters. Therefore, the value of a SETTINGS parameter is the last value that is seen by a receiver.

SETTINGS帧中的每个参数替换那个参数既有的值。参数以它们出现的顺序处理,SETTINGS帧的接收者不需要维护额外的状态,除了参数的当前值。因此,一个SETTINGS参数的值是接收者收到的最后的值。

SETTINGS parameters are acknowledged by the receiving peer. To enable this, the SETTINGS frame defines the following flag:

SETTINGS参数由接收端作确认。为了启用这一点,SETTINGS帧定义了如下的标记:

ACK (0x1):
When set, bit 0 indicates that this frame acknowledges receipt and application of the peer's SETTINGS frame. When this bit is set, the payload of the SETTINGS frame MUST be empty. Receipt of a SETTINGS frame with the ACK flag set and a length field value other than 0 MUST be treated as a connection error (Section 5.4.1) of type FRAME_SIZE_ERROR. For more information, see Section 6.5.3 ("Settings Synchronization").

ACK (0x1): 设置时,位0指示了这个帧用于确认对端的SETTINGS帧的接收和应用。当设置了这个位时,SETTINGS帧的载荷必须是空的。接收到一个设置了ACK标记的SETTINGS帧,而长度字段的值不是0,这 必须(MUST) 被当做一个类型为FRAME_SIZE_ERROR的连接错误(Section 5.4.1)。要获得更多信息,请参考Section 6.5.3 ("Settings Synchronization")。

SETTINGS frames always apply to a connection, never a single stream. The stream identifier for a SETTINGS frame MUST be zero (0x0). If an endpoint receives a SETTINGS frame whose stream identifier field is anything other than 0x0, the endpoint MUST respond with a connection error (Section 5.4.1) of type PROTOCOL_ERROR.

SETTINGS帧总是应用于一个连接,而不是一个单独的流。SETTINGS帧的流标识符 必须(MUST) 是零(0x0)。如果一个端点收到了一个流标识符字段不是0的SETTINGS帧,则 必须(MUST) 以一个类型为 PROTOCOL_ERROR 的连接错误 (Section 5.4.1) 来响应。

The SETTINGS frame affects connection state. A badly formed or incomplete SETTINGS frame MUST be treated as a connection error (Section 5.4.1) of type PROTOCOL_ERROR.

SETTINGS帧影响连接的状态。一个格式错误或不完整的SETTINGS帧 必须(MUST) 被当做一个类型为PROTOCOL_ERROR的连接错误(Section 5.4.1)。

A SETTINGS frame with a length other than a multiple of 6 octets MUST be treated as a connection error (Section 5.4.1) of type FRAME_SIZE_ERROR.

SETTINGS帧的长度如果不是6字节的整数倍的话,必须被作为一个类型是FRAME_SIZE_ERROR](https://http2.github.io/http2-spec/#FRAME_SIZE_ERROR)的连接错误(Section 5.4.1)。

6.5.1 SETTINGS格式(SETTINGS Format)

The payload of a SETTINGS frame consists of zero or more parameters, each consisting of an unsigned 16-bit setting identifier and an unsigned 32-bit value.

SETTINGS帧的载荷由零个或多个参数组成,每个参数由一个无符号16位的设置标识符和一个无符号的32位值组成。

 +-------------------------------+
 |       Identifier (16)         |
 +-------------------------------+-------------------------------+
 |                        Value (32)                             |
 +---------------------------------------------------------------+

Figure 10: Setting Format

图 10: 设置项的格式

6.5.2 已定义的SETTINGS参数(Defined SETTINGS Parameters)

The following parameters are defined:

已定义了如下的参数:

SETTINGS_HEADER_TABLE_SIZE (0x1):
Allows the sender to inform the remote endpoint of the maximum size of the header compression table used to decode header blocks, in octets. The encoder can select any size equal to or less than this value by using signaling specific to the header compression format inside a header block (see [COMPRESSION]). The initial value is 4,096 octets.

SETTINGS_HEADER_TABLE_SIZE (0x1):
允许发送者通知远端,用于解码首部块的首部压缩表的最大大小,以字节位单位。编码器可以可以选择任何等于或小于这个值的大小,通过使用首部块内信号特有的首部压缩格式(参考[[COMPRESSION]
](https://http2.github.io/http2-spec/#COMPRESSION))。初始值是4,096字节。

SETTINGS_ENABLE_PUSH (0x2):
This setting can be used to disable server push (Section 8.2). An endpoint MUST NOT send a PUSH_PROMISE frame if it receives this parameter set to a value of 0. An endpoint that has both set this parameter to 0 and had it acknowledged MUST treat the receipt of a PUSH_PROMISE frame as a connection error (Section 5.4.1) of type PROTOCOL_ERROR.

SETTINGS_ENABLE_PUSH (0x2):
这个设置项可被用于禁用服务端推送(Section 8.2)。一个终端如果收到了这个设置项,且值为0,则它 一定不能(MUST NOT) 发送PUSH_PROMISE帧。一个已经将这个参数设置为了0,且已经收到了对这个设置项的确认的终端,则在收到一个PUSH_PROMISE帧时, 必须(MUST) 将其作为一个类型是PROTOCOL_ERROR的连接错误(Section 5.4.1)。

The initial value is 1, which indicates that server push is permitted. Any value other than 0 or 1 MUST be treated as a connection error (Section 5.4.1) of type PROTOCOL_ERROR.

初始值是1,这表示服务端推送是允许的。任何0或1之外的值 必须(MUST) 被作为一个类型是PROTOCOL_ERROR的连接错误(Section 5.4.1)。

SETTINGS_MAX_CONCURRENT_STREAMS (0x3):
Indicates the maximum number of concurrent streams that the sender will allow. This limit is directional: it applies to the number of streams that the sender permits the receiver to create. Initially, there is no limit to this value. It is recommended that this value be no smaller than 100, so as to not unnecessarily limit parallelism.

SETTINGS_MAX_CONCURRENT_STREAMS (0x3):
指明了发送者允许的最大的并发流个数。这个限制是有方向的:它应用于发送者允许接收者创建的流的个数。初始时,这个值没有限制。建议这个值不要小于100,以便于不要不必要地限制了并发性。

A value of 0 for SETTINGS_MAX_CONCURRENT_STREAMS SHOULD NOT be treated as special by endpoints. A zero value does prevent the creation of new streams; however, this can also happen for any limit that is exhausted with active streams. Servers SHOULD only set a zero value for short durations; if a server does not wish to accept requests, closing the connection is more appropriate.

SETTINGS_MAX_CONCURRENT_STREAMS被设置为0 不应该(SHULD NOT) 被终端特殊对待。值为0确实阻止创建新的流;然而,这也可能发生在活跃的流超出了限制的时候。服务器 应该(SHOULD) 只短暂地将这个值设为0;如果一个服务器不希望接受请求,关闭连接更合适。

SETTINGS_INITIAL_WINDOW_SIZE (0x4):
Indicates the sender's initial window size (in octets) for stream-level flow control. The initial value is 216-1 (65,535) octets.

SETTINGS_INITIAL_WINDOW_SIZE (0x4):
指明了发送者stream-level flow control的初始窗口大小(以字节为单位)。初始值为2^16 - 1 (65,535)字节。

This setting affects the window size of all streams (see Section 6.9.2).

这个设置项影响所有流的窗口大小(参见Section 6.9.2)。

Values above the maximum flow-control window size of 231-1 MUST be treated as a connection error (Section 5.4.1) of type FLOW_CONTROL_ERROR.

值大于2^31-1的最大flow-control窗口大小 必须(MUST) 被作为一个类型是FLOW_CONTROL_ERROR的连接错误(Section 5.4.1)。

SETTINGS_MAX_FRAME_SIZE (0x5):
Indicates the size of the largest frame payload that the sender is willing to receive, in octets.

SETTINGS_MAX_FRAME_SIZE (0x5):
指明了发送者期望接收的最大的帧载荷大小,以字节为单位。

The initial value is 214 (16,384) octets. The value advertised by an endpoint MUST be between this initial value and the maximum allowed frame size (224-1 or 16,777,215 octets), inclusive. Values outside this range MUST be treated as a connection error (Section 5.4.1) of type PROTOCOL_ERROR.

初始值是2^14 (16,384)。终端广告的值 必须(MUST) 介于初始值和允许的最大帧大小(2^24-1 or 16,777,215 字节)之间,包含。这个范围之外的值 必须(MUST) 被作为一个类型是PROTOCOL_ERROR的连接错误(Section 5.4.1)。

SETTINGS_MAX_HEADER_LIST_SIZE (0x6):
This advisory setting informs a peer of the maximum size of header list that the sender is prepared to accept, in octets. The value is based on the uncompressed size of header fields, including the length of the name and value in octets plus an overhead of 32 octets for each header field.

SETTINGS_MAX_HEADER_LIST_SIZE (0x6):
这个建议性的设置通知对端发送者准备接受的首部列表的最大大小,以字节为单位。这个值是基于首部字段未压缩的大小来计算的,包括名字和值以字节为单位的长度,再为每个首部字段加上32字节。

For any given request, a lower limit than what is advertised MAY be enforced. The initial value of this setting is unlimited.

对于任何给定的请求,可以(MAY) 实施小于广告的限制的值。这个设置项的初始值没有限制。

An endpoint that receives a SETTINGS frame with any unknown or unsupported identifier MUST ignore that setting.

一个终端接收了一个SETTINGS帧,其中未知的或不支持的标识符的设置项 必须(MUST) 被忽略。

6.5.3 设置同步(Settings Synchronization)

Most values in SETTINGS benefit from or require an understanding of when the peer has received and applied the changed parameter values. In order to provide such synchronization timepoints, the recipient of a SETTINGS frame in which the ACK flag is not set MUST apply the updated parameters as soon as possible upon receipt.

SETTINGS中的大多数值受益于或需要知道对端在何时接收并应用改变的参数值。为了提供这种同步时间点,一个ACK标记没有设置的SETTINGS帧的接收者 必须(MUST) 一收到帧就尽可能快地应用更新后的参数。

The values in the SETTINGS frame MUST be processed in the order they appear, with no other frame processing between values. Unsupported parameters MUST be ignored. Once all values have been processed, the recipient MUST immediately emit a SETTINGS frame with the ACK flag set. Upon receiving a SETTINGS frame with the ACK flag set, the sender of the altered parameters can rely on the setting having been applied.

SETTINGS帧中的参数 必须(MUST) 以它们出现的顺序处理,值之间没有对其它帧的处理。不支持的参数 必须(MUST) 被忽略。一旦处理了所有值,则接收者 必须(MUST) 立即发送一个设置了ACK标记的SETTINGS帧。一旦接收到设置了ACK标记的SETTINGS帧,改变了参数的发送者可以依赖于已经应用的设置了。

If the sender of a SETTINGS frame does not receive an acknowledgement within a reasonable amount of time, it MAY issue a connection error (Section 5.4.1) of type SETTINGS_TIMEOUT.

如果SETTINGS帧的发送者没有在合理的时间内收到确认,它 可以(MAY) 产生一个类型为SETTINGS_TIMEOUT的连接错误(Section 5.4.1)。

Submit