Internet Engineering Task Force (IETF)                           R. Peon
Request for Comments: 7541                                   Google, Inc
Category: Standards Track                                     H. Ruellan
ISSN: 2070-1721                                                Canon CRF
                                                                May 2015
        
Internet Engineering Task Force (IETF)                           R. Peon
Request for Comments: 7541                                   Google, Inc
Category: Standards Track                                     H. Ruellan
ISSN: 2070-1721                                                Canon CRF
                                                                May 2015
        

HPACK: Header Compression for HTTP/2

HPACK:HTTP/2的头压缩

Abstract

摘要

This specification defines HPACK, a compression format for efficiently representing HTTP header fields, to be used in HTTP/2.

本规范定义了HPACK,一种用于高效表示HTTP头字段的压缩格式,将在HTTP/2中使用。

Status of This Memo

关于下段备忘

This is an Internet Standards Track document.

这是一份互联网标准跟踪文件。

This document is a product of the Internet Engineering Task Force (IETF). It represents the consensus of the IETF community. It has received public review and has been approved for publication by the Internet Engineering Steering Group (IESG). Further information on Internet Standards is available in Section 2 of RFC 5741.

本文件是互联网工程任务组(IETF)的产品。它代表了IETF社区的共识。它已经接受了公众审查,并已被互联网工程指导小组(IESG)批准出版。有关互联网标准的更多信息,请参见RFC 5741第2节。

Information about the current status of this document, any errata, and how to provide feedback on it may be obtained at http://www.rfc-editor.org/info/rfc7541.

有关本文件当前状态、任何勘误表以及如何提供反馈的信息,请访问http://www.rfc-editor.org/info/rfc7541.

Copyright Notice

版权公告

Copyright (c) 2015 IETF Trust and the persons identified as the document authors. All rights reserved.

版权所有(c)2015 IETF信托基金和确定为文件作者的人员。版权所有。

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.

本文件受BCP 78和IETF信托有关IETF文件的法律规定的约束(http://trustee.ietf.org/license-info)自本文件出版之日起生效。请仔细阅读这些文件,因为它们描述了您对本文件的权利和限制。从本文件中提取的代码组件必须包括信托法律条款第4.e节中所述的简化BSD许可证文本,并提供简化BSD许可证中所述的无担保。

Table of Contents

目录

   1. Introduction ....................................................4
      1.1. Overview ...................................................4
      1.2. Conventions ................................................5
      1.3. Terminology ................................................5
   2. Compression Process Overview ....................................6
      2.1. Header List Ordering .......................................6
      2.2. Encoding and Decoding Contexts .............................6
      2.3. Indexing Tables ............................................6
           2.3.1. Static Table ........................................6
           2.3.2. Dynamic Table .......................................6
           2.3.3. Index Address Space .................................7
      2.4. Header Field Representation ................................8
   3. Header Block Decoding ...........................................8
      3.1. Header Block Processing ....................................8
      3.2. Header Field Representation Processing .....................9
   4. Dynamic Table Management ........................................9
      4.1. Calculating Table Size ....................................10
      4.2. Maximum Table Size ........................................10
      4.3. Entry Eviction When Dynamic Table Size Changes ............11
      4.4. Entry Eviction When Adding New Entries ....................11
   5. Primitive Type Representations .................................11
      5.1. Integer Representation ....................................11
      5.2. String Literal Representation .............................13
   6. Binary Format ..................................................14
      6.1. Indexed Header Field Representation .......................14
      6.2. Literal Header Field Representation .......................15
           6.2.1. Literal Header Field with Incremental Indexing .....15
           6.2.2. Literal Header Field without Indexing ..............16
           6.2.3. Literal Header Field Never Indexed .................17
      6.3. Dynamic Table Size Update .................................18
   7. Security Considerations ........................................19
      7.1. Probing Dynamic Table State ...............................19
           7.1.1. Applicability to HPACK and HTTP ....................20
           7.1.2. Mitigation .........................................20
           7.1.3. Never-Indexed Literals .............................21
      7.2. Static Huffman Encoding ...................................22
      7.3. Memory Consumption ........................................22
      7.4. Implementation Limits .....................................23
   8. References .....................................................23
      8.1. Normative References ......................................23
      8.2. Informative References ....................................24
   Appendix A. Static Table Definition ...............................25
   Appendix B. Huffman Code ..........................................27
        
   1. Introduction ....................................................4
      1.1. Overview ...................................................4
      1.2. Conventions ................................................5
      1.3. Terminology ................................................5
   2. Compression Process Overview ....................................6
      2.1. Header List Ordering .......................................6
      2.2. Encoding and Decoding Contexts .............................6
      2.3. Indexing Tables ............................................6
           2.3.1. Static Table ........................................6
           2.3.2. Dynamic Table .......................................6
           2.3.3. Index Address Space .................................7
      2.4. Header Field Representation ................................8
   3. Header Block Decoding ...........................................8
      3.1. Header Block Processing ....................................8
      3.2. Header Field Representation Processing .....................9
   4. Dynamic Table Management ........................................9
      4.1. Calculating Table Size ....................................10
      4.2. Maximum Table Size ........................................10
      4.3. Entry Eviction When Dynamic Table Size Changes ............11
      4.4. Entry Eviction When Adding New Entries ....................11
   5. Primitive Type Representations .................................11
      5.1. Integer Representation ....................................11
      5.2. String Literal Representation .............................13
   6. Binary Format ..................................................14
      6.1. Indexed Header Field Representation .......................14
      6.2. Literal Header Field Representation .......................15
           6.2.1. Literal Header Field with Incremental Indexing .....15
           6.2.2. Literal Header Field without Indexing ..............16
           6.2.3. Literal Header Field Never Indexed .................17
      6.3. Dynamic Table Size Update .................................18
   7. Security Considerations ........................................19
      7.1. Probing Dynamic Table State ...............................19
           7.1.1. Applicability to HPACK and HTTP ....................20
           7.1.2. Mitigation .........................................20
           7.1.3. Never-Indexed Literals .............................21
      7.2. Static Huffman Encoding ...................................22
      7.3. Memory Consumption ........................................22
      7.4. Implementation Limits .....................................23
   8. References .....................................................23
      8.1. Normative References ......................................23
      8.2. Informative References ....................................24
   Appendix A. Static Table Definition ...............................25
   Appendix B. Huffman Code ..........................................27
        
   Appendix C. Examples ..............................................33
     C.1. Integer Representation Examples ............................33
       C.1.1. Example 1: Encoding 10 Using a 5-Bit Prefix ............33
       C.1.2. Example 2: Encoding 1337 Using a 5-Bit Prefix ..........33
       C.1.3. Example 3: Encoding 42 Starting at an Octet Boundary ...34
     C.2. Header Field Representation Examples .......................34
       C.2.1. Literal Header Field with Indexing .....................34
       C.2.2. Literal Header Field without Indexing ..................35
       C.2.3. Literal Header Field Never Indexed .....................36
       C.2.4. Indexed Header Field ...................................37
     C.3. Request Examples without Huffman Coding ....................37
       C.3.1. First Request ..........................................37
       C.3.2. Second Request .........................................38
       C.3.3. Third Request ..........................................39
     C.4. Request Examples with Huffman Coding .......................41
       C.4.1. First Request ..........................................41
       C.4.2. Second Request .........................................42
       C.4.3. Third Request ..........................................43
     C.5. Response Examples without Huffman Coding ...................45
       C.5.1. First Response .........................................45
       C.5.2. Second Response ........................................46
       C.5.3. Third Response .........................................47
     C.6. Response Examples with Huffman Coding ......................49
       C.6.1. First Response .........................................49
       C.6.2. Second Response ........................................51
       C.6.3. Third Response .........................................52
   Acknowledgments ...................................................55
   Authors' Addresses ................................................55
        
   Appendix C. Examples ..............................................33
     C.1. Integer Representation Examples ............................33
       C.1.1. Example 1: Encoding 10 Using a 5-Bit Prefix ............33
       C.1.2. Example 2: Encoding 1337 Using a 5-Bit Prefix ..........33
       C.1.3. Example 3: Encoding 42 Starting at an Octet Boundary ...34
     C.2. Header Field Representation Examples .......................34
       C.2.1. Literal Header Field with Indexing .....................34
       C.2.2. Literal Header Field without Indexing ..................35
       C.2.3. Literal Header Field Never Indexed .....................36
       C.2.4. Indexed Header Field ...................................37
     C.3. Request Examples without Huffman Coding ....................37
       C.3.1. First Request ..........................................37
       C.3.2. Second Request .........................................38
       C.3.3. Third Request ..........................................39
     C.4. Request Examples with Huffman Coding .......................41
       C.4.1. First Request ..........................................41
       C.4.2. Second Request .........................................42
       C.4.3. Third Request ..........................................43
     C.5. Response Examples without Huffman Coding ...................45
       C.5.1. First Response .........................................45
       C.5.2. Second Response ........................................46
       C.5.3. Third Response .........................................47
     C.6. Response Examples with Huffman Coding ......................49
       C.6.1. First Response .........................................49
       C.6.2. Second Response ........................................51
       C.6.3. Third Response .........................................52
   Acknowledgments ...................................................55
   Authors' Addresses ................................................55
        
1. Introduction
1. 介绍

In HTTP/1.1 (see [RFC7230]), header fields are not compressed. As web pages have grown to require dozens to hundreds of requests, the redundant header fields in these requests unnecessarily consume bandwidth, measurably increasing latency.

在HTTP/1.1(参见[RFC7230])中,头字段未压缩。随着web页面增长到需要几十到数百个请求,这些请求中的冗余头字段会不必要地消耗带宽,从而显著增加延迟。

SPDY [SPDY] initially addressed this redundancy by compressing header fields using the DEFLATE [DEFLATE] format, which proved very effective at efficiently representing the redundant header fields. However, that approach exposed a security risk as demonstrated by the CRIME (Compression Ratio Info-leak Made Easy) attack (see [CRIME]).

SPDY[SPDY]最初通过使用DEFLATE[DEFLATE]格式压缩报头字段来解决这种冗余问题,事实证明,这种格式在高效表示冗余报头字段方面非常有效。然而,这种方法暴露了一种安全风险,犯罪(压缩比信息泄漏变得容易)攻击(参见[犯罪])就是明证。

This specification defines HPACK, a new compressor that eliminates redundant header fields, limits vulnerability to known security attacks, and has a bounded memory requirement for use in constrained environments. Potential security concerns for HPACK are described in Section 7.

本规范定义了HPACK,这是一种新的压缩器,它消除了冗余的报头字段,限制了已知安全攻击的漏洞,并且在受限环境中使用时具有有限的内存需求。第7节描述了HPACK的潜在安全问题。

The HPACK format is intentionally simple and inflexible. Both characteristics reduce the risk of interoperability or security issues due to implementation error. No extensibility mechanisms are defined; changes to the format are only possible by defining a complete replacement.

HPACK格式有意简单且不灵活。这两种特性都降低了由于实现错误而导致互操作性或安全问题的风险。没有定义可扩展性机制;只有定义完整的替换,才能更改格式。

1.1. Overview
1.1. 概述

The format defined in this specification treats a list of header fields as an ordered collection of name-value pairs that can include duplicate pairs. Names and values are considered to be opaque sequences of octets, and the order of header fields is preserved after being compressed and decompressed.

本规范中定义的格式将标题字段列表视为名称-值对的有序集合,其中可能包含重复对。名称和值被认为是不透明的八位字节序列,头字段的顺序在压缩和解压缩后保持不变。

Encoding is informed by header field tables that map header fields to indexed values. These header field tables can be incrementally updated as new header fields are encoded or decoded.

编码由将标题字段映射到索引值的标题字段表通知。这些标头字段表可以随着新标头字段的编码或解码而增量更新。

In the encoded form, a header field is represented either literally or as a reference to a header field in one of the header field tables. Therefore, a list of header fields can be encoded using a mixture of references and literal values.

在编码形式中,标题字段以字面形式或作为对其中一个标题字段表中的标题字段的引用来表示。因此,可以使用引用和文本值的混合来对标题字段列表进行编码。

Literal values are either encoded directly or use a static Huffman code.

文字值要么直接编码,要么使用静态哈夫曼代码。

The encoder is responsible for deciding which header fields to insert as new entries in the header field tables. The decoder executes the modifications to the header field tables prescribed by the encoder,

编码器负责决定将哪些标头字段作为新条目插入标头字段表中。解码器执行对编码器规定的报头字段表的修改,

reconstructing the list of header fields in the process. This enables decoders to remain simple and interoperate with a wide variety of encoders.

重建进程中标题字段的列表。这使得解码器保持简单,并与各种编码器互操作。

Examples illustrating the use of these different mechanisms to represent header fields are available in Appendix C.

附录C中提供了使用这些不同机制表示标题字段的示例。

1.2. Conventions
1.2. 习俗

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 [RFC2119].

本文件中的关键词“必须”、“不得”、“要求”、“应”、“不应”、“应”、“不应”、“建议”、“可”和“可选”应按照RFC 2119[RFC2119]中所述进行解释。

All numeric values are in network byte order. Values are unsigned unless otherwise indicated. Literal values are provided in decimal or hexadecimal as appropriate.

所有数值均按网络字节顺序排列。除非另有说明,否则值是无符号的。文字值以十进制或十六进制(视情况而定)提供。

1.3. Terminology
1.3. 术语

This specification uses the following terms:

本规范使用以下术语:

Header Field: A name-value pair. Both the name and value are treated as opaque sequences of octets.

标题字段:名称-值对。名称和值都被视为不透明的八位字节序列。

Dynamic Table: The dynamic table (see Section 2.3.2) is a table that associates stored header fields with index values. This table is dynamic and specific to an encoding or decoding context.

动态表:动态表(见第2.3.2节)是一个将存储的标题字段与索引值关联的表。此表是动态的,特定于编码或解码上下文。

Static Table: The static table (see Section 2.3.1) is a table that statically associates header fields that occur frequently with index values. This table is ordered, read-only, always accessible, and it may be shared amongst all encoding or decoding contexts.

静态表:静态表(见第2.3.1节)是一个静态关联频繁出现的标题字段和索引值的表。此表是有序的、只读的、始终可访问的,并且可以在所有编码或解码上下文中共享。

Header List: A header list is an ordered collection of header fields that are encoded jointly and can contain duplicate header fields. A complete list of header fields contained in an HTTP/2 header block is a header list.

标题列表:标题列表是联合编码的标题字段的有序集合,可以包含重复的标题字段。HTTP/2头块中包含的头字段的完整列表是头列表。

Header Field Representation: A header field can be represented in encoded form either as a literal or as an index (see Section 2.4).

标题字段表示:标题字段可以以编码形式表示为文字或索引(参见第2.4节)。

Header Block: An ordered list of header field representations, which, when decoded, yields a complete header list.

标题块:标题字段表示的有序列表,解码后生成完整的标题列表。

2. Compression Process Overview
2. 压缩过程概述

This specification does not describe a specific algorithm for an encoder. Instead, it defines precisely how a decoder is expected to operate, allowing encoders to produce any encoding that this definition permits.

本规范不描述编码器的特定算法。相反,它精确地定义了解码器的预期操作方式,允许编码器产生该定义允许的任何编码。

2.1. Header List Ordering
2.1. 标题列表排序

HPACK preserves the ordering of header fields inside the header list. An encoder MUST order header field representations in the header block according to their ordering in the original header list. A decoder MUST order header fields in the decoded header list according to their ordering in the header block.

HPACK保留标题列表中标题字段的顺序。编码器必须根据其在原始标题列表中的顺序对标题块中的标题字段表示进行排序。解码器必须根据其在头块中的顺序对解码头列表中的头字段进行排序。

2.2. Encoding and Decoding Contexts
2.2. 编码和解码上下文

To decompress header blocks, a decoder only needs to maintain a dynamic table (see Section 2.3.2) as a decoding context. No other dynamic state is needed.

要解压缩头块,解码器只需要维护一个动态表(见第2.3.2节)作为解码上下文。不需要其他动态状态。

When used for bidirectional communication, such as in HTTP, the encoding and decoding dynamic tables maintained by an endpoint are completely independent, i.e., the request and response dynamic tables are separate.

当用于双向通信时,例如在HTTP中,由端点维护的编码和解码动态表是完全独立的,即请求和响应动态表是分开的。

2.3. Indexing Tables
2.3. 索引表

HPACK uses two tables for associating header fields to indexes. The static table (see Section 2.3.1) is predefined and contains common header fields (most of them with an empty value). The dynamic table (see Section 2.3.2) is dynamic and can be used by the encoder to index header fields repeated in the encoded header lists.

HPACK使用两个表将标题字段与索引相关联。静态表(见第2.3.1节)是预定义的,包含公共标题字段(其中大多数字段为空值)。动态表(见第2.3.2节)是动态的,编码器可以使用它来索引编码标题列表中重复的标题字段。

These two tables are combined into a single address space for defining index values (see Section 2.3.3).

这两个表组合成一个地址空间,用于定义索引值(见第2.3.3节)。

2.3.1. Static Table
2.3.1. 静态表

The static table consists of a predefined static list of header fields. Its entries are defined in Appendix A.

静态表由预定义的标题字段静态列表组成。其条目定义见附录A。

2.3.2. Dynamic Table
2.3.2. 动态表

The dynamic table consists of a list of header fields maintained in first-in, first-out order. The first and newest entry in a dynamic table is at the lowest index, and the oldest entry of a dynamic table is at the highest index.

动态表由按先进先出顺序维护的标题字段列表组成。动态表中的第一个也是最新的条目位于最低索引,而动态表中最早的条目位于最高索引。

The dynamic table is initially empty. Entries are added as each header block is decompressed.

动态表最初为空。在解压每个头块时添加条目。

The dynamic table can contain duplicate entries (i.e., entries with the same name and same value). Therefore, duplicate entries MUST NOT be treated as an error by a decoder.

动态表可以包含重复的条目(即具有相同名称和相同值的条目)。因此,解码器不得将重复条目视为错误。

The encoder decides how to update the dynamic table and as such can control how much memory is used by the dynamic table. To limit the memory requirements of the decoder, the dynamic table size is strictly bounded (see Section 4.2).

编码器决定如何更新动态表,因此可以控制动态表使用的内存量。为了限制解码器的内存需求,动态表大小受到严格限制(见第4.2节)。

The decoder updates the dynamic table during the processing of a list of header field representations (see Section 3.2).

解码器在处理标题字段表示列表期间更新动态表(见第3.2节)。

2.3.3. Index Address Space
2.3.3. 索引地址空间

The static table and the dynamic table are combined into a single index address space.

静态表和动态表合并到一个索引地址空间中。

Indices between 1 and the length of the static table (inclusive) refer to elements in the static table (see Section 2.3.1).

1和静态表长度(含)之间的索引指静态表中的元素(见第2.3.1节)。

Indices strictly greater than the length of the static table refer to elements in the dynamic table (see Section 2.3.2). The length of the static table is subtracted to find the index into the dynamic table.

严格大于静态表长度的索引指的是动态表中的元素(见第2.3.2节)。减去静态表的长度,找到动态表的索引。

Indices strictly greater than the sum of the lengths of both tables MUST be treated as a decoding error.

严格大于两个表的长度之和的索引必须视为解码错误。

For a static table size of s and a dynamic table size of k, the following diagram shows the entire valid index address space.

对于静态表大小s和动态表大小k,下图显示了整个有效索引地址空间。

           <----------  Index Address Space ---------->
           <-- Static  Table -->  <-- Dynamic Table -->
           +---+-----------+---+  +---+-----------+---+
           | 1 |    ...    | s |  |s+1|    ...    |s+k|
           +---+-----------+---+  +---+-----------+---+
                                  ^                   |
                                  |                   V
                           Insertion Point      Dropping Point
        
           <----------  Index Address Space ---------->
           <-- Static  Table -->  <-- Dynamic Table -->
           +---+-----------+---+  +---+-----------+---+
           | 1 |    ...    | s |  |s+1|    ...    |s+k|
           +---+-----------+---+  +---+-----------+---+
                                  ^                   |
                                  |                   V
                           Insertion Point      Dropping Point
        

Figure 1: Index Address Space

图1:索引地址空间

2.4. Header Field Representation
2.4. 标题字段表示法

An encoded header field can be represented either as an index or as a literal.

编码的头字段可以表示为索引或文字。

An indexed representation defines a header field as a reference to an entry in either the static table or the dynamic table (see Section 6.1).

索引表示法将标题字段定义为对静态表或动态表中条目的引用(参见第6.1节)。

A literal representation defines a header field by specifying its name and value. The header field name can be represented literally or as a reference to an entry in either the static table or the dynamic table. The header field value is represented literally.

文字表示通过指定标题字段的名称和值来定义标题字段。标题字段名可以按字面意思表示,也可以作为对静态表或动态表中某个条目的引用。标题字段值按字面表示。

Three different literal representations are defined:

定义了三种不同的文字表示:

o A literal representation that adds the header field as a new entry at the beginning of the dynamic table (see Section 6.2.1).

o 一种文字表示法,将标题字段作为新条目添加到动态表的开头(参见第6.2.1节)。

o A literal representation that does not add the header field to the dynamic table (see Section 6.2.2).

o 不向动态表中添加标题字段的文字表示法(见第6.2.2节)。

o A literal representation that does not add the header field to the dynamic table, with the additional stipulation that this header field always use a literal representation, in particular when re-encoded by an intermediary (see Section 6.2.3). This representation is intended for protecting header field values that are not to be put at risk by compressing them (see Section 7.1.3 for more details).

o 一种不向动态表中添加标题字段的文字表示法,另外规定该标题字段始终使用文字表示法,特别是在由中间层重新编码时(见第6.2.3节)。此表示法旨在保护不会因压缩而面临风险的标题字段值(有关更多详细信息,请参阅第7.1.3节)。

The selection of one of these literal representations can be guided by security considerations, in order to protect sensitive header field values (see Section 7.1).

为了保护敏感的头字段值,可以根据安全考虑来选择这些文字表示之一(见第7.1节)。

The literal representation of a header field name or of a header field value can encode the sequence of octets either directly or using a static Huffman code (see Section 5.2).

标题字段名称或标题字段值的文字表示可以直接或使用静态哈夫曼码对八位字节序列进行编码(见第5.2节)。

3. Header Block Decoding
3. 头块译码
3.1. Header Block Processing
3.1. 头块处理

A decoder processes a header block sequentially to reconstruct the original header list.

解码器按顺序处理报头块以重构原始报头列表。

A header block is the concatenation of header field representations. The different possible header field representations are described in Section 6.

标题块是标题字段表示的串联。第6节描述了不同可能的标题字段表示。

Once a header field is decoded and added to the reconstructed header list, the header field cannot be removed. A header field added to the header list can be safely passed to the application.

一旦头字段被解码并添加到重建的头列表中,就不能删除头字段。添加到标题列表的标题字段可以安全地传递给应用程序。

By passing the resulting header fields to the application, a decoder can be implemented with minimal transitory memory commitment in addition to the memory required for the dynamic table.

通过将得到的头字段传递给应用程序,除了动态表所需的内存外,还可以使用最小的临时内存投入来实现解码器。

3.2. Header Field Representation Processing
3.2. 标题字段表示处理

The processing of a header block to obtain a header list is defined in this section. To ensure that the decoding will successfully produce a header list, a decoder MUST obey the following rules.

本节定义了获取标题列表的标题块处理。为了确保解码将成功生成头列表,解码器必须遵守以下规则。

All the header field representations contained in a header block are processed in the order in which they appear, as specified below. Details on the formatting of the various header field representations and some additional processing instructions are found in Section 6.

标题块中包含的所有标题字段表示将按照其出现的顺序进行处理,如下所述。有关各种标题字段表示形式的格式和一些附加处理说明的详细信息,请参见第6节。

An _indexed representation_ entails the following actions:

索引表示法包含以下操作:

o The header field corresponding to the referenced entry in either the static table or dynamic table is appended to the decoded header list.

o 与静态表或动态表中的引用条目相对应的标题字段追加到解码标题列表中。

A _literal representation_ that is _not added_ to the dynamic table entails the following action:

未添加到动态表中的文字表示包含以下操作:

o The header field is appended to the decoded header list.

o 标题字段追加到解码标题列表中。

A _literal representation_ that is _added_ to the dynamic table entails the following actions:

添加到动态表中的文字表示包含以下操作:

o The header field is appended to the decoded header list.

o 标题字段追加到解码标题列表中。

o The header field is inserted at the beginning of the dynamic table. This insertion could result in the eviction of previous entries in the dynamic table (see Section 4.4).

o 标题字段插入到动态表的开头。这种插入可能导致删除动态表中以前的条目(参见第4.4节)。

4. Dynamic Table Management
4. 动态表管理

To limit the memory requirements on the decoder side, the dynamic table is constrained in size.

为了限制解码器端的内存需求,动态表的大小受到限制。

4.1. Calculating Table Size
4.1. 计算表大小

The size of the dynamic table is the sum of the size of its entries.

动态表的大小是其条目大小的总和。

The size of an entry is the sum of its name's length in octets (as defined in Section 5.2), its value's length in octets, and 32.

条目的大小是其名称的长度(以八位字节为单位)(定义见第5.2节)、其值的长度(以八位字节为单位)和32的总和。

The size of an entry is calculated using the length of its name and value without any Huffman encoding applied.

条目的大小是使用其名称和值的长度计算的,不应用任何哈夫曼编码。

Note: The additional 32 octets account for an estimated overhead associated with an entry. For example, an entry structure using two 64-bit pointers to reference the name and the value of the entry and two 64-bit integers for counting the number of references to the name and value would have 32 octets of overhead.

注:额外的32个八位字节占与条目相关的估计开销。例如,一个条目结构使用两个64位指针来引用条目的名称和值,以及两个64位整数来计算名称和值的引用数,其开销为32个八位字节。

4.2. Maximum Table Size
4.2. 最大表大小

Protocols that use HPACK determine the maximum size that the encoder is permitted to use for the dynamic table. In HTTP/2, this value is determined by the SETTINGS_HEADER_TABLE_SIZE setting (see Section 6.5.2 of [HTTP2]).

使用HPACK的协议确定编码器允许用于动态表的最大大小。在HTTP/2中,该值由设置\标题\表格\大小设置确定(见[HTTP2]第6.5.2节)。

An encoder can choose to use less capacity than this maximum size (see Section 6.3), but the chosen size MUST stay lower than or equal to the maximum set by the protocol.

编码器可以选择使用小于此最大大小的容量(参见第6.3节),但所选大小必须保持低于或等于协议设置的最大值。

A change in the maximum size of the dynamic table is signaled via a dynamic table size update (see Section 6.3). This dynamic table size update MUST occur at the beginning of the first header block following the change to the dynamic table size. In HTTP/2, this follows a settings acknowledgment (see Section 6.5.3 of [HTTP2]).

动态表最大大小的变化通过动态表大小更新发出信号(见第6.3节)。此动态表大小更新必须发生在动态表大小更改后的第一个标题块的开头。在HTTP/2中,这遵循设置确认(请参见[HTTP2]第6.5.3节)。

Multiple updates to the maximum table size can occur between the transmission of two header blocks. In the case that this size is changed more than once in this interval, the smallest maximum table size that occurs in that interval MUST be signaled in a dynamic table size update. The final maximum size is always signaled, resulting in at most two dynamic table size updates. This ensures that the decoder is able to perform eviction based on reductions in dynamic table size (see Section 4.3).

在两个头块的传输之间可能会发生对最大表大小的多次更新。如果此大小在此间隔内更改多次,则必须在动态表大小更新中通知该间隔内出现的最小最大表大小。最终的最大大小总是以信号的形式显示,从而导致最多两次动态表大小更新。这确保解码器能够基于动态表大小的减少执行逐出(参见第4.3节)。

This mechanism can be used to completely clear entries from the dynamic table by setting a maximum size of 0, which can subsequently be restored.

通过将最大大小设置为0,可以使用此机制从动态表中完全清除条目,随后可以恢复该最大大小。

4.3. Entry Eviction When Dynamic Table Size Changes
4.3. 动态表大小更改时的条目逐出

Whenever the maximum size for the dynamic table is reduced, entries are evicted from the end of the dynamic table until the size of the dynamic table is less than or equal to the maximum size.

每当动态表的最大大小减小时,将从动态表的末尾逐出条目,直到动态表的大小小于或等于最大大小。

4.4. Entry Eviction When Adding New Entries
4.4. 添加新条目时逐出条目

Before a new entry is added to the dynamic table, entries are evicted from the end of the dynamic table until the size of the dynamic table is less than or equal to (maximum size - new entry size) or until the table is empty.

在将新条目添加到动态表之前,将从动态表的末尾逐出条目,直到动态表的大小小于或等于(最大大小-新条目大小)或直到表为空。

If the size of the new entry is less than or equal to the maximum size, that entry is added to the table. It is not an error to attempt to add an entry that is larger than the maximum size; an attempt to add an entry larger than the maximum size causes the table to be emptied of all existing entries and results in an empty table.

如果新条目的大小小于或等于最大值,则该条目将添加到表中。尝试添加大于最大大小的条目不是错误;尝试添加大于最大值的条目会导致表中所有现有条目被清空,并导致空表。

A new entry can reference the name of an entry in the dynamic table that will be evicted when adding this new entry into the dynamic table. Implementations are cautioned to avoid deleting the referenced name if the referenced entry is evicted from the dynamic table prior to inserting the new entry.

新条目可以引用动态表中的条目名称,在将此新条目添加到动态表中时,该条目将被逐出。如果在插入新条目之前将引用的条目从动态表中逐出,则应提醒实现避免删除引用的名称。

5. Primitive Type Representations
5. 基元类型表示法

HPACK encoding uses two primitive types: unsigned variable-length integers and strings of octets.

HPACK编码使用两种基本类型:无符号变长整数和八位字节字符串。

5.1. Integer Representation
5.1. 整数表示

Integers are used to represent name indexes, header field indexes, or string lengths. An integer representation can start anywhere within an octet. To allow for optimized processing, an integer representation always finishes at the end of an octet.

整数用于表示名称索引、标题字段索引或字符串长度。整数表示可以从八位字节内的任何位置开始。为了优化处理,整数表示始终在八位字节的末尾结束。

An integer is represented in two parts: a prefix that fills the current octet and an optional list of octets that are used if the integer value does not fit within the prefix. The number of bits of the prefix (called N) is a parameter of the integer representation.

整数由两部分表示:一部分是填充当前八位字节的前缀,另一部分是可选的八位字节列表,如果整数值不符合前缀,则使用该列表。前缀的位数(称为N)是整数表示的参数。

If the integer value is small enough, i.e., strictly less than 2^N-1, it is encoded within the N-bit prefix.

如果整数值足够小,即严格小于2^N-1,则在N位前缀内对其进行编码。

     0   1   2   3   4   5   6   7
   +---+---+---+---+---+---+---+---+
   | ? | ? | ? |       Value       |
   +---+---+---+-------------------+
        
     0   1   2   3   4   5   6   7
   +---+---+---+---+---+---+---+---+
   | ? | ? | ? |       Value       |
   +---+---+---+-------------------+
        

Figure 2: Integer Value Encoded within the Prefix (Shown for N = 5)

图2:前缀中编码的整数值(显示为N=5)

Otherwise, all the bits of the prefix are set to 1, and the value, decreased by 2^N-1, is encoded using a list of one or more octets. The most significant bit of each octet is used as a continuation flag: its value is set to 1 except for the last octet in the list. The remaining bits of the octets are used to encode the decreased value.

否则,前缀的所有位都设置为1,值减少2^N-1,使用一个或多个八位字节的列表进行编码。每个八位字节的最高有效位用作连续标志:除列表中的最后一个八位字节外,其值设置为1。八位字节的剩余位用于对减少的值进行编码。

     0   1   2   3   4   5   6   7
   +---+---+---+---+---+---+---+---+
   | ? | ? | ? | 1   1   1   1   1 |
   +---+---+---+-------------------+
   | 1 |    Value-(2^N-1) LSB      |
   +---+---------------------------+
                  ...
   +---+---------------------------+
   | 0 |    Value-(2^N-1) MSB      |
   +---+---------------------------+
        
     0   1   2   3   4   5   6   7
   +---+---+---+---+---+---+---+---+
   | ? | ? | ? | 1   1   1   1   1 |
   +---+---+---+-------------------+
   | 1 |    Value-(2^N-1) LSB      |
   +---+---------------------------+
                  ...
   +---+---------------------------+
   | 0 |    Value-(2^N-1) MSB      |
   +---+---------------------------+
        

Figure 3: Integer Value Encoded after the Prefix (Shown for N = 5)

图3:前缀后编码的整数值(显示为N=5)

Decoding the integer value from the list of octets starts by reversing the order of the octets in the list. Then, for each octet, its most significant bit is removed. The remaining bits of the octets are concatenated, and the resulting value is increased by 2^N-1 to obtain the integer value.

解码八位字节列表中的整数值首先要颠倒列表中八位字节的顺序。然后,对于每个八位组,其最高有效位被移除。将八位字节的剩余位串联起来,所得值增加2^N-1以获得整数值。

The prefix size, N, is always between 1 and 8 bits. An integer starting at an octet boundary will have an 8-bit prefix.

前缀大小N始终在1到8位之间。从八位字节边界开始的整数将具有8位前缀。

Pseudocode to represent an integer I is as follows:

表示整数I的伪代码如下所示:

   if I < 2^N - 1, encode I on N bits
   else
       encode (2^N - 1) on N bits
       I = I - (2^N - 1)
       while I >= 128
            encode (I % 128 + 128) on 8 bits
            I = I / 128
       encode I on 8 bits
        
   if I < 2^N - 1, encode I on N bits
   else
       encode (2^N - 1) on N bits
       I = I - (2^N - 1)
       while I >= 128
            encode (I % 128 + 128) on 8 bits
            I = I / 128
       encode I on 8 bits
        

Pseudocode to decode an integer I is as follows:

解码整数I的伪码如下所示:

   decode I from the next N bits
   if I < 2^N - 1, return I
   else
       M = 0
       repeat
           B = next octet
           I = I + (B & 127) * 2^M
           M = M + 7
       while B & 128 == 128
       return I
        
   decode I from the next N bits
   if I < 2^N - 1, return I
   else
       M = 0
       repeat
           B = next octet
           I = I + (B & 127) * 2^M
           M = M + 7
       while B & 128 == 128
       return I
        

Examples illustrating the encoding of integers are available in Appendix C.1.

附录C.1中提供了说明整数编码的示例。

This integer representation allows for values of indefinite size. It is also possible for an encoder to send a large number of zero values, which can waste octets and could be used to overflow integer values. Integer encodings that exceed implementation limits -- in value or octet length -- MUST be treated as decoding errors. Different limits can be set for each of the different uses of integers, based on implementation constraints.

此整数表示允许不确定大小的值。编码器也可能发送大量零值,这可能会浪费八位字节,并可用于溢出整数值。超过实现限制(值或八位字节长度)的整数编码必须视为解码错误。根据实现约束,可以为整数的每个不同用途设置不同的限制。

5.2. String Literal Representation
5.2. 字符串文字表示法

Header field names and header field values can be represented as string literals. A string literal is encoded as a sequence of octets, either by directly encoding the string literal's octets or by using a Huffman code (see [HUFFMAN]).

标题字段名称和标题字段值可以表示为字符串文字。字符串文字被编码为八位字节序列,可以直接编码字符串文字的八位字节,也可以使用哈夫曼代码(参见[Huffman])。

     0   1   2   3   4   5   6   7
   +---+---+---+---+---+---+---+---+
   | H |    String Length (7+)     |
   +---+---------------------------+
   |  String Data (Length octets)  |
   +-------------------------------+
        
     0   1   2   3   4   5   6   7
   +---+---+---+---+---+---+---+---+
   | H |    String Length (7+)     |
   +---+---------------------------+
   |  String Data (Length octets)  |
   +-------------------------------+
        

Figure 4: String Literal Representation

图4:字符串文字表示

A string literal representation contains the following fields:

字符串文字表示法包含以下字段:

H: A one-bit flag, H, indicating whether or not the octets of the string are Huffman encoded.

H:一位标志,H,指示字符串的八位字节是否为哈夫曼编码。

String Length: The number of octets used to encode the string literal, encoded as an integer with a 7-bit prefix (see Section 5.1).

字符串长度:用于编码字符串文字的八位字节数,编码为带有7位前缀的整数(见第5.1节)。

String Data: The encoded data of the string literal. If H is '0', then the encoded data is the raw octets of the string literal. If H is '1', then the encoded data is the Huffman encoding of the string literal.

字符串数据:字符串文字的编码数据。如果H为“0”,则编码数据为字符串文字的原始八位字节。如果H是“1”,则编码数据是字符串文本的哈夫曼编码。

String literals that use Huffman encoding are encoded with the Huffman code defined in Appendix B (see examples for requests in Appendix C.4 and for responses in Appendix C.6). The encoded data is the bitwise concatenation of the codes corresponding to each octet of the string literal.

使用哈夫曼编码的字符串文本使用附录B中定义的哈夫曼编码进行编码(参见附录C.4中的请求示例和附录C.6中的响应示例)。编码数据是对应于字符串文字的每个八位字节的代码的按位串联。

As the Huffman-encoded data doesn't always end at an octet boundary, some padding is inserted after it, up to the next octet boundary. To prevent this padding from being misinterpreted as part of the string literal, the most significant bits of the code corresponding to the EOS (end-of-string) symbol are used.

由于哈夫曼编码的数据并不总是以八位字节边界结束,因此在它之后插入一些填充,直到下一个八位字节边界。为了防止此填充被误解为字符串文字的一部分,将使用与EOS(字符串结束)符号相对应的代码的最高有效位。

Upon decoding, an incomplete code at the end of the encoded data is to be considered as padding and discarded. A padding strictly longer than 7 bits MUST be treated as a decoding error. A padding not corresponding to the most significant bits of the code for the EOS symbol MUST be treated as a decoding error. A Huffman-encoded string literal containing the EOS symbol MUST be treated as a decoding error.

解码时,编码数据末尾的不完整代码将被视为填充并丢弃。严格大于7位的填充必须视为解码错误。与EOS符号的代码最高有效位不对应的填充必须视为解码错误。包含EOS符号的哈夫曼编码字符串文字必须视为解码错误。

6. Binary Format
6. 二进制格式

This section describes the detailed format of each of the different header field representations and the dynamic table size update instruction.

本节介绍每个不同标题字段表示形式和动态表大小更新指令的详细格式。

6.1. Indexed Header Field Representation
6.1. 索引头字段表示法

An indexed header field representation identifies an entry in either the static table or the dynamic table (see Section 2.3).

索引标题字段表示法标识静态表或动态表中的条目(参见第2.3节)。

An indexed header field representation causes a header field to be added to the decoded header list, as described in Section 3.2.

如第3.2节所述,索引标题字段表示会将标题字段添加到解码标题列表中。

     0   1   2   3   4   5   6   7
   +---+---+---+---+---+---+---+---+
   | 1 |        Index (7+)         |
   +---+---------------------------+
        
     0   1   2   3   4   5   6   7
   +---+---+---+---+---+---+---+---+
   | 1 |        Index (7+)         |
   +---+---------------------------+
        

Figure 5: Indexed Header Field

图5:索引头字段

An indexed header field starts with the '1' 1-bit pattern, followed by the index of the matching header field, represented as an integer with a 7-bit prefix (see Section 5.1).

索引标头字段以“1”1位模式开始,然后是匹配标头字段的索引,表示为带有7位前缀的整数(参见第5.1节)。

The index value of 0 is not used. It MUST be treated as a decoding error if found in an indexed header field representation.

未使用索引值0。如果在索引头字段表示中找到,则必须将其视为解码错误。

6.2. Literal Header Field Representation
6.2. 文字标题字段表示法

A literal header field representation contains a literal header field value. Header field names are provided either as a literal or by reference to an existing table entry, either from the static table or the dynamic table (see Section 2.3).

文字标题字段表示包含文字标题字段值。标题字段名以文本形式提供,或通过引用现有表条目提供,无论是静态表还是动态表(参见第2.3节)。

This specification defines three forms of literal header field representations: with indexing, without indexing, and never indexed.

本规范定义了三种形式的文字标题字段表示:有索引、无索引和从不索引。

6.2.1. Literal Header Field with Incremental Indexing
6.2.1. 具有增量索引的文字标题字段

A literal header field with incremental indexing representation results in appending a header field to the decoded header list and inserting it as a new entry into the dynamic table.

具有增量索引表示的文字标题字段会将标题字段追加到解码标题列表中,并将其作为新条目插入动态表中。

     0   1   2   3   4   5   6   7
   +---+---+---+---+---+---+---+---+
   | 0 | 1 |      Index (6+)       |
   +---+---+-----------------------+
   | H |     Value Length (7+)     |
   +---+---------------------------+
   | Value String (Length octets)  |
   +-------------------------------+
        
     0   1   2   3   4   5   6   7
   +---+---+---+---+---+---+---+---+
   | 0 | 1 |      Index (6+)       |
   +---+---+-----------------------+
   | H |     Value Length (7+)     |
   +---+---------------------------+
   | Value String (Length octets)  |
   +-------------------------------+
        

Figure 6: Literal Header Field with Incremental Indexing -- Indexed Name

图6:具有增量索引的文本标题字段——索引名称

     0   1   2   3   4   5   6   7
   +---+---+---+---+---+---+---+---+
   | 0 | 1 |           0           |
   +---+---+-----------------------+
   | H |     Name Length (7+)      |
   +---+---------------------------+
   |  Name String (Length octets)  |
   +---+---------------------------+
   | H |     Value Length (7+)     |
   +---+---------------------------+
   | Value String (Length octets)  |
   +-------------------------------+
        
     0   1   2   3   4   5   6   7
   +---+---+---+---+---+---+---+---+
   | 0 | 1 |           0           |
   +---+---+-----------------------+
   | H |     Name Length (7+)      |
   +---+---------------------------+
   |  Name String (Length octets)  |
   +---+---------------------------+
   | H |     Value Length (7+)     |
   +---+---------------------------+
   | Value String (Length octets)  |
   +-------------------------------+
        

Figure 7: Literal Header Field with Incremental Indexing -- New Name

图7:具有增量索引的文本标题字段——新名称

A literal header field with incremental indexing representation starts with the '01' 2-bit pattern.

具有增量索引表示的文字标题字段以“01”2位模式开头。

If the header field name matches the header field name of an entry stored in the static table or the dynamic table, the header field name can be represented using the index of that entry. In this case, the index of the entry is represented as an integer with a 6-bit prefix (see Section 5.1). This value is always non-zero.

如果标题字段名与存储在静态表或动态表中的条目的标题字段名匹配,则可以使用该条目的索引表示标题字段名。在这种情况下,条目的索引表示为带有6位前缀的整数(参见第5.1节)。此值始终为非零。

Otherwise, the header field name is represented as a string literal (see Section 5.2). A value 0 is used in place of the 6-bit index, followed by the header field name.

否则,标题字段名将表示为字符串文字(参见第5.2节)。使用值0代替6位索引,后跟标题字段名。

Either form of header field name representation is followed by the header field value represented as a string literal (see Section 5.2).

任何一种形式的标题字段名称表示后面都跟有以字符串文字表示的标题字段值(参见第5.2节)。

6.2.2. Literal Header Field without Indexing
6.2.2. 不带索引的文本标题字段

A literal header field without indexing representation results in appending a header field to the decoded header list without altering the dynamic table.

没有索引表示的文本头字段会导致在解码头列表中附加头字段,而不会更改动态表。

     0   1   2   3   4   5   6   7
   +---+---+---+---+---+---+---+---+
   | 0 | 0 | 0 | 0 |  Index (4+)   |
   +---+---+-----------------------+
   | H |     Value Length (7+)     |
   +---+---------------------------+
   | Value String (Length octets)  |
   +-------------------------------+
        
     0   1   2   3   4   5   6   7
   +---+---+---+---+---+---+---+---+
   | 0 | 0 | 0 | 0 |  Index (4+)   |
   +---+---+-----------------------+
   | H |     Value Length (7+)     |
   +---+---------------------------+
   | Value String (Length octets)  |
   +-------------------------------+
        

Figure 8: Literal Header Field without Indexing -- Indexed Name

图8:不带索引的文本标题字段——索引名称

     0   1   2   3   4   5   6   7
   +---+---+---+---+---+---+---+---+
   | 0 | 0 | 0 | 0 |       0       |
   +---+---+-----------------------+
   | H |     Name Length (7+)      |
   +---+---------------------------+
   |  Name String (Length octets)  |
   +---+---------------------------+
   | H |     Value Length (7+)     |
   +---+---------------------------+
   | Value String (Length octets)  |
   +-------------------------------+
        
     0   1   2   3   4   5   6   7
   +---+---+---+---+---+---+---+---+
   | 0 | 0 | 0 | 0 |       0       |
   +---+---+-----------------------+
   | H |     Name Length (7+)      |
   +---+---------------------------+
   |  Name String (Length octets)  |
   +---+---------------------------+
   | H |     Value Length (7+)     |
   +---+---------------------------+
   | Value String (Length octets)  |
   +-------------------------------+
        

Figure 9: Literal Header Field without Indexing -- New Name

图9:无索引的文本标题字段——新名称

A literal header field without indexing representation starts with the '0000' 4-bit pattern.

不带索引表示的文字标题字段以“0000”4位模式开头。

If the header field name matches the header field name of an entry stored in the static table or the dynamic table, the header field name can be represented using the index of that entry. In this case, the index of the entry is represented as an integer with a 4-bit prefix (see Section 5.1). This value is always non-zero.

如果标题字段名与存储在静态表或动态表中的条目的标题字段名匹配,则可以使用该条目的索引表示标题字段名。在这种情况下,条目的索引表示为带有4位前缀的整数(参见第5.1节)。此值始终为非零。

Otherwise, the header field name is represented as a string literal (see Section 5.2). A value 0 is used in place of the 4-bit index, followed by the header field name.

否则,标题字段名将表示为字符串文字(参见第5.2节)。使用值0代替4位索引,后跟标题字段名。

Either form of header field name representation is followed by the header field value represented as a string literal (see Section 5.2).

任何一种形式的标题字段名称表示后面都跟有以字符串文字表示的标题字段值(参见第5.2节)。

6.2.3. Literal Header Field Never Indexed
6.2.3. 文字标题字段从未索引

A literal header field never-indexed representation results in appending a header field to the decoded header list without altering the dynamic table. Intermediaries MUST use the same representation for encoding this header field.

文本头字段从不索引表示将导致在不更改动态表的情况下将头字段追加到解码头列表。中介体必须使用相同的表示形式来编码此标头字段。

     0   1   2   3   4   5   6   7
   +---+---+---+---+---+---+---+---+
   | 0 | 0 | 0 | 1 |  Index (4+)   |
   +---+---+-----------------------+
   | H |     Value Length (7+)     |
   +---+---------------------------+
   | Value String (Length octets)  |
   +-------------------------------+
        
     0   1   2   3   4   5   6   7
   +---+---+---+---+---+---+---+---+
   | 0 | 0 | 0 | 1 |  Index (4+)   |
   +---+---+-----------------------+
   | H |     Value Length (7+)     |
   +---+---------------------------+
   | Value String (Length octets)  |
   +-------------------------------+
        

Figure 10: Literal Header Field Never Indexed -- Indexed Name

图10:从未索引的文本头字段——索引名称

     0   1   2   3   4   5   6   7
   +---+---+---+---+---+---+---+---+
   | 0 | 0 | 0 | 1 |       0       |
   +---+---+-----------------------+
   | H |     Name Length (7+)      |
   +---+---------------------------+
   |  Name String (Length octets)  |
   +---+---------------------------+
   | H |     Value Length (7+)     |
   +---+---------------------------+
   | Value String (Length octets)  |
   +-------------------------------+
        
     0   1   2   3   4   5   6   7
   +---+---+---+---+---+---+---+---+
   | 0 | 0 | 0 | 1 |       0       |
   +---+---+-----------------------+
   | H |     Name Length (7+)      |
   +---+---------------------------+
   |  Name String (Length octets)  |
   +---+---------------------------+
   | H |     Value Length (7+)     |
   +---+---------------------------+
   | Value String (Length octets)  |
   +-------------------------------+
        

Figure 11: Literal Header Field Never Indexed -- New Name

图11:从未索引的文本头字段——新名称

A literal header field never-indexed representation starts with the '0001' 4-bit pattern.

文字标题字段从不索引表示形式以“0001”4位模式开头。

When a header field is represented as a literal header field never indexed, it MUST always be encoded with this specific literal representation. In particular, when a peer sends a header field that it received represented as a literal header field never indexed, it MUST use the same representation to forward this header field.

当标头字段表示为从未索引的文本标头字段时,必须始终使用此特定的文本表示对其进行编码。特别是,当对等方发送其接收的报头字段时,该字段表示为从未索引的文本报头字段,它必须使用相同的表示来转发该报头字段。

This representation is intended for protecting header field values that are not to be put at risk by compressing them (see Section 7.1 for more details).

此表示法旨在保护不会因压缩而面临风险的标题字段值(有关更多详细信息,请参阅第7.1节)。

The encoding of the representation is identical to the literal header field without indexing (see Section 6.2.2).

表示的编码与无索引的文字标题字段相同(见第6.2.2节)。

6.3. Dynamic Table Size Update
6.3. 动态表大小更新

A dynamic table size update signals a change to the size of the dynamic table.

动态表大小更新表示动态表大小的更改。

     0   1   2   3   4   5   6   7
   +---+---+---+---+---+---+---+---+
   | 0 | 0 | 1 |   Max size (5+)   |
   +---+---------------------------+
        
     0   1   2   3   4   5   6   7
   +---+---+---+---+---+---+---+---+
   | 0 | 0 | 1 |   Max size (5+)   |
   +---+---------------------------+
        

Figure 12: Maximum Dynamic Table Size Change

图12:最大动态表大小更改

A dynamic table size update starts with the '001' 3-bit pattern, followed by the new maximum size, represented as an integer with a 5-bit prefix (see Section 5.1).

动态表大小更新以“001”3位模式开始,然后是新的最大大小,表示为带5位前缀的整数(参见第5.1节)。

The new maximum size MUST be lower than or equal to the limit determined by the protocol using HPACK. A value that exceeds this limit MUST be treated as a decoding error. In HTTP/2, this limit is the last value of the SETTINGS_HEADER_TABLE_SIZE parameter (see Section 6.5.2 of [HTTP2]) received from the decoder and acknowledged by the encoder (see Section 6.5.3 of [HTTP2]).

新的最大大小必须小于或等于使用HPACK的协议确定的限制。超过此限制的值必须视为解码错误。在HTTP/2中,该限制是从解码器接收并由编码器确认的设置\头\表\大小参数(见[HTTP2]第6.5.2节)的最后一个值(见[HTTP2]第6.5.3节)。

Reducing the maximum size of the dynamic table can cause entries to be evicted (see Section 4.3).

减小动态表的最大大小可能会导致逐出条目(参见第4.3节)。

7. Security Considerations
7. 安全考虑

This section describes potential areas of security concern with HPACK:

本节介绍HPACK可能存在的安全问题:

o Use of compression as a length-based oracle for verifying guesses about secrets that are compressed into a shared compression context.

o 将压缩用作基于长度的oracle,用于验证对压缩到共享压缩上下文中的机密的猜测。

o Denial of service resulting from exhausting processing or memory capacity at a decoder.

o 由于解码器耗尽处理或内存容量而导致的拒绝服务。

7.1. Probing Dynamic Table State
7.1. 探测动态表状态

HPACK reduces the length of header field encodings by exploiting the redundancy inherent in protocols like HTTP. The ultimate goal of this is to reduce the amount of data that is required to send HTTP requests or responses.

HPACK利用HTTP等协议固有的冗余,减少了报头字段编码的长度。其最终目标是减少发送HTTP请求或响应所需的数据量。

The compression context used to encode header fields can be probed by an attacker who can both define header fields to be encoded and transmitted and observe the length of those fields once they are encoded. When an attacker can do both, they can adaptively modify requests in order to confirm guesses about the dynamic table state. If a guess is compressed into a shorter length, the attacker can observe the encoded length and infer that the guess was correct.

攻击者可以探测用于编码报头字段的压缩上下文,攻击者可以定义要编码和传输的报头字段,并在编码后观察这些字段的长度。当攻击者可以同时执行这两项操作时,他们可以自适应地修改请求,以确认对动态表状态的猜测。如果猜测被压缩为较短的长度,攻击者可以观察编码的长度并推断猜测是正确的。

This is possible even over the Transport Layer Security (TLS) protocol (see [TLS12]), because while TLS provides confidentiality protection for content, it only provides a limited amount of protection for the length of that content.

即使通过传输层安全(TLS)协议(参见[TLS12]),这也是可能的,因为虽然TLS为内容提供保密保护,但它仅为该内容的长度提供有限的保护。

Note: Padding schemes only provide limited protection against an attacker with these capabilities, potentially only forcing an increased number of guesses to learn the length associated with a given guess. Padding schemes also work directly against compression by increasing the number of bits that are transmitted.

注意:填充方案仅为具有这些功能的攻击者提供有限的保护,可能只会增加猜测次数以了解与给定猜测相关的长度。填充方案还通过增加传输的比特数直接对抗压缩。

Attacks like CRIME [CRIME] demonstrated the existence of these general attacker capabilities. The specific attack exploited the fact that DEFLATE [DEFLATE] removes redundancy based on prefix matching. This permitted the attacker to confirm guesses a character at a time, reducing an exponential-time attack into a linear-time attack.

类似犯罪的攻击[犯罪]证明了这些一般攻击者能力的存在。特定攻击利用了DEFLATE[DEFLATE]基于前缀匹配删除冗余这一事实。这允许攻击者一次确认猜测一个角色,从而将指数时间攻击减少为线性时间攻击。

7.1.1. Applicability to HPACK and HTTP
7.1.1. 对HPACK和HTTP的适用性

HPACK mitigates but does not completely prevent attacks modeled on CRIME [CRIME] by forcing a guess to match an entire header field value rather than individual characters. Attackers can only learn whether a guess is correct or not, so they are reduced to brute-force guesses for the header field values.

HPACK通过强制猜测匹配整个标题字段值而不是单个字符来减轻但不能完全防止模仿犯罪[犯罪]的攻击。攻击者只能了解猜测是否正确,因此他们只能对标题字段值进行暴力猜测。

The viability of recovering specific header field values therefore depends on the entropy of values. As a result, values with high entropy are unlikely to be recovered successfully. However, values with low entropy remain vulnerable.

因此,恢复特定报头字段值的可行性取决于值的熵。因此,高熵值不太可能成功恢复。然而,低熵值仍然很脆弱。

Attacks of this nature are possible any time that two mutually distrustful entities control requests or responses that are placed onto a single HTTP/2 connection. If the shared HPACK compressor permits one entity to add entries to the dynamic table and the other to access those entries, then the state of the table can be learned.

当两个相互不信任的实体控制放置在单个HTTP/2连接上的请求或响应时,这种性质的攻击随时可能发生。如果共享HPACK压缩器允许一个实体向动态表添加条目,另一个实体访问这些条目,则可以了解表的状态。

Having requests or responses from mutually distrustful entities occurs when an intermediary either:

当中介机构出现以下情况之一时,就会出现来自相互不信任的实体的请求或响应:

o sends requests from multiple clients on a single connection toward an origin server, or

o 在单个连接上向源服务器发送来自多个客户端的请求,或

o takes responses from multiple origin servers and places them on a shared connection toward a client.

o 从多个源服务器获取响应,并将它们放置在指向客户端的共享连接上。

Web browsers also need to assume that requests made on the same connection by different web origins [ORIGIN] are made by mutually distrustful entities.

Web浏览器还需要假设不同Web源在同一连接上发出的请求是由相互不信任的实体发出的。

7.1.2. Mitigation
7.1.2. 缓解

Users of HTTP that require confidentiality for header fields can use values with entropy sufficient to make guessing infeasible. However, this is impractical as a general solution because it forces all users of HTTP to take steps to mitigate attacks. It would impose new constraints on how HTTP is used.

需要对头字段保密的HTTP用户可以使用熵足以使猜测不可行的值。然而,作为一个通用解决方案,这是不切实际的,因为它迫使HTTP的所有用户采取措施来减轻攻击。它将对如何使用HTTP施加新的限制。

Rather than impose constraints on users of HTTP, an implementation of HPACK can instead constrain how compression is applied in order to limit the potential for dynamic table probing.

HPACK的实现可以约束压缩的应用方式,从而限制动态表探测的可能性,而不是对HTTP用户施加约束。

An ideal solution segregates access to the dynamic table based on the entity that is constructing header fields. Header field values that are added to the table are attributed to an entity, and only the entity that created a particular value can extract that value.

理想的解决方案是基于构造头字段的实体隔离对动态表的访问。添加到表中的标题字段值属于实体,只有创建特定值的实体才能提取该值。

To improve compression performance of this option, certain entries might be tagged as being public. For example, a web browser might make the values of the Accept-Encoding header field available in all requests.

为了提高此选项的压缩性能,某些条目可能被标记为公共。例如,web浏览器可能使Accept Encoding标头字段的值在所有请求中都可用。

An encoder without good knowledge of the provenance of header fields might instead introduce a penalty for a header field with many different values, such that a large number of attempts to guess a header field value results in the header field no longer being compared to the dynamic table entries in future messages, effectively preventing further guesses.

如果编码器不了解头字段的来源,则可能会对具有许多不同值的头字段引入惩罚,从而大量尝试猜测头字段值会导致头字段不再与未来消息中的动态表条目进行比较,有效防止进一步猜测。

Note: Simply removing entries corresponding to the header field from the dynamic table can be ineffectual if the attacker has a reliable way of causing values to be reinstalled. For example, a request to load an image in a web browser typically includes the Cookie header field (a potentially highly valued target for this sort of attack), and web sites can easily force an image to be loaded, thereby refreshing the entry in the dynamic table.

注意:如果攻击者有可靠的方法导致重新安装值,则仅从动态表中删除与标题字段对应的条目可能无效。例如,在web浏览器中加载图像的请求通常包括Cookie标头字段(这类攻击的潜在高价值目标),web站点可以轻松强制加载图像,从而刷新动态表中的条目。

This response might be made inversely proportional to the length of the header field value. Marking a header field as not using the dynamic table anymore might occur for shorter values more quickly or with higher probability than for longer values.

此响应可能与标头字段值的长度成反比。将标题字段标记为不再使用动态表可能会在较短的值中比在较长的值中更快或更高的概率出现。

7.1.3. Never-Indexed Literals
7.1.3. 从不索引文本

Implementations can also choose to protect sensitive header fields by not compressing them and instead encoding their value as literals.

实现还可以选择不压缩敏感头字段,而是将其值编码为文字来保护敏感头字段。

Refusing to generate an indexed representation for a header field is only effective if compression is avoided on all hops. The never-indexed literal (see Section 6.2.3) can be used to signal to intermediaries that a particular value was intentionally sent as a literal.

拒绝为头字段生成索引表示只有在所有跃点上避免压缩时才有效。从不带索引的文本(见第6.2.3节)可用于向中介机构发出信号,表明特定值是故意作为文本发送的。

An intermediary MUST NOT re-encode a value that uses the never-indexed literal representation with another representation that would index it. If HPACK is used for re-encoding, the never-indexed literal representation MUST be used.

中介体不得将使用从未索引的文字表示的值与另一个将对其进行索引的表示重新编码。如果HPACK用于重新编码,则必须使用从不索引的文字表示。

The choice to use a never-indexed literal representation for a header field depends on several factors. Since HPACK doesn't protect against guessing an entire header field value, short or low-entropy values are more readily recovered by an adversary. Therefore, an encoder might choose not to index values with low entropy.

对标题字段使用从不索引的文字表示取决于几个因素。由于HPACK无法防止猜测整个报头字段值,因此短熵或低熵值更容易被对手恢复。因此,编码器可能选择不索引低熵的值。

An encoder might also choose not to index values for header fields that are considered to be highly valuable or sensitive to recovery, such as the Cookie or Authorization header fields.

编码器还可以选择不为被认为对恢复非常有价值或敏感的头字段(如Cookie或授权头字段)的值编制索引。

On the contrary, an encoder might prefer indexing values for header fields that have little or no value if they were exposed. For instance, a User-Agent header field does not commonly vary between requests and is sent to any server. In that case, confirmation that a particular User-Agent value has been used provides little value.

相反,编码器可能更喜欢为头字段编制索引值,这些头字段在公开时几乎没有值或没有值。例如,用户代理头字段通常不会因请求而异,而是发送到任何服务器。在这种情况下,确认某个特定的用户代理值已被使用几乎没有价值。

Note that these criteria for deciding to use a never-indexed literal representation will evolve over time as new attacks are discovered.

请注意,随着新攻击的发现,这些决定使用从不索引的文字表示的标准将随着时间的推移而变化。

7.2. Static Huffman Encoding
7.2. 静态哈夫曼编码

There is no currently known attack against a static Huffman encoding. A study has shown that using a static Huffman encoding table created an information leakage; however, this same study concluded that an attacker could not take advantage of this information leakage to recover any meaningful amount of information (see [PETAL]).

目前还没有已知的针对静态哈夫曼编码的攻击。一项研究表明,使用静态哈夫曼编码表造成了信息泄漏;然而,这项研究得出的结论是,攻击者无法利用这种信息泄漏来恢复任何有意义的信息量(请参见[PETAL])。

7.3. Memory Consumption
7.3. 内存消耗

An attacker can try to cause an endpoint to exhaust its memory. HPACK is designed to limit both the peak and state amounts of memory allocated by an endpoint.

攻击者可以尝试导致端点耗尽其内存。HPACK设计用于限制端点分配的峰值和状态内存量。

The amount of memory used by the compressor is limited by the protocol using HPACK through the definition of the maximum size of the dynamic table. In HTTP/2, this value is controlled by the decoder through the setting parameter SETTINGS_HEADER_TABLE_SIZE (see Section 6.5.2 of [HTTP2]). This limit takes into account both the size of the data stored in the dynamic table, plus a small allowance for overhead.

通过定义动态表的最大大小,使用HPACK的协议限制压缩器使用的内存量。在HTTP/2中,该值由解码器通过设置参数SETTINGS_HEADER_TABLE_SIZE(参见[HTTP2]第6.5.2节)来控制。这个限制既考虑了动态表中存储的数据的大小,又考虑了少量开销。

A decoder can limit the amount of state memory used by setting an appropriate value for the maximum size of the dynamic table. In HTTP/2, this is realized by setting an appropriate value for the SETTINGS_HEADER_TABLE_SIZE parameter. An encoder can limit the amount of state memory it uses by signaling a lower dynamic table size than the decoder allows (see Section 6.3).

解码器可以通过为动态表的最大大小设置适当的值来限制状态内存的使用量。在HTTP/2中,这是通过为SETTINGS\u HEADER\u TABLE\u SIZE参数设置适当的值来实现的。编码器可以通过发送低于解码器允许的动态表大小的信号来限制其使用的状态内存量(参见第6.3节)。

The amount of temporary memory consumed by an encoder or decoder can be limited by processing header fields sequentially. An implementation does not need to retain a complete list of header fields. Note, however, that it might be necessary for an application to retain a complete header list for other reasons; even though HPACK does not force this to occur, application constraints might make this necessary.

编码器或解码器消耗的临时内存量可以通过顺序处理报头字段来限制。实现不需要保留标题字段的完整列表。但是,请注意,应用程序可能出于其他原因需要保留完整的标题列表;即使HPACK不会强制执行此操作,但应用程序约束可能会使此操作成为必要。

7.4. Implementation Limits
7.4. 实施限制

An implementation of HPACK needs to ensure that large values for integers, long encoding for integers, or long string literals do not create security weaknesses.

HPACK的实现需要确保整数的大值、整数的长编码或长字符串文字不会造成安全缺陷。

An implementation has to set a limit for the values it accepts for integers, as well as for the encoded length (see Section 5.1). In the same way, it has to set a limit to the length it accepts for string literals (see Section 5.2).

实现必须为其接受的整数值以及编码长度设置限制(参见第5.1节)。同样,它必须对接受的字符串文本长度设置限制(参见第5.2节)。

8. References
8. 工具书类
8.1. Normative References
8.1. 规范性引用文件

[HTTP2] Belshe, M., Peon, R., and M. Thomson, Ed., "Hypertext Transfer Protocol Version 2 (HTTP/2)", RFC 7540, DOI 10.17487/RFC7540, May 2015, <http://www.rfc-editor.org/info/rfc7540>.

[HTTP2]Belshe,M.,Paon,R.,和M.Thomson,编辑,“超文本传输协议版本2(HTTP/2)”,RFC 7540,DOI 10.17487/RFC7540,2015年5月<http://www.rfc-editor.org/info/rfc7540>.

[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997, <http://www.rfc-editor.org/info/rfc2119>.

[RFC2119]Bradner,S.,“RFC中用于表示需求水平的关键词”,BCP 14,RFC 2119,DOI 10.17487/RFC2119,1997年3月<http://www.rfc-editor.org/info/rfc2119>.

[RFC7230] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing", RFC 7230, DOI 10.17487/RFC7230, June 2014, <http://www.rfc-editor.org/info/rfc7230>.

[RFC7230]Fielding,R.,Ed.和J.Reschke,Ed.,“超文本传输协议(HTTP/1.1):消息语法和路由”,RFC 7230,DOI 10.17487/RFC7230,2014年6月<http://www.rfc-editor.org/info/rfc7230>.

8.2. Informative References
8.2. 资料性引用

[CANONICAL] Schwartz, E. and B. Kallick, "Generating a canonical prefix encoding", Communications of the ACM, Volume 7 Issue 3, pp. 166-169, March 1964, <https://dl.acm.org/ citation.cfm?id=363991>.

[CANONICAL]Schwartz,E.和B.Kallick,“生成规范前缀编码”,《ACM通讯》,第7卷第3期,第166-169页,1964年3月<https://dl.acm.org/ 引文.cfm?id=363991>。

[CRIME] Wikipedia, "CRIME", May 2015, <http://en.wikipedia.org/w/ index.php?title=CRIME&oldid=660948120>.

[犯罪]维基百科,“犯罪”,2015年5月<http://en.wikipedia.org/w/ index.php?title=CRIME&oldid=660948120>。

[DEFLATE] Deutsch, P., "DEFLATE Compressed Data Format Specification version 1.3", RFC 1951, DOI 10.17487/RFC1951, May 1996, <http://www.rfc-editor.org/info/rfc1951>.

[DEFLATE]Deutsch,P.,“DEFLATE压缩数据格式规范1.3版”,RFC 1951,DOI 10.17487/RFC1951,1996年5月<http://www.rfc-editor.org/info/rfc1951>.

[HUFFMAN] Huffman, D., "A Method for the Construction of Minimum-Redundancy Codes", Proceedings of the Institute of Radio Engineers, Volume 40, Number 9, pp. 1098-1101, September 1952, <http://ieeexplore.ieee.org/xpl/ articleDetails.jsp?arnumber=4051119>.

[HUFFMAN]HUFFMAN,D.,“构造最小冗余码的方法”,《无线电工程师学会学报》,第40卷,第9期,第1098-1101页,1952年9月<http://ieeexplore.ieee.org/xpl/ articleDetails.jsp?arnumber=4051119>。

[ORIGIN] Barth, A., "The Web Origin Concept", RFC 6454, DOI 10.17487/RFC6454, December 2011, <http://www.rfc-editor.org/info/rfc6454>.

[来源]Barth,A.,“网络来源概念”,RFC 6454,DOI 10.17487/RFC6454,2011年12月<http://www.rfc-editor.org/info/rfc6454>.

[PETAL] Tan, J. and J. Nahata, "PETAL: Preset Encoding Table Information Leakage", April 2013, <http://www.pdl.cmu.edu/PDL-FTP/associated/ CMU-PDL-13-106.pdf>.

[PETAL]Tan,J.和J.Nahata,“PETAL:预设编码表信息泄漏”,2013年4月<http://www.pdl.cmu.edu/PDL-FTP/associated/ CMU-PDL-13-106.pdf>。

[SPDY] Belshe, M. and R. Peon, "SPDY Protocol", Work in Progress, draft-mbelshe-httpbis-spdy-00, February 2012.

[SPDY]Belshe,M.和R.Paun,“SPDY协议”,正在进行的工作,草案-mbelshe-httpbis-SPDY-00,2012年2月。

[TLS12] Dierks, T. and E. Rescorla, "The Transport Layer Security (TLS) Protocol Version 1.2", RFC 5246, DOI 10.17487/RFC5246, August 2008, <http://www.rfc-editor.org/info/rfc5246>.

[TLS12]Dierks,T.和E.Rescorla,“传输层安全(TLS)协议版本1.2”,RFC 5246,DOI 10.17487/RFC5246,2008年8月<http://www.rfc-editor.org/info/rfc5246>.

Appendix A. Static Table Definition
附录A.静态表定义

The static table (see Section 2.3.1) consists in a predefined and unchangeable list of header fields.

静态表(见第2.3.1节)包含预定义且不可更改的标题字段列表。

The static table was created from the most frequent header fields used by popular web sites, with the addition of HTTP/2-specific pseudo-header fields (see Section 8.1.2.1 of [HTTP2]). For header fields with a few frequent values, an entry was added for each of these frequent values. For other header fields, an entry was added with an empty value.

静态表是从流行网站使用的最频繁的头字段创建的,添加了HTTP/2特定的伪头字段(参见[HTTP2]第8.1.2.1节)。对于具有几个频繁值的标题字段,为每个频繁值添加了一个条目。对于其他标题字段,添加了一个带有空值的条目。

Table 1 lists the predefined header fields that make up the static table and gives the index of each entry.

表1列出了构成静态表的预定义标题字段,并给出了每个条目的索引。

          +-------+-----------------------------+---------------+
          | Index | Header Name                 | Header Value  |
          +-------+-----------------------------+---------------+
          | 1     | :authority                  |               |
          | 2     | :method                     | GET           |
          | 3     | :method                     | POST          |
          | 4     | :path                       | /             |
          | 5     | :path                       | /index.html   |
          | 6     | :scheme                     | http          |
          | 7     | :scheme                     | https         |
          | 8     | :status                     | 200           |
          | 9     | :status                     | 204           |
          | 10    | :status                     | 206           |
          | 11    | :status                     | 304           |
          | 12    | :status                     | 400           |
          | 13    | :status                     | 404           |
          | 14    | :status                     | 500           |
          | 15    | accept-charset              |               |
          | 16    | accept-encoding             | gzip, deflate |
          | 17    | accept-language             |               |
          | 18    | accept-ranges               |               |
          | 19    | accept                      |               |
          | 20    | access-control-allow-origin |               |
          | 21    | age                         |               |
          | 22    | allow                       |               |
          | 23    | authorization               |               |
          | 24    | cache-control               |               |
          | 25    | content-disposition         |               |
          | 26    | content-encoding            |               |
          | 27    | content-language            |               |
          | 28    | content-length              |               |
          | 29    | content-location            |               |
          | 30    | content-range               |               |
        
          +-------+-----------------------------+---------------+
          | Index | Header Name                 | Header Value  |
          +-------+-----------------------------+---------------+
          | 1     | :authority                  |               |
          | 2     | :method                     | GET           |
          | 3     | :method                     | POST          |
          | 4     | :path                       | /             |
          | 5     | :path                       | /index.html   |
          | 6     | :scheme                     | http          |
          | 7     | :scheme                     | https         |
          | 8     | :status                     | 200           |
          | 9     | :status                     | 204           |
          | 10    | :status                     | 206           |
          | 11    | :status                     | 304           |
          | 12    | :status                     | 400           |
          | 13    | :status                     | 404           |
          | 14    | :status                     | 500           |
          | 15    | accept-charset              |               |
          | 16    | accept-encoding             | gzip, deflate |
          | 17    | accept-language             |               |
          | 18    | accept-ranges               |               |
          | 19    | accept                      |               |
          | 20    | access-control-allow-origin |               |
          | 21    | age                         |               |
          | 22    | allow                       |               |
          | 23    | authorization               |               |
          | 24    | cache-control               |               |
          | 25    | content-disposition         |               |
          | 26    | content-encoding            |               |
          | 27    | content-language            |               |
          | 28    | content-length              |               |
          | 29    | content-location            |               |
          | 30    | content-range               |               |
        
          | 31    | content-type                |               |
          | 32    | cookie                      |               |
          | 33    | date                        |               |
          | 34    | etag                        |               |
          | 35    | expect                      |               |
          | 36    | expires                     |               |
          | 37    | from                        |               |
          | 38    | host                        |               |
          | 39    | if-match                    |               |
          | 40    | if-modified-since           |               |
          | 41    | if-none-match               |               |
          | 42    | if-range                    |               |
          | 43    | if-unmodified-since         |               |
          | 44    | last-modified               |               |
          | 45    | link                        |               |
          | 46    | location                    |               |
          | 47    | max-forwards                |               |
          | 48    | proxy-authenticate          |               |
          | 49    | proxy-authorization         |               |
          | 50    | range                       |               |
          | 51    | referer                     |               |
          | 52    | refresh                     |               |
          | 53    | retry-after                 |               |
          | 54    | server                      |               |
          | 55    | set-cookie                  |               |
          | 56    | strict-transport-security   |               |
          | 57    | transfer-encoding           |               |
          | 58    | user-agent                  |               |
          | 59    | vary                        |               |
          | 60    | via                         |               |
          | 61    | www-authenticate            |               |
          +-------+-----------------------------+---------------+
        
          | 31    | content-type                |               |
          | 32    | cookie                      |               |
          | 33    | date                        |               |
          | 34    | etag                        |               |
          | 35    | expect                      |               |
          | 36    | expires                     |               |
          | 37    | from                        |               |
          | 38    | host                        |               |
          | 39    | if-match                    |               |
          | 40    | if-modified-since           |               |
          | 41    | if-none-match               |               |
          | 42    | if-range                    |               |
          | 43    | if-unmodified-since         |               |
          | 44    | last-modified               |               |
          | 45    | link                        |               |
          | 46    | location                    |               |
          | 47    | max-forwards                |               |
          | 48    | proxy-authenticate          |               |
          | 49    | proxy-authorization         |               |
          | 50    | range                       |               |
          | 51    | referer                     |               |
          | 52    | refresh                     |               |
          | 53    | retry-after                 |               |
          | 54    | server                      |               |
          | 55    | set-cookie                  |               |
          | 56    | strict-transport-security   |               |
          | 57    | transfer-encoding           |               |
          | 58    | user-agent                  |               |
          | 59    | vary                        |               |
          | 60    | via                         |               |
          | 61    | www-authenticate            |               |
          +-------+-----------------------------+---------------+
        

Table 1: Static Table Entries

表1:静态表条目

Appendix B. Huffman Code
附录B.哈夫曼准则

The following Huffman code is used when encoding string literals with a Huffman coding (see Section 5.2).

当使用哈夫曼编码对字符串文字进行编码时,使用以下哈夫曼编码(参见第5.2节)。

This Huffman code was generated from statistics obtained on a large sample of HTTP headers. It is a canonical Huffman code (see [CANONICAL]) with some tweaking to ensure that no symbol has a unique code length.

这个哈夫曼代码是从大量HTTP头样本中获得的统计数据生成的。这是一个规范的哈夫曼代码(请参见[canonical]),并进行了一些调整,以确保没有符号具有唯一的代码长度。

Each row in the table defines the code used to represent a symbol:

表中的每一行定义了用于表示符号的代码:

sym: The symbol to be represented. It is the decimal value of an octet, possibly prepended with its ASCII representation. A specific symbol, "EOS", is used to indicate the end of a string literal.

sym:要表示的符号。它是八位字节的十进制值,可能在其ASCII表示形式之前。特定符号“EOS”用于指示字符串文字的结尾。

code as bits: The Huffman code for the symbol represented as a base-2 integer, aligned on the most significant bit (MSB).

按位编码:符号的哈夫曼代码,表示为基数为2的整数,与最高有效位(MSB)对齐。

code as hex: The Huffman code for the symbol, represented as a hexadecimal integer, aligned on the least significant bit (LSB).

十六进制代码:符号的哈夫曼代码,表示为十六进制整数,在最低有效位(LSB)上对齐。

len: The number of bits for the code representing the symbol.

len:表示符号的代码的位数。

As an example, the code for the symbol 47 (corresponding to the ASCII character "/") consists in the 6 bits "0", "1", "1", "0", "0", "0". This corresponds to the value 0x18 (in hexadecimal) encoded in 6 bits.

例如,符号47(对应于ASCII字符“/)的代码由6位“0”、“1”、“1”、“0”、“0”、“0”组成。这对应于以6位编码的值0x18(十六进制)。

                                                        code
                          code as bits                 as hex   len
        sym              aligned to MSB                aligned   in
                                                       to LSB   bits
       (  0)  |11111111|11000                             1ff8  [13]
       (  1)  |11111111|11111111|1011000                7fffd8  [23]
       (  2)  |11111111|11111111|11111110|0010         fffffe2  [28]
       (  3)  |11111111|11111111|11111110|0011         fffffe3  [28]
       (  4)  |11111111|11111111|11111110|0100         fffffe4  [28]
       (  5)  |11111111|11111111|11111110|0101         fffffe5  [28]
       (  6)  |11111111|11111111|11111110|0110         fffffe6  [28]
       (  7)  |11111111|11111111|11111110|0111         fffffe7  [28]
       (  8)  |11111111|11111111|11111110|1000         fffffe8  [28]
       (  9)  |11111111|11111111|11101010               ffffea  [24]
       ( 10)  |11111111|11111111|11111111|111100      3ffffffc  [30]
       ( 11)  |11111111|11111111|11111110|1001         fffffe9  [28]
       ( 12)  |11111111|11111111|11111110|1010         fffffea  [28]
       ( 13)  |11111111|11111111|11111111|111101      3ffffffd  [30]
        
                                                        code
                          code as bits                 as hex   len
        sym              aligned to MSB                aligned   in
                                                       to LSB   bits
       (  0)  |11111111|11000                             1ff8  [13]
       (  1)  |11111111|11111111|1011000                7fffd8  [23]
       (  2)  |11111111|11111111|11111110|0010         fffffe2  [28]
       (  3)  |11111111|11111111|11111110|0011         fffffe3  [28]
       (  4)  |11111111|11111111|11111110|0100         fffffe4  [28]
       (  5)  |11111111|11111111|11111110|0101         fffffe5  [28]
       (  6)  |11111111|11111111|11111110|0110         fffffe6  [28]
       (  7)  |11111111|11111111|11111110|0111         fffffe7  [28]
       (  8)  |11111111|11111111|11111110|1000         fffffe8  [28]
       (  9)  |11111111|11111111|11101010               ffffea  [24]
       ( 10)  |11111111|11111111|11111111|111100      3ffffffc  [30]
       ( 11)  |11111111|11111111|11111110|1001         fffffe9  [28]
       ( 12)  |11111111|11111111|11111110|1010         fffffea  [28]
       ( 13)  |11111111|11111111|11111111|111101      3ffffffd  [30]
        
       ( 14)  |11111111|11111111|11111110|1011         fffffeb  [28]
       ( 15)  |11111111|11111111|11111110|1100         fffffec  [28]
       ( 16)  |11111111|11111111|11111110|1101         fffffed  [28]
       ( 17)  |11111111|11111111|11111110|1110         fffffee  [28]
       ( 18)  |11111111|11111111|11111110|1111         fffffef  [28]
       ( 19)  |11111111|11111111|11111111|0000         ffffff0  [28]
       ( 20)  |11111111|11111111|11111111|0001         ffffff1  [28]
       ( 21)  |11111111|11111111|11111111|0010         ffffff2  [28]
       ( 22)  |11111111|11111111|11111111|111110      3ffffffe  [30]
       ( 23)  |11111111|11111111|11111111|0011         ffffff3  [28]
       ( 24)  |11111111|11111111|11111111|0100         ffffff4  [28]
       ( 25)  |11111111|11111111|11111111|0101         ffffff5  [28]
       ( 26)  |11111111|11111111|11111111|0110         ffffff6  [28]
       ( 27)  |11111111|11111111|11111111|0111         ffffff7  [28]
       ( 28)  |11111111|11111111|11111111|1000         ffffff8  [28]
       ( 29)  |11111111|11111111|11111111|1001         ffffff9  [28]
       ( 30)  |11111111|11111111|11111111|1010         ffffffa  [28]
       ( 31)  |11111111|11111111|11111111|1011         ffffffb  [28]
   ' ' ( 32)  |010100                                       14  [ 6]
   '!' ( 33)  |11111110|00                                 3f8  [10]
   '"' ( 34)  |11111110|01                                 3f9  [10]
   '#' ( 35)  |11111111|1010                               ffa  [12]
   '$' ( 36)  |11111111|11001                             1ff9  [13]
   '%' ( 37)  |010101                                       15  [ 6]
   '&' ( 38)  |11111000                                     f8  [ 8]
   ''' ( 39)  |11111111|010                                7fa  [11]
   '(' ( 40)  |11111110|10                                 3fa  [10]
   ')' ( 41)  |11111110|11                                 3fb  [10]
   '*' ( 42)  |11111001                                     f9  [ 8]
   '+' ( 43)  |11111111|011                                7fb  [11]
   ',' ( 44)  |11111010                                     fa  [ 8]
   '-' ( 45)  |010110                                       16  [ 6]
   '.' ( 46)  |010111                                       17  [ 6]
   '/' ( 47)  |011000                                       18  [ 6]
   '0' ( 48)  |00000                                         0  [ 5]
   '1' ( 49)  |00001                                         1  [ 5]
   '2' ( 50)  |00010                                         2  [ 5]
   '3' ( 51)  |011001                                       19  [ 6]
   '4' ( 52)  |011010                                       1a  [ 6]
   '5' ( 53)  |011011                                       1b  [ 6]
   '6' ( 54)  |011100                                       1c  [ 6]
   '7' ( 55)  |011101                                       1d  [ 6]
   '8' ( 56)  |011110                                       1e  [ 6]
   '9' ( 57)  |011111                                       1f  [ 6]
   ':' ( 58)  |1011100                                      5c  [ 7]
   ';' ( 59)  |11111011                                     fb  [ 8]
   '<' ( 60)  |11111111|1111100                           7ffc  [15]
   '=' ( 61)  |100000                                       20  [ 6]
        
       ( 14)  |11111111|11111111|11111110|1011         fffffeb  [28]
       ( 15)  |11111111|11111111|11111110|1100         fffffec  [28]
       ( 16)  |11111111|11111111|11111110|1101         fffffed  [28]
       ( 17)  |11111111|11111111|11111110|1110         fffffee  [28]
       ( 18)  |11111111|11111111|11111110|1111         fffffef  [28]
       ( 19)  |11111111|11111111|11111111|0000         ffffff0  [28]
       ( 20)  |11111111|11111111|11111111|0001         ffffff1  [28]
       ( 21)  |11111111|11111111|11111111|0010         ffffff2  [28]
       ( 22)  |11111111|11111111|11111111|111110      3ffffffe  [30]
       ( 23)  |11111111|11111111|11111111|0011         ffffff3  [28]
       ( 24)  |11111111|11111111|11111111|0100         ffffff4  [28]
       ( 25)  |11111111|11111111|11111111|0101         ffffff5  [28]
       ( 26)  |11111111|11111111|11111111|0110         ffffff6  [28]
       ( 27)  |11111111|11111111|11111111|0111         ffffff7  [28]
       ( 28)  |11111111|11111111|11111111|1000         ffffff8  [28]
       ( 29)  |11111111|11111111|11111111|1001         ffffff9  [28]
       ( 30)  |11111111|11111111|11111111|1010         ffffffa  [28]
       ( 31)  |11111111|11111111|11111111|1011         ffffffb  [28]
   ' ' ( 32)  |010100                                       14  [ 6]
   '!' ( 33)  |11111110|00                                 3f8  [10]
   '"' ( 34)  |11111110|01                                 3f9  [10]
   '#' ( 35)  |11111111|1010                               ffa  [12]
   '$' ( 36)  |11111111|11001                             1ff9  [13]
   '%' ( 37)  |010101                                       15  [ 6]
   '&' ( 38)  |11111000                                     f8  [ 8]
   ''' ( 39)  |11111111|010                                7fa  [11]
   '(' ( 40)  |11111110|10                                 3fa  [10]
   ')' ( 41)  |11111110|11                                 3fb  [10]
   '*' ( 42)  |11111001                                     f9  [ 8]
   '+' ( 43)  |11111111|011                                7fb  [11]
   ',' ( 44)  |11111010                                     fa  [ 8]
   '-' ( 45)  |010110                                       16  [ 6]
   '.' ( 46)  |010111                                       17  [ 6]
   '/' ( 47)  |011000                                       18  [ 6]
   '0' ( 48)  |00000                                         0  [ 5]
   '1' ( 49)  |00001                                         1  [ 5]
   '2' ( 50)  |00010                                         2  [ 5]
   '3' ( 51)  |011001                                       19  [ 6]
   '4' ( 52)  |011010                                       1a  [ 6]
   '5' ( 53)  |011011                                       1b  [ 6]
   '6' ( 54)  |011100                                       1c  [ 6]
   '7' ( 55)  |011101                                       1d  [ 6]
   '8' ( 56)  |011110                                       1e  [ 6]
   '9' ( 57)  |011111                                       1f  [ 6]
   ':' ( 58)  |1011100                                      5c  [ 7]
   ';' ( 59)  |11111011                                     fb  [ 8]
   '<' ( 60)  |11111111|1111100                           7ffc  [15]
   '=' ( 61)  |100000                                       20  [ 6]
        
   '>' ( 62)  |11111111|1011                               ffb  [12]
   '?' ( 63)  |11111111|00                                 3fc  [10]
   '@' ( 64)  |11111111|11010                             1ffa  [13]
   'A' ( 65)  |100001                                       21  [ 6]
   'B' ( 66)  |1011101                                      5d  [ 7]
   'C' ( 67)  |1011110                                      5e  [ 7]
   'D' ( 68)  |1011111                                      5f  [ 7]
   'E' ( 69)  |1100000                                      60  [ 7]
   'F' ( 70)  |1100001                                      61  [ 7]
   'G' ( 71)  |1100010                                      62  [ 7]
   'H' ( 72)  |1100011                                      63  [ 7]
   'I' ( 73)  |1100100                                      64  [ 7]
   'J' ( 74)  |1100101                                      65  [ 7]
   'K' ( 75)  |1100110                                      66  [ 7]
   'L' ( 76)  |1100111                                      67  [ 7]
   'M' ( 77)  |1101000                                      68  [ 7]
   'N' ( 78)  |1101001                                      69  [ 7]
   'O' ( 79)  |1101010                                      6a  [ 7]
   'P' ( 80)  |1101011                                      6b  [ 7]
   'Q' ( 81)  |1101100                                      6c  [ 7]
   'R' ( 82)  |1101101                                      6d  [ 7]
   'S' ( 83)  |1101110                                      6e  [ 7]
   'T' ( 84)  |1101111                                      6f  [ 7]
   'U' ( 85)  |1110000                                      70  [ 7]
   'V' ( 86)  |1110001                                      71  [ 7]
   'W' ( 87)  |1110010                                      72  [ 7]
   'X' ( 88)  |11111100                                     fc  [ 8]
   'Y' ( 89)  |1110011                                      73  [ 7]
   'Z' ( 90)  |11111101                                     fd  [ 8]
   '[' ( 91)  |11111111|11011                             1ffb  [13]
   '\' ( 92)  |11111111|11111110|000                     7fff0  [19]
   ']' ( 93)  |11111111|11100                             1ffc  [13]
   '^' ( 94)  |11111111|111100                            3ffc  [14]
   '_' ( 95)  |100010                                       22  [ 6]
   '`' ( 96)  |11111111|1111101                           7ffd  [15]
   'a' ( 97)  |00011                                         3  [ 5]
   'b' ( 98)  |100011                                       23  [ 6]
   'c' ( 99)  |00100                                         4  [ 5]
   'd' (100)  |100100                                       24  [ 6]
   'e' (101)  |00101                                         5  [ 5]
   'f' (102)  |100101                                       25  [ 6]
   'g' (103)  |100110                                       26  [ 6]
   'h' (104)  |100111                                       27  [ 6]
   'i' (105)  |00110                                         6  [ 5]
   'j' (106)  |1110100                                      74  [ 7]
   'k' (107)  |1110101                                      75  [ 7]
   'l' (108)  |101000                                       28  [ 6]
   'm' (109)  |101001                                       29  [ 6]
        
   '>' ( 62)  |11111111|1011                               ffb  [12]
   '?' ( 63)  |11111111|00                                 3fc  [10]
   '@' ( 64)  |11111111|11010                             1ffa  [13]
   'A' ( 65)  |100001                                       21  [ 6]
   'B' ( 66)  |1011101                                      5d  [ 7]
   'C' ( 67)  |1011110                                      5e  [ 7]
   'D' ( 68)  |1011111                                      5f  [ 7]
   'E' ( 69)  |1100000                                      60  [ 7]
   'F' ( 70)  |1100001                                      61  [ 7]
   'G' ( 71)  |1100010                                      62  [ 7]
   'H' ( 72)  |1100011                                      63  [ 7]
   'I' ( 73)  |1100100                                      64  [ 7]
   'J' ( 74)  |1100101                                      65  [ 7]
   'K' ( 75)  |1100110                                      66  [ 7]
   'L' ( 76)  |1100111                                      67  [ 7]
   'M' ( 77)  |1101000                                      68  [ 7]
   'N' ( 78)  |1101001                                      69  [ 7]
   'O' ( 79)  |1101010                                      6a  [ 7]
   'P' ( 80)  |1101011                                      6b  [ 7]
   'Q' ( 81)  |1101100                                      6c  [ 7]
   'R' ( 82)  |1101101                                      6d  [ 7]
   'S' ( 83)  |1101110                                      6e  [ 7]
   'T' ( 84)  |1101111                                      6f  [ 7]
   'U' ( 85)  |1110000                                      70  [ 7]
   'V' ( 86)  |1110001                                      71  [ 7]
   'W' ( 87)  |1110010                                      72  [ 7]
   'X' ( 88)  |11111100                                     fc  [ 8]
   'Y' ( 89)  |1110011                                      73  [ 7]
   'Z' ( 90)  |11111101                                     fd  [ 8]
   '[' ( 91)  |11111111|11011                             1ffb  [13]
   '\' ( 92)  |11111111|11111110|000                     7fff0  [19]
   ']' ( 93)  |11111111|11100                             1ffc  [13]
   '^' ( 94)  |11111111|111100                            3ffc  [14]
   '_' ( 95)  |100010                                       22  [ 6]
   '`' ( 96)  |11111111|1111101                           7ffd  [15]
   'a' ( 97)  |00011                                         3  [ 5]
   'b' ( 98)  |100011                                       23  [ 6]
   'c' ( 99)  |00100                                         4  [ 5]
   'd' (100)  |100100                                       24  [ 6]
   'e' (101)  |00101                                         5  [ 5]
   'f' (102)  |100101                                       25  [ 6]
   'g' (103)  |100110                                       26  [ 6]
   'h' (104)  |100111                                       27  [ 6]
   'i' (105)  |00110                                         6  [ 5]
   'j' (106)  |1110100                                      74  [ 7]
   'k' (107)  |1110101                                      75  [ 7]
   'l' (108)  |101000                                       28  [ 6]
   'm' (109)  |101001                                       29  [ 6]
        
   'n' (110)  |101010                                       2a  [ 6]
   'o' (111)  |00111                                         7  [ 5]
   'p' (112)  |101011                                       2b  [ 6]
   'q' (113)  |1110110                                      76  [ 7]
   'r' (114)  |101100                                       2c  [ 6]
   's' (115)  |01000                                         8  [ 5]
   't' (116)  |01001                                         9  [ 5]
   'u' (117)  |101101                                       2d  [ 6]
   'v' (118)  |1110111                                      77  [ 7]
   'w' (119)  |1111000                                      78  [ 7]
   'x' (120)  |1111001                                      79  [ 7]
   'y' (121)  |1111010                                      7a  [ 7]
   'z' (122)  |1111011                                      7b  [ 7]
   '{' (123)  |11111111|1111110                           7ffe  [15]
   '|' (124)  |11111111|100                                7fc  [11]
   '}' (125)  |11111111|111101                            3ffd  [14]
   '~' (126)  |11111111|11101                             1ffd  [13]
       (127)  |11111111|11111111|11111111|1100         ffffffc  [28]
       (128)  |11111111|11111110|0110                    fffe6  [20]
       (129)  |11111111|11111111|010010                 3fffd2  [22]
       (130)  |11111111|11111110|0111                    fffe7  [20]
       (131)  |11111111|11111110|1000                    fffe8  [20]
       (132)  |11111111|11111111|010011                 3fffd3  [22]
       (133)  |11111111|11111111|010100                 3fffd4  [22]
       (134)  |11111111|11111111|010101                 3fffd5  [22]
       (135)  |11111111|11111111|1011001                7fffd9  [23]
       (136)  |11111111|11111111|010110                 3fffd6  [22]
       (137)  |11111111|11111111|1011010                7fffda  [23]
       (138)  |11111111|11111111|1011011                7fffdb  [23]
       (139)  |11111111|11111111|1011100                7fffdc  [23]
       (140)  |11111111|11111111|1011101                7fffdd  [23]
       (141)  |11111111|11111111|1011110                7fffde  [23]
       (142)  |11111111|11111111|11101011               ffffeb  [24]
       (143)  |11111111|11111111|1011111                7fffdf  [23]
       (144)  |11111111|11111111|11101100               ffffec  [24]
       (145)  |11111111|11111111|11101101               ffffed  [24]
       (146)  |11111111|11111111|010111                 3fffd7  [22]
       (147)  |11111111|11111111|1100000                7fffe0  [23]
       (148)  |11111111|11111111|11101110               ffffee  [24]
       (149)  |11111111|11111111|1100001                7fffe1  [23]
       (150)  |11111111|11111111|1100010                7fffe2  [23]
       (151)  |11111111|11111111|1100011                7fffe3  [23]
       (152)  |11111111|11111111|1100100                7fffe4  [23]
       (153)  |11111111|11111110|11100                  1fffdc  [21]
       (154)  |11111111|11111111|011000                 3fffd8  [22]
       (155)  |11111111|11111111|1100101                7fffe5  [23]
       (156)  |11111111|11111111|011001                 3fffd9  [22]
       (157)  |11111111|11111111|1100110                7fffe6  [23]
        
   'n' (110)  |101010                                       2a  [ 6]
   'o' (111)  |00111                                         7  [ 5]
   'p' (112)  |101011                                       2b  [ 6]
   'q' (113)  |1110110                                      76  [ 7]
   'r' (114)  |101100                                       2c  [ 6]
   's' (115)  |01000                                         8  [ 5]
   't' (116)  |01001                                         9  [ 5]
   'u' (117)  |101101                                       2d  [ 6]
   'v' (118)  |1110111                                      77  [ 7]
   'w' (119)  |1111000                                      78  [ 7]
   'x' (120)  |1111001                                      79  [ 7]
   'y' (121)  |1111010                                      7a  [ 7]
   'z' (122)  |1111011                                      7b  [ 7]
   '{' (123)  |11111111|1111110                           7ffe  [15]
   '|' (124)  |11111111|100                                7fc  [11]
   '}' (125)  |11111111|111101                            3ffd  [14]
   '~' (126)  |11111111|11101                             1ffd  [13]
       (127)  |11111111|11111111|11111111|1100         ffffffc  [28]
       (128)  |11111111|11111110|0110                    fffe6  [20]
       (129)  |11111111|11111111|010010                 3fffd2  [22]
       (130)  |11111111|11111110|0111                    fffe7  [20]
       (131)  |11111111|11111110|1000                    fffe8  [20]
       (132)  |11111111|11111111|010011                 3fffd3  [22]
       (133)  |11111111|11111111|010100                 3fffd4  [22]
       (134)  |11111111|11111111|010101                 3fffd5  [22]
       (135)  |11111111|11111111|1011001                7fffd9  [23]
       (136)  |11111111|11111111|010110                 3fffd6  [22]
       (137)  |11111111|11111111|1011010                7fffda  [23]
       (138)  |11111111|11111111|1011011                7fffdb  [23]
       (139)  |11111111|11111111|1011100                7fffdc  [23]
       (140)  |11111111|11111111|1011101                7fffdd  [23]
       (141)  |11111111|11111111|1011110                7fffde  [23]
       (142)  |11111111|11111111|11101011               ffffeb  [24]
       (143)  |11111111|11111111|1011111                7fffdf  [23]
       (144)  |11111111|11111111|11101100               ffffec  [24]
       (145)  |11111111|11111111|11101101               ffffed  [24]
       (146)  |11111111|11111111|010111                 3fffd7  [22]
       (147)  |11111111|11111111|1100000                7fffe0  [23]
       (148)  |11111111|11111111|11101110               ffffee  [24]
       (149)  |11111111|11111111|1100001                7fffe1  [23]
       (150)  |11111111|11111111|1100010                7fffe2  [23]
       (151)  |11111111|11111111|1100011                7fffe3  [23]
       (152)  |11111111|11111111|1100100                7fffe4  [23]
       (153)  |11111111|11111110|11100                  1fffdc  [21]
       (154)  |11111111|11111111|011000                 3fffd8  [22]
       (155)  |11111111|11111111|1100101                7fffe5  [23]
       (156)  |11111111|11111111|011001                 3fffd9  [22]
       (157)  |11111111|11111111|1100110                7fffe6  [23]
        
       (158)  |11111111|11111111|1100111                7fffe7  [23]
       (159)  |11111111|11111111|11101111               ffffef  [24]
       (160)  |11111111|11111111|011010                 3fffda  [22]
       (161)  |11111111|11111110|11101                  1fffdd  [21]
       (162)  |11111111|11111110|1001                    fffe9  [20]
       (163)  |11111111|11111111|011011                 3fffdb  [22]
       (164)  |11111111|11111111|011100                 3fffdc  [22]
       (165)  |11111111|11111111|1101000                7fffe8  [23]
       (166)  |11111111|11111111|1101001                7fffe9  [23]
       (167)  |11111111|11111110|11110                  1fffde  [21]
       (168)  |11111111|11111111|1101010                7fffea  [23]
       (169)  |11111111|11111111|011101                 3fffdd  [22]
       (170)  |11111111|11111111|011110                 3fffde  [22]
       (171)  |11111111|11111111|11110000               fffff0  [24]
       (172)  |11111111|11111110|11111                  1fffdf  [21]
       (173)  |11111111|11111111|011111                 3fffdf  [22]
       (174)  |11111111|11111111|1101011                7fffeb  [23]
       (175)  |11111111|11111111|1101100                7fffec  [23]
       (176)  |11111111|11111111|00000                  1fffe0  [21]
       (177)  |11111111|11111111|00001                  1fffe1  [21]
       (178)  |11111111|11111111|100000                 3fffe0  [22]
       (179)  |11111111|11111111|00010                  1fffe2  [21]
       (180)  |11111111|11111111|1101101                7fffed  [23]
       (181)  |11111111|11111111|100001                 3fffe1  [22]
       (182)  |11111111|11111111|1101110                7fffee  [23]
       (183)  |11111111|11111111|1101111                7fffef  [23]
       (184)  |11111111|11111110|1010                    fffea  [20]
       (185)  |11111111|11111111|100010                 3fffe2  [22]
       (186)  |11111111|11111111|100011                 3fffe3  [22]
       (187)  |11111111|11111111|100100                 3fffe4  [22]
       (188)  |11111111|11111111|1110000                7ffff0  [23]
       (189)  |11111111|11111111|100101                 3fffe5  [22]
       (190)  |11111111|11111111|100110                 3fffe6  [22]
       (191)  |11111111|11111111|1110001                7ffff1  [23]
       (192)  |11111111|11111111|11111000|00           3ffffe0  [26]
       (193)  |11111111|11111111|11111000|01           3ffffe1  [26]
       (194)  |11111111|11111110|1011                    fffeb  [20]
       (195)  |11111111|11111110|001                     7fff1  [19]
       (196)  |11111111|11111111|100111                 3fffe7  [22]
       (197)  |11111111|11111111|1110010                7ffff2  [23]
       (198)  |11111111|11111111|101000                 3fffe8  [22]
       (199)  |11111111|11111111|11110110|0            1ffffec  [25]
       (200)  |11111111|11111111|11111000|10           3ffffe2  [26]
       (201)  |11111111|11111111|11111000|11           3ffffe3  [26]
       (202)  |11111111|11111111|11111001|00           3ffffe4  [26]
       (203)  |11111111|11111111|11111011|110          7ffffde  [27]
       (204)  |11111111|11111111|11111011|111          7ffffdf  [27]
       (205)  |11111111|11111111|11111001|01           3ffffe5  [26]
        
       (158)  |11111111|11111111|1100111                7fffe7  [23]
       (159)  |11111111|11111111|11101111               ffffef  [24]
       (160)  |11111111|11111111|011010                 3fffda  [22]
       (161)  |11111111|11111110|11101                  1fffdd  [21]
       (162)  |11111111|11111110|1001                    fffe9  [20]
       (163)  |11111111|11111111|011011                 3fffdb  [22]
       (164)  |11111111|11111111|011100                 3fffdc  [22]
       (165)  |11111111|11111111|1101000                7fffe8  [23]
       (166)  |11111111|11111111|1101001                7fffe9  [23]
       (167)  |11111111|11111110|11110                  1fffde  [21]
       (168)  |11111111|11111111|1101010                7fffea  [23]
       (169)  |11111111|11111111|011101                 3fffdd  [22]
       (170)  |11111111|11111111|011110                 3fffde  [22]
       (171)  |11111111|11111111|11110000               fffff0  [24]
       (172)  |11111111|11111110|11111                  1fffdf  [21]
       (173)  |11111111|11111111|011111                 3fffdf  [22]
       (174)  |11111111|11111111|1101011                7fffeb  [23]
       (175)  |11111111|11111111|1101100                7fffec  [23]
       (176)  |11111111|11111111|00000                  1fffe0  [21]
       (177)  |11111111|11111111|00001                  1fffe1  [21]
       (178)  |11111111|11111111|100000                 3fffe0  [22]
       (179)  |11111111|11111111|00010                  1fffe2  [21]
       (180)  |11111111|11111111|1101101                7fffed  [23]
       (181)  |11111111|11111111|100001                 3fffe1  [22]
       (182)  |11111111|11111111|1101110                7fffee  [23]
       (183)  |11111111|11111111|1101111                7fffef  [23]
       (184)  |11111111|11111110|1010                    fffea  [20]
       (185)  |11111111|11111111|100010                 3fffe2  [22]
       (186)  |11111111|11111111|100011                 3fffe3  [22]
       (187)  |11111111|11111111|100100                 3fffe4  [22]
       (188)  |11111111|11111111|1110000                7ffff0  [23]
       (189)  |11111111|11111111|100101                 3fffe5  [22]
       (190)  |11111111|11111111|100110                 3fffe6  [22]
       (191)  |11111111|11111111|1110001                7ffff1  [23]
       (192)  |11111111|11111111|11111000|00           3ffffe0  [26]
       (193)  |11111111|11111111|11111000|01           3ffffe1  [26]
       (194)  |11111111|11111110|1011                    fffeb  [20]
       (195)  |11111111|11111110|001                     7fff1  [19]
       (196)  |11111111|11111111|100111                 3fffe7  [22]
       (197)  |11111111|11111111|1110010                7ffff2  [23]
       (198)  |11111111|11111111|101000                 3fffe8  [22]
       (199)  |11111111|11111111|11110110|0            1ffffec  [25]
       (200)  |11111111|11111111|11111000|10           3ffffe2  [26]
       (201)  |11111111|11111111|11111000|11           3ffffe3  [26]
       (202)  |11111111|11111111|11111001|00           3ffffe4  [26]
       (203)  |11111111|11111111|11111011|110          7ffffde  [27]
       (204)  |11111111|11111111|11111011|111          7ffffdf  [27]
       (205)  |11111111|11111111|11111001|01           3ffffe5  [26]
        
       (206)  |11111111|11111111|11110001               fffff1  [24]
       (207)  |11111111|11111111|11110110|1            1ffffed  [25]
       (208)  |11111111|11111110|010                     7fff2  [19]
       (209)  |11111111|11111111|00011                  1fffe3  [21]
       (210)  |11111111|11111111|11111001|10           3ffffe6  [26]
       (211)  |11111111|11111111|11111100|000          7ffffe0  [27]
       (212)  |11111111|11111111|11111100|001          7ffffe1  [27]
       (213)  |11111111|11111111|11111001|11           3ffffe7  [26]
       (214)  |11111111|11111111|11111100|010          7ffffe2  [27]
       (215)  |11111111|11111111|11110010               fffff2  [24]
       (216)  |11111111|11111111|00100                  1fffe4  [21]
       (217)  |11111111|11111111|00101                  1fffe5  [21]
       (218)  |11111111|11111111|11111010|00           3ffffe8  [26]
       (219)  |11111111|11111111|11111010|01           3ffffe9  [26]
       (220)  |11111111|11111111|11111111|1101         ffffffd  [28]
       (221)  |11111111|11111111|11111100|011          7ffffe3  [27]
       (222)  |11111111|11111111|11111100|100          7ffffe4  [27]
       (223)  |11111111|11111111|11111100|101          7ffffe5  [27]
       (224)  |11111111|11111110|1100                    fffec  [20]
       (225)  |11111111|11111111|11110011               fffff3  [24]
       (226)  |11111111|11111110|1101                    fffed  [20]
       (227)  |11111111|11111111|00110                  1fffe6  [21]
       (228)  |11111111|11111111|101001                 3fffe9  [22]
       (229)  |11111111|11111111|00111                  1fffe7  [21]
       (230)  |11111111|11111111|01000                  1fffe8  [21]
       (231)  |11111111|11111111|1110011                7ffff3  [23]
       (232)  |11111111|11111111|101010                 3fffea  [22]
       (233)  |11111111|11111111|101011                 3fffeb  [22]
       (234)  |11111111|11111111|11110111|0            1ffffee  [25]
       (235)  |11111111|11111111|11110111|1            1ffffef  [25]
       (236)  |11111111|11111111|11110100               fffff4  [24]
       (237)  |11111111|11111111|11110101               fffff5  [24]
       (238)  |11111111|11111111|11111010|10           3ffffea  [26]
       (239)  |11111111|11111111|1110100                7ffff4  [23]
       (240)  |11111111|11111111|11111010|11           3ffffeb  [26]
       (241)  |11111111|11111111|11111100|110          7ffffe6  [27]
       (242)  |11111111|11111111|11111011|00           3ffffec  [26]
       (243)  |11111111|11111111|11111011|01           3ffffed  [26]
       (244)  |11111111|11111111|11111100|111          7ffffe7  [27]
       (245)  |11111111|11111111|11111101|000          7ffffe8  [27]
       (246)  |11111111|11111111|11111101|001          7ffffe9  [27]
       (247)  |11111111|11111111|11111101|010          7ffffea  [27]
       (248)  |11111111|11111111|11111101|011          7ffffeb  [27]
       (249)  |11111111|11111111|11111111|1110         ffffffe  [28]
       (250)  |11111111|11111111|11111101|100          7ffffec  [27]
       (251)  |11111111|11111111|11111101|101          7ffffed  [27]
       (252)  |11111111|11111111|11111101|110          7ffffee  [27]
       (253)  |11111111|11111111|11111101|111          7ffffef  [27]
        
       (206)  |11111111|11111111|11110001               fffff1  [24]
       (207)  |11111111|11111111|11110110|1            1ffffed  [25]
       (208)  |11111111|11111110|010                     7fff2  [19]
       (209)  |11111111|11111111|00011                  1fffe3  [21]
       (210)  |11111111|11111111|11111001|10           3ffffe6  [26]
       (211)  |11111111|11111111|11111100|000          7ffffe0  [27]
       (212)  |11111111|11111111|11111100|001          7ffffe1  [27]
       (213)  |11111111|11111111|11111001|11           3ffffe7  [26]
       (214)  |11111111|11111111|11111100|010          7ffffe2  [27]
       (215)  |11111111|11111111|11110010               fffff2  [24]
       (216)  |11111111|11111111|00100                  1fffe4  [21]
       (217)  |11111111|11111111|00101                  1fffe5  [21]
       (218)  |11111111|11111111|11111010|00           3ffffe8  [26]
       (219)  |11111111|11111111|11111010|01           3ffffe9  [26]
       (220)  |11111111|11111111|11111111|1101         ffffffd  [28]
       (221)  |11111111|11111111|11111100|011          7ffffe3  [27]
       (222)  |11111111|11111111|11111100|100          7ffffe4  [27]
       (223)  |11111111|11111111|11111100|101          7ffffe5  [27]
       (224)  |11111111|11111110|1100                    fffec  [20]
       (225)  |11111111|11111111|11110011               fffff3  [24]
       (226)  |11111111|11111110|1101                    fffed  [20]
       (227)  |11111111|11111111|00110                  1fffe6  [21]
       (228)  |11111111|11111111|101001                 3fffe9  [22]
       (229)  |11111111|11111111|00111                  1fffe7  [21]
       (230)  |11111111|11111111|01000                  1fffe8  [21]
       (231)  |11111111|11111111|1110011                7ffff3  [23]
       (232)  |11111111|11111111|101010                 3fffea  [22]
       (233)  |11111111|11111111|101011                 3fffeb  [22]
       (234)  |11111111|11111111|11110111|0            1ffffee  [25]
       (235)  |11111111|11111111|11110111|1            1ffffef  [25]
       (236)  |11111111|11111111|11110100               fffff4  [24]
       (237)  |11111111|11111111|11110101               fffff5  [24]
       (238)  |11111111|11111111|11111010|10           3ffffea  [26]
       (239)  |11111111|11111111|1110100                7ffff4  [23]
       (240)  |11111111|11111111|11111010|11           3ffffeb  [26]
       (241)  |11111111|11111111|11111100|110          7ffffe6  [27]
       (242)  |11111111|11111111|11111011|00           3ffffec  [26]
       (243)  |11111111|11111111|11111011|01           3ffffed  [26]
       (244)  |11111111|11111111|11111100|111          7ffffe7  [27]
       (245)  |11111111|11111111|11111101|000          7ffffe8  [27]
       (246)  |11111111|11111111|11111101|001          7ffffe9  [27]
       (247)  |11111111|11111111|11111101|010          7ffffea  [27]
       (248)  |11111111|11111111|11111101|011          7ffffeb  [27]
       (249)  |11111111|11111111|11111111|1110         ffffffe  [28]
       (250)  |11111111|11111111|11111101|100          7ffffec  [27]
       (251)  |11111111|11111111|11111101|101          7ffffed  [27]
       (252)  |11111111|11111111|11111101|110          7ffffee  [27]
       (253)  |11111111|11111111|11111101|111          7ffffef  [27]
        
       (254)  |11111111|11111111|11111110|000          7fffff0  [27]
       (255)  |11111111|11111111|11111011|10           3ffffee  [26]
   EOS (256)  |11111111|11111111|11111111|111111      3fffffff  [30]
        
       (254)  |11111111|11111111|11111110|000          7fffff0  [27]
       (255)  |11111111|11111111|11111011|10           3ffffee  [26]
   EOS (256)  |11111111|11111111|11111111|111111      3fffffff  [30]
        
Appendix C. Examples
附录C.示例

This appendix contains examples covering integer encoding, header field representation, and the encoding of whole lists of header fields for both requests and responses, with and without Huffman coding.

本附录包含的示例包括整数编码、头字段表示以及请求和响应的头字段的整个列表的编码,包括哈夫曼编码和不包括哈夫曼编码。

C.1. Integer Representation Examples
C.1. 整数表示示例

This section shows the representation of integer values in detail (see Section 5.1).

本节详细介绍了整数值的表示(见第5.1节)。

C.1.1. Example 1: Encoding 10 Using a 5-Bit Prefix
C.1.1. 示例1:使用5位前缀编码10

The value 10 is to be encoded with a 5-bit prefix.

值10将使用5位前缀进行编码。

o 10 is less than 31 (2^5 - 1) and is represented using the 5-bit prefix.

o 10小于31(2^5-1),并使用5位前缀表示。

     0   1   2   3   4   5   6   7
   +---+---+---+---+---+---+---+---+
   | X | X | X | 0 | 1 | 0 | 1 | 0 |   10 stored on 5 bits
   +---+---+---+---+---+---+---+---+
        
     0   1   2   3   4   5   6   7
   +---+---+---+---+---+---+---+---+
   | X | X | X | 0 | 1 | 0 | 1 | 0 |   10 stored on 5 bits
   +---+---+---+---+---+---+---+---+
        
C.1.2. Example 2: Encoding 1337 Using a 5-Bit Prefix
C.1.2. 示例2:使用5位前缀编码1337

The value I=1337 is to be encoded with a 5-bit prefix.

值I=1337将使用5位前缀进行编码。

1337 is greater than 31 (2^5 - 1).

1337大于31(2^5-1)。

The 5-bit prefix is filled with its max value (31).

5位前缀用其最大值(31)填充。

I = 1337 - (2^5 - 1) = 1306.

I=1337-(2^5-1)=1306。

I (1306) is greater than or equal to 128, so the while loop body executes:

I(1306)大于或等于128,因此while循环体执行:

I % 128 == 26

I%128==26

            26 + 128 == 154
        
            26 + 128 == 154
        

154 is encoded in 8 bits as: 10011010

154按8位编码为:10011010

            I is set to 10 (1306 / 128 == 10)
        
            I is set to 10 (1306 / 128 == 10)
        

I is no longer greater than or equal to 128, so the while loop terminates.

I不再大于或等于128,因此while循环终止。

I, now 10, is encoded in 8 bits as: 00001010.

一、 现在是10,用8位编码为:00001010。

The process ends.

这个过程结束了。

     0   1   2   3   4   5   6   7
   +---+---+---+---+---+---+---+---+
   | X | X | X | 1 | 1 | 1 | 1 | 1 |  Prefix = 31, I = 1306
   | 1 | 0 | 0 | 1 | 1 | 0 | 1 | 0 |  1306>=128, encode(154), I=1306/128
   | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 |  10<128, encode(10), done
   +---+---+---+---+---+---+---+---+
        
     0   1   2   3   4   5   6   7
   +---+---+---+---+---+---+---+---+
   | X | X | X | 1 | 1 | 1 | 1 | 1 |  Prefix = 31, I = 1306
   | 1 | 0 | 0 | 1 | 1 | 0 | 1 | 0 |  1306>=128, encode(154), I=1306/128
   | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 |  10<128, encode(10), done
   +---+---+---+---+---+---+---+---+
        
C.1.3. Example 3: Encoding 42 Starting at an Octet Boundary
C.1.3. 示例3:从八位字节边界开始编码42

The value 42 is to be encoded starting at an octet boundary. This implies that a 8-bit prefix is used.

值42将从八位组边界开始编码。这意味着使用了8位前缀。

o 42 is less than 255 (2^8 - 1) and is represented using the 8-bit prefix.

o 42小于255(2^8-1),并使用8位前缀表示。

     0   1   2   3   4   5   6   7
   +---+---+---+---+---+---+---+---+
   | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 |   42 stored on 8 bits
   +---+---+---+---+---+---+---+---+
        
     0   1   2   3   4   5   6   7
   +---+---+---+---+---+---+---+---+
   | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 |   42 stored on 8 bits
   +---+---+---+---+---+---+---+---+
        
C.2. Header Field Representation Examples
C.2. 标题字段表示示例

This section shows several independent representation examples.

本节显示了几个独立的表示示例。

C.2.1. Literal Header Field with Indexing
C.2.1. 带索引的文字标题字段

The header field representation uses a literal name and a literal value. The header field is added to the dynamic table.

标题字段表示使用文字名称和文字值。标题字段将添加到动态表中。

Header list to encode:

要编码的标题列表:

custom-key: custom-header

自定义键:自定义标题

Hex dump of encoded data:

编码数据的十六进制转储:

400a 6375 7374 6f6d 2d6b 6579 0d63 7573 | @.custom-key.cus 746f 6d2d 6865 6164 6572 | tom-header

400a 6375 7374 6f6d 2d6b 6579 0d63 7573|@自定义键。cus 746f 6d2d 6865 6164 6572|tom头

Decoding process:

解码过程:

   40                                      | == Literal indexed ==
   0a                                      |   Literal name (len = 10)
   6375 7374 6f6d 2d6b 6579                | custom-key
   0d                                      |   Literal value (len = 13)
   6375 7374 6f6d 2d68 6561 6465 72        | custom-header
                                           | -> custom-key:
                                           |   custom-header
        
   40                                      | == Literal indexed ==
   0a                                      |   Literal name (len = 10)
   6375 7374 6f6d 2d6b 6579                | custom-key
   0d                                      |   Literal value (len = 13)
   6375 7374 6f6d 2d68 6561 6465 72        | custom-header
                                           | -> custom-key:
                                           |   custom-header
        

Dynamic Table (after decoding):

动态表(解码后):

[ 1] (s = 55) custom-key: custom-header Table size: 55

[1](s=55)自定义键:自定义标题表大小:55

Decoded header list:

解码标题列表:

custom-key: custom-header

自定义键:自定义标题

C.2.2. Literal Header Field without Indexing
C.2.2. 不带索引的文本标题字段

The header field representation uses an indexed name and a literal value. The header field is not added to the dynamic table.

标题字段表示使用索引名称和文字值。标题字段不会添加到动态表中。

Header list to encode:

要编码的标题列表:

   :path: /sample/path
        
   :path: /sample/path
        

Hex dump of encoded data:

编码数据的十六进制转储:

040c 2f73 616d 706c 652f 7061 7468 | ../sample/path

040c 2f73 616d 706c 652f 7061 7468 |..样本/路径

Decoding process:

解码过程:

   04                                      | == Literal not indexed ==
                                           |   Indexed name (idx = 4)
                                           |     :path
   0c                                      |   Literal value (len = 12)
   2f73 616d 706c 652f 7061 7468           | /sample/path
                                           | -> :path: /sample/path
        
   04                                      | == Literal not indexed ==
                                           |   Indexed name (idx = 4)
                                           |     :path
   0c                                      |   Literal value (len = 12)
   2f73 616d 706c 652f 7061 7468           | /sample/path
                                           | -> :path: /sample/path
        

Dynamic table (after decoding): empty.

动态表(解码后):空。

Decoded header list:

解码标题列表:

   :path: /sample/path
        
   :path: /sample/path
        
C.2.3. Literal Header Field Never Indexed
C.2.3. 文字标题字段从未索引

The header field representation uses a literal name and a literal value. The header field is not added to the dynamic table and must use the same representation if re-encoded by an intermediary.

标题字段表示使用文字名称和文字值。标头字段不会添加到动态表中,如果由中间层重新编码,则必须使用相同的表示形式。

Header list to encode:

要编码的标题列表:

password: secret

密码:secret

Hex dump of encoded data:

编码数据的十六进制转储:

1008 7061 7373 776f 7264 0673 6563 7265 | ..password.secre 74 | t

1008 7061 7373 776f 7264 0673 6563 7265 |…password.secre 74 | t

Decoding process:

解码过程:

   10                                      | == Literal never indexed ==
   08                                      |   Literal name (len = 8)
   7061 7373 776f 7264                     | password
   06                                      |   Literal value (len = 6)
   7365 6372 6574                          | secret
                                           | -> password: secret
        
   10                                      | == Literal never indexed ==
   08                                      |   Literal name (len = 8)
   7061 7373 776f 7264                     | password
   06                                      |   Literal value (len = 6)
   7365 6372 6574                          | secret
                                           | -> password: secret
        

Dynamic table (after decoding): empty.

动态表(解码后):空。

Decoded header list:

解码标题列表:

password: secret

密码:secret

C.2.4. Indexed Header Field
C.2.4. 索引头字段

The header field representation uses an indexed header field from the static table.

标题字段表示使用静态表中的索引标题字段。

Header list to encode:

要编码的标题列表:

:method: GET

:方法:获取

Hex dump of encoded data:

编码数据的十六进制转储:

82 | .

82 | .

Decoding process:

解码过程:

   82                                      | == Indexed - Add ==
                                           |   idx = 2
                                           | -> :method: GET
        
   82                                      | == Indexed - Add ==
                                           |   idx = 2
                                           | -> :method: GET
        

Dynamic table (after decoding): empty.

动态表(解码后):空。

Decoded header list:

解码标题列表:

:method: GET

:方法:获取

C.3. Request Examples without Huffman Coding
C.3. 不使用哈夫曼编码的请求示例

This section shows several consecutive header lists, corresponding to HTTP requests, on the same connection.

本节显示了在同一连接上对应于HTTP请求的几个连续头列表。

C.3.1. First Request
C.3.1. 第一个请求

Header list to encode:

要编码的标题列表:

   :method: GET
   :scheme: http
   :path: /
   :authority: www.example.com
        
   :method: GET
   :scheme: http
   :path: /
   :authority: www.example.com
        

Hex dump of encoded data:

编码数据的十六进制转储:

8286 8441 0f77 7777 2e65 7861 6d70 6c65 | ...A.www.example 2e63 6f6d | .com

8286 8441 0f77 7777 2e65 7861 6d70 6c65 |…A.www.example 2e63 6f6d | com

Decoding process:

解码过程:

   82                                      | == Indexed - Add ==
                                           |   idx = 2
                                           | -> :method: GET
   86                                      | == Indexed - Add ==
                                           |   idx = 6
                                           | -> :scheme: http
   84                                      | == Indexed - Add ==
                                           |   idx = 4
                                           | -> :path: /
   41                                      | == Literal indexed ==
                                           |   Indexed name (idx = 1)
                                           |     :authority
   0f                                      |   Literal value (len = 15)
   7777 772e 6578 616d 706c 652e 636f 6d   | www.example.com
                                           | -> :authority:
                                           |   www.example.com
        
   82                                      | == Indexed - Add ==
                                           |   idx = 2
                                           | -> :method: GET
   86                                      | == Indexed - Add ==
                                           |   idx = 6
                                           | -> :scheme: http
   84                                      | == Indexed - Add ==
                                           |   idx = 4
                                           | -> :path: /
   41                                      | == Literal indexed ==
                                           |   Indexed name (idx = 1)
                                           |     :authority
   0f                                      |   Literal value (len = 15)
   7777 772e 6578 616d 706c 652e 636f 6d   | www.example.com
                                           | -> :authority:
                                           |   www.example.com
        

Dynamic Table (after decoding):

动态表(解码后):

   [  1] (s =  57) :authority: www.example.com
         Table size:  57
        
   [  1] (s =  57) :authority: www.example.com
         Table size:  57
        

Decoded header list:

解码标题列表:

   :method: GET
   :scheme: http
   :path: /
   :authority: www.example.com
        
   :method: GET
   :scheme: http
   :path: /
   :authority: www.example.com
        
C.3.2. Second Request
C.3.2. 第二个请求

Header list to encode:

要编码的标题列表:

   :method: GET
   :scheme: http
   :path: /
   :authority: www.example.com
   cache-control: no-cache
        
   :method: GET
   :scheme: http
   :path: /
   :authority: www.example.com
   cache-control: no-cache
        

Hex dump of encoded data:

编码数据的十六进制转储:

   8286 84be 5808 6e6f 2d63 6163 6865      | ....X.no-cache
        
   8286 84be 5808 6e6f 2d63 6163 6865      | ....X.no-cache
        

Decoding process:

解码过程:

   82                                      | == Indexed - Add ==
                                           |   idx = 2
                                           | -> :method: GET
   86                                      | == Indexed - Add ==
                                           |   idx = 6
                                           | -> :scheme: http
   84                                      | == Indexed - Add ==
                                           |   idx = 4
                                           | -> :path: /
   be                                      | == Indexed - Add ==
                                           |   idx = 62
                                           | -> :authority:
                                           |   www.example.com
   58                                      | == Literal indexed ==
                                           |   Indexed name (idx = 24)
                                           |     cache-control
   08                                      |   Literal value (len = 8)
   6e6f 2d63 6163 6865                     | no-cache
                                           | -> cache-control: no-cache
        
   82                                      | == Indexed - Add ==
                                           |   idx = 2
                                           | -> :method: GET
   86                                      | == Indexed - Add ==
                                           |   idx = 6
                                           | -> :scheme: http
   84                                      | == Indexed - Add ==
                                           |   idx = 4
                                           | -> :path: /
   be                                      | == Indexed - Add ==
                                           |   idx = 62
                                           | -> :authority:
                                           |   www.example.com
   58                                      | == Literal indexed ==
                                           |   Indexed name (idx = 24)
                                           |     cache-control
   08                                      |   Literal value (len = 8)
   6e6f 2d63 6163 6865                     | no-cache
                                           | -> cache-control: no-cache
        

Dynamic Table (after decoding):

动态表(解码后):

   [  1] (s =  53) cache-control: no-cache
   [  2] (s =  57) :authority: www.example.com
         Table size: 110
        
   [  1] (s =  53) cache-control: no-cache
   [  2] (s =  57) :authority: www.example.com
         Table size: 110
        

Decoded header list:

解码标题列表:

   :method: GET
   :scheme: http
   :path: /
   :authority: www.example.com
   cache-control: no-cache
        
   :method: GET
   :scheme: http
   :path: /
   :authority: www.example.com
   cache-control: no-cache
        
C.3.3. Third Request
C.3.3. 第三个请求

Header list to encode:

要编码的标题列表:

   :method: GET
   :scheme: https
   :path: /index.html
   :authority: www.example.com
   custom-key: custom-value
        
   :method: GET
   :scheme: https
   :path: /index.html
   :authority: www.example.com
   custom-key: custom-value
        

Hex dump of encoded data:

编码数据的十六进制转储:

   8287 85bf 400a 6375 7374 6f6d 2d6b 6579 | ....@.custom-key
   0c63 7573 746f 6d2d 7661 6c75 65        | .custom-value
        
   8287 85bf 400a 6375 7374 6f6d 2d6b 6579 | ....@.custom-key
   0c63 7573 746f 6d2d 7661 6c75 65        | .custom-value
        

Decoding process:

解码过程:

   82                                      | == Indexed - Add ==
                                           |   idx = 2
                                           | -> :method: GET
   87                                      | == Indexed - Add ==
                                           |   idx = 7
                                           | -> :scheme: https
   85                                      | == Indexed - Add ==
                                           |   idx = 5
                                           | -> :path: /index.html
   bf                                      | == Indexed - Add ==
                                           |   idx = 63
                                           | -> :authority:
                                           |   www.example.com
   40                                      | == Literal indexed ==
   0a                                      |   Literal name (len = 10)
   6375 7374 6f6d 2d6b 6579                | custom-key
   0c                                      |   Literal value (len = 12)
   6375 7374 6f6d 2d76 616c 7565           | custom-value
                                           | -> custom-key:
                                           |   custom-value
        
   82                                      | == Indexed - Add ==
                                           |   idx = 2
                                           | -> :method: GET
   87                                      | == Indexed - Add ==
                                           |   idx = 7
                                           | -> :scheme: https
   85                                      | == Indexed - Add ==
                                           |   idx = 5
                                           | -> :path: /index.html
   bf                                      | == Indexed - Add ==
                                           |   idx = 63
                                           | -> :authority:
                                           |   www.example.com
   40                                      | == Literal indexed ==
   0a                                      |   Literal name (len = 10)
   6375 7374 6f6d 2d6b 6579                | custom-key
   0c                                      |   Literal value (len = 12)
   6375 7374 6f6d 2d76 616c 7565           | custom-value
                                           | -> custom-key:
                                           |   custom-value
        

Dynamic Table (after decoding):

动态表(解码后):

   [  1] (s =  54) custom-key: custom-value
   [  2] (s =  53) cache-control: no-cache
   [  3] (s =  57) :authority: www.example.com
         Table size: 164
        
   [  1] (s =  54) custom-key: custom-value
   [  2] (s =  53) cache-control: no-cache
   [  3] (s =  57) :authority: www.example.com
         Table size: 164
        

Decoded header list:

解码标题列表:

   :method: GET
   :scheme: https
   :path: /index.html
   :authority: www.example.com
   custom-key: custom-value
        
   :method: GET
   :scheme: https
   :path: /index.html
   :authority: www.example.com
   custom-key: custom-value
        
C.4. Request Examples with Huffman Coding
C.4. 使用哈夫曼编码的请求示例

This section shows the same examples as the previous section but uses Huffman encoding for the literal values.

本节显示与上一节相同的示例,但对文字值使用哈夫曼编码。

C.4.1. First Request
C.4.1. 第一个请求

Header list to encode:

要编码的标题列表:

   :method: GET
   :scheme: http
   :path: /
   :authority: www.example.com
        
   :method: GET
   :scheme: http
   :path: /
   :authority: www.example.com
        

Hex dump of encoded data:

编码数据的十六进制转储:

   8286 8441 8cf1 e3c2 e5f2 3a6b a0ab 90f4 | ...A......:k....
   ff                                      | .
        
   8286 8441 8cf1 e3c2 e5f2 3a6b a0ab 90f4 | ...A......:k....
   ff                                      | .
        

Decoding process:

解码过程:

   82                                      | == Indexed - Add ==
                                           |   idx = 2
                                           | -> :method: GET
   86                                      | == Indexed - Add ==
                                           |   idx = 6
                                           | -> :scheme: http
   84                                      | == Indexed - Add ==
                                           |   idx = 4
                                           | -> :path: /
   41                                      | == Literal indexed ==
                                           |   Indexed name (idx = 1)
                                           |     :authority
   8c                                      |   Literal value (len = 12)
                                           |     Huffman encoded:
   f1e3 c2e5 f23a 6ba0 ab90 f4ff           | .....:k.....
                                           |     Decoded:
                                           | www.example.com
                                           | -> :authority:
                                           |   www.example.com
        
   82                                      | == Indexed - Add ==
                                           |   idx = 2
                                           | -> :method: GET
   86                                      | == Indexed - Add ==
                                           |   idx = 6
                                           | -> :scheme: http
   84                                      | == Indexed - Add ==
                                           |   idx = 4
                                           | -> :path: /
   41                                      | == Literal indexed ==
                                           |   Indexed name (idx = 1)
                                           |     :authority
   8c                                      |   Literal value (len = 12)
                                           |     Huffman encoded:
   f1e3 c2e5 f23a 6ba0 ab90 f4ff           | .....:k.....
                                           |     Decoded:
                                           | www.example.com
                                           | -> :authority:
                                           |   www.example.com
        

Dynamic Table (after decoding):

动态表(解码后):

   [  1] (s =  57) :authority: www.example.com
         Table size:  57
        
   [  1] (s =  57) :authority: www.example.com
         Table size:  57
        

Decoded header list:

解码标题列表:

   :method: GET
   :scheme: http
   :path: /
   :authority: www.example.com
        
   :method: GET
   :scheme: http
   :path: /
   :authority: www.example.com
        
C.4.2. Second Request
C.4.2. 第二个请求

Header list to encode:

要编码的标题列表:

   :method: GET
   :scheme: http
   :path: /
   :authority: www.example.com
   cache-control: no-cache
        
   :method: GET
   :scheme: http
   :path: /
   :authority: www.example.com
   cache-control: no-cache
        

Hex dump of encoded data:

编码数据的十六进制转储:

   8286 84be 5886 a8eb 1064 9cbf           | ....X....d..
        
   8286 84be 5886 a8eb 1064 9cbf           | ....X....d..
        

Decoding process:

解码过程:

   82                                      | == Indexed - Add ==
                                           |   idx = 2
                                           | -> :method: GET
   86                                      | == Indexed - Add ==
                                           |   idx = 6
                                           | -> :scheme: http
   84                                      | == Indexed - Add ==
                                           |   idx = 4
                                           | -> :path: /
   be                                      | == Indexed - Add ==
                                           |   idx = 62
                                           | -> :authority:
                                           |   www.example.com
   58                                      | == Literal indexed ==
                                           |   Indexed name (idx = 24)
                                           |     cache-control
   86                                      |   Literal value (len = 6)
                                           |     Huffman encoded:
   a8eb 1064 9cbf                          | ...d..
                                           |     Decoded:
                                           | no-cache
                                           | -> cache-control: no-cache
        
   82                                      | == Indexed - Add ==
                                           |   idx = 2
                                           | -> :method: GET
   86                                      | == Indexed - Add ==
                                           |   idx = 6
                                           | -> :scheme: http
   84                                      | == Indexed - Add ==
                                           |   idx = 4
                                           | -> :path: /
   be                                      | == Indexed - Add ==
                                           |   idx = 62
                                           | -> :authority:
                                           |   www.example.com
   58                                      | == Literal indexed ==
                                           |   Indexed name (idx = 24)
                                           |     cache-control
   86                                      |   Literal value (len = 6)
                                           |     Huffman encoded:
   a8eb 1064 9cbf                          | ...d..
                                           |     Decoded:
                                           | no-cache
                                           | -> cache-control: no-cache
        

Dynamic Table (after decoding):

动态表(解码后):

   [  1] (s =  53) cache-control: no-cache
   [  2] (s =  57) :authority: www.example.com
         Table size: 110
        
   [  1] (s =  53) cache-control: no-cache
   [  2] (s =  57) :authority: www.example.com
         Table size: 110
        

Decoded header list:

解码标题列表:

   :method: GET
   :scheme: http
   :path: /
   :authority: www.example.com
   cache-control: no-cache
        
   :method: GET
   :scheme: http
   :path: /
   :authority: www.example.com
   cache-control: no-cache
        
C.4.3. Third Request
C.4.3. 第三个请求

Header list to encode:

要编码的标题列表:

   :method: GET
   :scheme: https
   :path: /index.html
   :authority: www.example.com
   custom-key: custom-value
        
   :method: GET
   :scheme: https
   :path: /index.html
   :authority: www.example.com
   custom-key: custom-value
        

Hex dump of encoded data:

编码数据的十六进制转储:

   8287 85bf 4088 25a8 49e9 5ba9 7d7f 8925 | ....@.%.I.[.}..%
   a849 e95b b8e8 b4bf                     | .I.[....
        
   8287 85bf 4088 25a8 49e9 5ba9 7d7f 8925 | ....@.%.I.[.}..%
   a849 e95b b8e8 b4bf                     | .I.[....
        

Decoding process:

解码过程:

   82                                      | == Indexed - Add ==
                                           |   idx = 2
                                           | -> :method: GET
   87                                      | == Indexed - Add ==
                                           |   idx = 7
                                           | -> :scheme: https
   85                                      | == Indexed - Add ==
                                           |   idx = 5
                                           | -> :path: /index.html
   bf                                      | == Indexed - Add ==
                                           |   idx = 63
                                           | -> :authority:
                                           |   www.example.com
   40                                      | == Literal indexed ==
   88                                      |   Literal name (len = 8)
                                           |     Huffman encoded:
   25a8 49e9 5ba9 7d7f                     | %.I.[.}.
                                           |     Decoded:
                                           | custom-key
   89                                      |   Literal value (len = 9)
                                           |     Huffman encoded:
   25a8 49e9 5bb8 e8b4 bf                  | %.I.[....
                                           |     Decoded:
                                           | custom-value
                                           | -> custom-key:
                                           |   custom-value
        
   82                                      | == Indexed - Add ==
                                           |   idx = 2
                                           | -> :method: GET
   87                                      | == Indexed - Add ==
                                           |   idx = 7
                                           | -> :scheme: https
   85                                      | == Indexed - Add ==
                                           |   idx = 5
                                           | -> :path: /index.html
   bf                                      | == Indexed - Add ==
                                           |   idx = 63
                                           | -> :authority:
                                           |   www.example.com
   40                                      | == Literal indexed ==
   88                                      |   Literal name (len = 8)
                                           |     Huffman encoded:
   25a8 49e9 5ba9 7d7f                     | %.I.[.}.
                                           |     Decoded:
                                           | custom-key
   89                                      |   Literal value (len = 9)
                                           |     Huffman encoded:
   25a8 49e9 5bb8 e8b4 bf                  | %.I.[....
                                           |     Decoded:
                                           | custom-value
                                           | -> custom-key:
                                           |   custom-value
        

Dynamic Table (after decoding):

动态表(解码后):

   [  1] (s =  54) custom-key: custom-value
   [  2] (s =  53) cache-control: no-cache
   [  3] (s =  57) :authority: www.example.com
         Table size: 164
        
   [  1] (s =  54) custom-key: custom-value
   [  2] (s =  53) cache-control: no-cache
   [  3] (s =  57) :authority: www.example.com
         Table size: 164
        

Decoded header list:

解码标题列表:

   :method: GET
   :scheme: https
   :path: /index.html
   :authority: www.example.com
   custom-key: custom-value
        
   :method: GET
   :scheme: https
   :path: /index.html
   :authority: www.example.com
   custom-key: custom-value
        
C.5. Response Examples without Huffman Coding
C.5. 无霍夫曼编码的响应示例

This section shows several consecutive header lists, corresponding to HTTP responses, on the same connection. The HTTP/2 setting parameter SETTINGS_HEADER_TABLE_SIZE is set to the value of 256 octets, causing some evictions to occur.

本节显示了同一连接上与HTTP响应相对应的几个连续头列表。HTTP/2设置参数SETTINGS\u HEADER\u TABLE\u SIZE被设置为256个八位字节的值,导致发生一些逐出。

C.5.1. First Response
C.5.1. 第一反应

Header list to encode:

要编码的标题列表:

   :status: 302
   cache-control: private
   date: Mon, 21 Oct 2013 20:13:21 GMT
   location: https://www.example.com
        
   :status: 302
   cache-control: private
   date: Mon, 21 Oct 2013 20:13:21 GMT
   location: https://www.example.com
        

Hex dump of encoded data:

编码数据的十六进制转储:

4803 3330 3258 0770 7269 7661 7465 611d | H.302X.privatea. 4d6f 6e2c 2032 3120 4f63 7420 3230 3133 | Mon, 21 Oct 2013 2032 303a 3133 3a32 3120 474d 546e 1768 | 20:13:21 GMTn.h 7474 7073 3a2f 2f77 7777 2e65 7861 6d70 | ttps://www.examp 6c65 2e63 6f6d | le.com

4803 3330 3258 0770 7269 7661 7465 611d | H.302X.privatea。4d6f 6e2c 2032 3120 4f63 7420 3230 3133 | 2013年10月21日星期一2032 303a 3133 3a32 3120 474d 546e 1768 | 20:13:21 GMTn.h 7474 7073 3a2f 2f77 777 2e65 7861 6d70 |ttps://www.examp 6c65 2e63 6f6d|le.com

Decoding process:

解码过程:

   48                                      | == Literal indexed ==
                                           |   Indexed name (idx = 8)
                                           |     :status
   03                                      |   Literal value (len = 3)
   3330 32                                 | 302
                                           | -> :status: 302
   58                                      | == Literal indexed ==
                                           |   Indexed name (idx = 24)
                                           |     cache-control
   07                                      |   Literal value (len = 7)
   7072 6976 6174 65                       | private
                                           | -> cache-control: private
   61                                      | == Literal indexed ==
                                           |   Indexed name (idx = 33)
                                           |     date
   1d                                      |   Literal value (len = 29)
   4d6f 6e2c 2032 3120 4f63 7420 3230 3133 | Mon, 21 Oct 2013
   2032 303a 3133 3a32 3120 474d 54        |  20:13:21 GMT
                                           | -> date: Mon, 21 Oct 2013
                                           |   20:13:21 GMT
   6e                                      | == Literal indexed ==
                                           |   Indexed name (idx = 46)
        
   48                                      | == Literal indexed ==
                                           |   Indexed name (idx = 8)
                                           |     :status
   03                                      |   Literal value (len = 3)
   3330 32                                 | 302
                                           | -> :status: 302
   58                                      | == Literal indexed ==
                                           |   Indexed name (idx = 24)
                                           |     cache-control
   07                                      |   Literal value (len = 7)
   7072 6976 6174 65                       | private
                                           | -> cache-control: private
   61                                      | == Literal indexed ==
                                           |   Indexed name (idx = 33)
                                           |     date
   1d                                      |   Literal value (len = 29)
   4d6f 6e2c 2032 3120 4f63 7420 3230 3133 | Mon, 21 Oct 2013
   2032 303a 3133 3a32 3120 474d 54        |  20:13:21 GMT
                                           | -> date: Mon, 21 Oct 2013
                                           |   20:13:21 GMT
   6e                                      | == Literal indexed ==
                                           |   Indexed name (idx = 46)
        
                                           |     location
   17                                      |   Literal value (len = 23)
   6874 7470 733a 2f2f 7777 772e 6578 616d | https://www.exam
   706c 652e 636f 6d                       | ple.com
                                           | -> location:
                                           |   https://www.example.com
        
                                           |     location
   17                                      |   Literal value (len = 23)
   6874 7470 733a 2f2f 7777 772e 6578 616d | https://www.exam
   706c 652e 636f 6d                       | ple.com
                                           | -> location:
                                           |   https://www.example.com
        

Dynamic Table (after decoding):

动态表(解码后):

   [  1] (s =  63) location: https://www.example.com
   [  2] (s =  65) date: Mon, 21 Oct 2013 20:13:21 GMT
   [  3] (s =  52) cache-control: private
   [  4] (s =  42) :status: 302
         Table size: 222
        
   [  1] (s =  63) location: https://www.example.com
   [  2] (s =  65) date: Mon, 21 Oct 2013 20:13:21 GMT
   [  3] (s =  52) cache-control: private
   [  4] (s =  42) :status: 302
         Table size: 222
        

Decoded header list:

解码标题列表:

   :status: 302
   cache-control: private
   date: Mon, 21 Oct 2013 20:13:21 GMT
   location: https://www.example.com
        
   :status: 302
   cache-control: private
   date: Mon, 21 Oct 2013 20:13:21 GMT
   location: https://www.example.com
        
C.5.2. Second Response
C.5.2. 第二反应

The (":status", "302") header field is evicted from the dynamic table to free space to allow adding the (":status", "307") header field.

将(“:status”,“302”)头字段从动态表中移出以释放空间,以允许添加(“:status”,“307”)头字段。

Header list to encode:

要编码的标题列表:

   :status: 307
   cache-control: private
   date: Mon, 21 Oct 2013 20:13:21 GMT
   location: https://www.example.com
        
   :status: 307
   cache-control: private
   date: Mon, 21 Oct 2013 20:13:21 GMT
   location: https://www.example.com
        

Hex dump of encoded data:

编码数据的十六进制转储:

4803 3330 37c1 c0bf | H.307...

4803 3330 37c1 c0bf | H.307。。。

Decoding process:

解码过程:

   48                                      | == Literal indexed ==
                                           |   Indexed name (idx = 8)
                                           |     :status
   03                                      |   Literal value (len = 3)
   3330 37                                 | 307
                                           | - evict: :status: 302
                                           | -> :status: 307
   c1                                      | == Indexed - Add ==
        
   48                                      | == Literal indexed ==
                                           |   Indexed name (idx = 8)
                                           |     :status
   03                                      |   Literal value (len = 3)
   3330 37                                 | 307
                                           | - evict: :status: 302
                                           | -> :status: 307
   c1                                      | == Indexed - Add ==
        
                                           |   idx = 65
                                           | -> cache-control: private
   c0                                      | == Indexed - Add ==
                                           |   idx = 64
                                           | -> date: Mon, 21 Oct 2013
                                           |   20:13:21 GMT
   bf                                      | == Indexed - Add ==
                                           |   idx = 63
                                           | -> location:
                                           |   https://www.example.com
        
                                           |   idx = 65
                                           | -> cache-control: private
   c0                                      | == Indexed - Add ==
                                           |   idx = 64
                                           | -> date: Mon, 21 Oct 2013
                                           |   20:13:21 GMT
   bf                                      | == Indexed - Add ==
                                           |   idx = 63
                                           | -> location:
                                           |   https://www.example.com
        

Dynamic Table (after decoding):

动态表(解码后):

   [  1] (s =  42) :status: 307
   [  2] (s =  63) location: https://www.example.com
   [  3] (s =  65) date: Mon, 21 Oct 2013 20:13:21 GMT
   [  4] (s =  52) cache-control: private
         Table size: 222
        
   [  1] (s =  42) :status: 307
   [  2] (s =  63) location: https://www.example.com
   [  3] (s =  65) date: Mon, 21 Oct 2013 20:13:21 GMT
   [  4] (s =  52) cache-control: private
         Table size: 222
        

Decoded header list:

解码标题列表:

   :status: 307
   cache-control: private
   date: Mon, 21 Oct 2013 20:13:21 GMT
   location: https://www.example.com
        
   :status: 307
   cache-control: private
   date: Mon, 21 Oct 2013 20:13:21 GMT
   location: https://www.example.com
        
C.5.3. Third Response
C.5.3. 第三反应

Several header fields are evicted from the dynamic table during the processing of this header list.

在处理此标题列表的过程中,会从动态表中逐出多个标题字段。

Header list to encode:

要编码的标题列表:

   :status: 200
   cache-control: private
   date: Mon, 21 Oct 2013 20:13:22 GMT
   location: https://www.example.com
   content-encoding: gzip
   set-cookie: foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1
        
   :status: 200
   cache-control: private
   date: Mon, 21 Oct 2013 20:13:22 GMT
   location: https://www.example.com
   content-encoding: gzip
   set-cookie: foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1
        

Hex dump of encoded data:

编码数据的十六进制转储:

88c1 611d 4d6f 6e2c 2032 3120 4f63 7420 | ..a.Mon, 21 Oct 3230 3133 2032 303a 3133 3a32 3220 474d | 2013 20:13:22 GM 54c0 5a04 677a 6970 7738 666f 6f3d 4153 | T.Z.gzipw8foo=AS 444a 4b48 514b 425a 584f 5157 454f 5049 | DJKHQKBZXOQWEOPI 5541 5851 5745 4f49 553b 206d 6178 2d61 | UAXQWEOIU; max-a 6765 3d33 3630 303b 2076 6572 7369 6f6e | ge=3600; version 3d31 | =1

88c1 611d 4d6f 6e2c 2032 3120 4f63 7420 | a.Mon,10月21日3230 3133 2032 303a 3133 3A332 3220 474d | 2013 20:13:22 GM 54c0 5a04 677a 6970 7738 66F 6f3d 4153 | T.Z.gzipw8foo=AS 444a 4b48 514b 425a 584f 5157 454f 5049 | Djkhqxoweopi 5541 5851 5745 4f49 556D 618 |;max-a 6765 3d33 3630 303b 2076 6572 7369 6f6e | ge=3600;版本3d31 |=1

Decoding process:

解码过程:

   88                                      | == Indexed - Add ==
                                           |   idx = 8
                                           | -> :status: 200
   c1                                      | == Indexed - Add ==
                                           |   idx = 65
                                           | -> cache-control: private
   61                                      | == Literal indexed ==
                                           |   Indexed name (idx = 33)
                                           |     date
   1d                                      |   Literal value (len = 29)
   4d6f 6e2c 2032 3120 4f63 7420 3230 3133 | Mon, 21 Oct 2013
   2032 303a 3133 3a32 3220 474d 54        |  20:13:22 GMT
                                           | - evict: cache-control:
                                           |   private
                                           | -> date: Mon, 21 Oct 2013
                                           |   20:13:22 GMT
   c0                                      | == Indexed - Add ==
                                           |   idx = 64
                                           | -> location:
                                           |   https://www.example.com
   5a                                      | == Literal indexed ==
                                           |   Indexed name (idx = 26)
                                           |     content-encoding
   04                                      |   Literal value (len = 4)
   677a 6970                               | gzip
                                           | - evict: date: Mon, 21 Oct
                                           |    2013 20:13:21 GMT
                                           | -> content-encoding: gzip
   77                                      | == Literal indexed ==
                                           |   Indexed name (idx = 55)
                                           |     set-cookie
   38                                      |   Literal value (len = 56)
   666f 6f3d 4153 444a 4b48 514b 425a 584f | foo=ASDJKHQKBZXO
   5157 454f 5049 5541 5851 5745 4f49 553b | QWEOPIUAXQWEOIU;
   206d 6178 2d61 6765 3d33 3630 303b 2076 |  max-age=3600; v
   6572 7369 6f6e 3d31                     | ersion=1
        
   88                                      | == Indexed - Add ==
                                           |   idx = 8
                                           | -> :status: 200
   c1                                      | == Indexed - Add ==
                                           |   idx = 65
                                           | -> cache-control: private
   61                                      | == Literal indexed ==
                                           |   Indexed name (idx = 33)
                                           |     date
   1d                                      |   Literal value (len = 29)
   4d6f 6e2c 2032 3120 4f63 7420 3230 3133 | Mon, 21 Oct 2013
   2032 303a 3133 3a32 3220 474d 54        |  20:13:22 GMT
                                           | - evict: cache-control:
                                           |   private
                                           | -> date: Mon, 21 Oct 2013
                                           |   20:13:22 GMT
   c0                                      | == Indexed - Add ==
                                           |   idx = 64
                                           | -> location:
                                           |   https://www.example.com
   5a                                      | == Literal indexed ==
                                           |   Indexed name (idx = 26)
                                           |     content-encoding
   04                                      |   Literal value (len = 4)
   677a 6970                               | gzip
                                           | - evict: date: Mon, 21 Oct
                                           |    2013 20:13:21 GMT
                                           | -> content-encoding: gzip
   77                                      | == Literal indexed ==
                                           |   Indexed name (idx = 55)
                                           |     set-cookie
   38                                      |   Literal value (len = 56)
   666f 6f3d 4153 444a 4b48 514b 425a 584f | foo=ASDJKHQKBZXO
   5157 454f 5049 5541 5851 5745 4f49 553b | QWEOPIUAXQWEOIU;
   206d 6178 2d61 6765 3d33 3630 303b 2076 |  max-age=3600; v
   6572 7369 6f6e 3d31                     | ersion=1
        
                                           | - evict: location:
                                           |   https://www.example.com
                                           | - evict: :status: 307
                                           | -> set-cookie: foo=ASDJKHQ
                                           |   KBZXOQWEOPIUAXQWEOIU; ma
                                           |   x-age=3600; version=1
        
                                           | - evict: location:
                                           |   https://www.example.com
                                           | - evict: :status: 307
                                           | -> set-cookie: foo=ASDJKHQ
                                           |   KBZXOQWEOPIUAXQWEOIU; ma
                                           |   x-age=3600; version=1
        

Dynamic Table (after decoding):

动态表(解码后):

   [  1] (s =  98) set-cookie: foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU;
                    max-age=3600; version=1
   [  2] (s =  52) content-encoding: gzip
   [  3] (s =  65) date: Mon, 21 Oct 2013 20:13:22 GMT
         Table size: 215
        
   [  1] (s =  98) set-cookie: foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU;
                    max-age=3600; version=1
   [  2] (s =  52) content-encoding: gzip
   [  3] (s =  65) date: Mon, 21 Oct 2013 20:13:22 GMT
         Table size: 215
        

Decoded header list:

解码标题列表:

   :status: 200
   cache-control: private
   date: Mon, 21 Oct 2013 20:13:22 GMT
   location: https://www.example.com
   content-encoding: gzip
   set-cookie: foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1
        
   :status: 200
   cache-control: private
   date: Mon, 21 Oct 2013 20:13:22 GMT
   location: https://www.example.com
   content-encoding: gzip
   set-cookie: foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1
        
C.6. Response Examples with Huffman Coding
C.6. 使用哈夫曼编码的响应示例

This section shows the same examples as the previous section but uses Huffman encoding for the literal values. The HTTP/2 setting parameter SETTINGS_HEADER_TABLE_SIZE is set to the value of 256 octets, causing some evictions to occur. The eviction mechanism uses the length of the decoded literal values, so the same evictions occur as in the previous section.

本节显示与上一节相同的示例,但对文字值使用哈夫曼编码。HTTP/2设置参数SETTINGS\u HEADER\u TABLE\u SIZE被设置为256个八位字节的值,导致发生一些逐出。逐出机制使用解码的文本值的长度,因此发生与上一节相同的逐出。

C.6.1. First Response
C.6.1. 第一反应

Header list to encode:

要编码的标题列表:

   :status: 302
   cache-control: private
   date: Mon, 21 Oct 2013 20:13:21 GMT
   location: https://www.example.com
        
   :status: 302
   cache-control: private
   date: Mon, 21 Oct 2013 20:13:21 GMT
   location: https://www.example.com
        

Hex dump of encoded data:

编码数据的十六进制转储:

   4882 6402 5885 aec3 771a 4b61 96d0 7abe | H.d.X...w.Ka..z.
   9410 54d4 44a8 2005 9504 0b81 66e0 82a6 | ..T.D. .....f...
   2d1b ff6e 919d 29ad 1718 63c7 8f0b 97c8 | -..n..)...c.....
   e9ae 82ae 43d3                          | ....C.
        
   4882 6402 5885 aec3 771a 4b61 96d0 7abe | H.d.X...w.Ka..z.
   9410 54d4 44a8 2005 9504 0b81 66e0 82a6 | ..T.D. .....f...
   2d1b ff6e 919d 29ad 1718 63c7 8f0b 97c8 | -..n..)...c.....
   e9ae 82ae 43d3                          | ....C.
        

Decoding process:

解码过程:

   48                                      | == Literal indexed ==
                                           |   Indexed name (idx = 8)
                                           |     :status
   82                                      |   Literal value (len = 2)
                                           |     Huffman encoded:
   6402                                    | d.
                                           |     Decoded:
                                           | 302
                                           | -> :status: 302
   58                                      | == Literal indexed ==
                                           |   Indexed name (idx = 24)
                                           |     cache-control
   85                                      |   Literal value (len = 5)
                                           |     Huffman encoded:
   aec3 771a 4b                            | ..w.K
                                           |     Decoded:
                                           | private
                                           | -> cache-control: private
   61                                      | == Literal indexed ==
                                           |   Indexed name (idx = 33)
                                           |     date
   96                                      |   Literal value (len = 22)
                                           |     Huffman encoded:
   d07a be94 1054 d444 a820 0595 040b 8166 | .z...T.D. .....f
   e082 a62d 1bff                          | ...-..
                                           |     Decoded:
                                           | Mon, 21 Oct 2013 20:13:21
                                           | GMT
                                           | -> date: Mon, 21 Oct 2013
                                           |   20:13:21 GMT
   6e                                      | == Literal indexed ==
                                           |   Indexed name (idx = 46)
                                           |     location
   91                                      |   Literal value (len = 17)
                                           |     Huffman encoded:
   9d29 ad17 1863 c78f 0b97 c8e9 ae82 ae43 | .)...c.........C
   d3                                      | .
                                           |     Decoded:
                                           | https://www.example.com
                                           | -> location:
                                           |   https://www.example.com
        
   48                                      | == Literal indexed ==
                                           |   Indexed name (idx = 8)
                                           |     :status
   82                                      |   Literal value (len = 2)
                                           |     Huffman encoded:
   6402                                    | d.
                                           |     Decoded:
                                           | 302
                                           | -> :status: 302
   58                                      | == Literal indexed ==
                                           |   Indexed name (idx = 24)
                                           |     cache-control
   85                                      |   Literal value (len = 5)
                                           |     Huffman encoded:
   aec3 771a 4b                            | ..w.K
                                           |     Decoded:
                                           | private
                                           | -> cache-control: private
   61                                      | == Literal indexed ==
                                           |   Indexed name (idx = 33)
                                           |     date
   96                                      |   Literal value (len = 22)
                                           |     Huffman encoded:
   d07a be94 1054 d444 a820 0595 040b 8166 | .z...T.D. .....f
   e082 a62d 1bff                          | ...-..
                                           |     Decoded:
                                           | Mon, 21 Oct 2013 20:13:21
                                           | GMT
                                           | -> date: Mon, 21 Oct 2013
                                           |   20:13:21 GMT
   6e                                      | == Literal indexed ==
                                           |   Indexed name (idx = 46)
                                           |     location
   91                                      |   Literal value (len = 17)
                                           |     Huffman encoded:
   9d29 ad17 1863 c78f 0b97 c8e9 ae82 ae43 | .)...c.........C
   d3                                      | .
                                           |     Decoded:
                                           | https://www.example.com
                                           | -> location:
                                           |   https://www.example.com
        

Dynamic Table (after decoding):

动态表(解码后):

   [  1] (s =  63) location: https://www.example.com
   [  2] (s =  65) date: Mon, 21 Oct 2013 20:13:21 GMT
   [  3] (s =  52) cache-control: private
   [  4] (s =  42) :status: 302
         Table size: 222
        
   [  1] (s =  63) location: https://www.example.com
   [  2] (s =  65) date: Mon, 21 Oct 2013 20:13:21 GMT
   [  3] (s =  52) cache-control: private
   [  4] (s =  42) :status: 302
         Table size: 222
        

Decoded header list:

解码标题列表:

   :status: 302
   cache-control: private
   date: Mon, 21 Oct 2013 20:13:21 GMT
   location: https://www.example.com
        
   :status: 302
   cache-control: private
   date: Mon, 21 Oct 2013 20:13:21 GMT
   location: https://www.example.com
        
C.6.2. Second Response
C.6.2. 第二反应

The (":status", "302") header field is evicted from the dynamic table to free space to allow adding the (":status", "307") header field.

将(“:status”,“302”)头字段从动态表中移出以释放空间,以允许添加(“:status”,“307”)头字段。

Header list to encode:

要编码的标题列表:

   :status: 307
   cache-control: private
   date: Mon, 21 Oct 2013 20:13:21 GMT
   location: https://www.example.com
        
   :status: 307
   cache-control: private
   date: Mon, 21 Oct 2013 20:13:21 GMT
   location: https://www.example.com
        

Hex dump of encoded data:

编码数据的十六进制转储:

   4883 640e ffc1 c0bf                     | H.d.....
        
   4883 640e ffc1 c0bf                     | H.d.....
        

Decoding process:

解码过程:

   48                                      | == Literal indexed ==
                                           |   Indexed name (idx = 8)
                                           |     :status
   83                                      |   Literal value (len = 3)
                                           |     Huffman encoded:
   640e ff                                 | d..
                                           |     Decoded:
                                           | 307
                                           | - evict: :status: 302
                                           | -> :status: 307
   c1                                      | == Indexed - Add ==
                                           |   idx = 65
                                           | -> cache-control: private
   c0                                      | == Indexed - Add ==
                                           |   idx = 64
        
   48                                      | == Literal indexed ==
                                           |   Indexed name (idx = 8)
                                           |     :status
   83                                      |   Literal value (len = 3)
                                           |     Huffman encoded:
   640e ff                                 | d..
                                           |     Decoded:
                                           | 307
                                           | - evict: :status: 302
                                           | -> :status: 307
   c1                                      | == Indexed - Add ==
                                           |   idx = 65
                                           | -> cache-control: private
   c0                                      | == Indexed - Add ==
                                           |   idx = 64
        
                                           | -> date: Mon, 21 Oct 2013
                                           |   20:13:21 GMT
   bf                                      | == Indexed - Add ==
                                           |   idx = 63
                                           | -> location:
                                           |   https://www.example.com
        
                                           | -> date: Mon, 21 Oct 2013
                                           |   20:13:21 GMT
   bf                                      | == Indexed - Add ==
                                           |   idx = 63
                                           | -> location:
                                           |   https://www.example.com
        

Dynamic Table (after decoding):

动态表(解码后):

   [  1] (s =  42) :status: 307
   [  2] (s =  63) location: https://www.example.com
   [  3] (s =  65) date: Mon, 21 Oct 2013 20:13:21 GMT
   [  4] (s =  52) cache-control: private
         Table size: 222
        
   [  1] (s =  42) :status: 307
   [  2] (s =  63) location: https://www.example.com
   [  3] (s =  65) date: Mon, 21 Oct 2013 20:13:21 GMT
   [  4] (s =  52) cache-control: private
         Table size: 222
        

Decoded header list:

解码标题列表:

   :status: 307
   cache-control: private
   date: Mon, 21 Oct 2013 20:13:21 GMT
   location: https://www.example.com
        
   :status: 307
   cache-control: private
   date: Mon, 21 Oct 2013 20:13:21 GMT
   location: https://www.example.com
        
C.6.3. Third Response
C.6.3. 第三反应

Several header fields are evicted from the dynamic table during the processing of this header list.

在处理此标题列表的过程中,会从动态表中逐出多个标题字段。

Header list to encode:

要编码的标题列表:

   :status: 200
   cache-control: private
   date: Mon, 21 Oct 2013 20:13:22 GMT
   location: https://www.example.com
   content-encoding: gzip
   set-cookie: foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1
        
   :status: 200
   cache-control: private
   date: Mon, 21 Oct 2013 20:13:22 GMT
   location: https://www.example.com
   content-encoding: gzip
   set-cookie: foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1
        

Hex dump of encoded data:

编码数据的十六进制转储:

   88c1 6196 d07a be94 1054 d444 a820 0595 | ..a..z...T.D. ..
   040b 8166 e084 a62d 1bff c05a 839b d9ab | ...f...-...Z....
   77ad 94e7 821d d7f2 e6c7 b335 dfdf cd5b | w..........5...[
   3960 d5af 2708 7f36 72c1 ab27 0fb5 291f | 9`..'..6r..'..).
   9587 3160 65c0 03ed 4ee5 b106 3d50 07   | ..1`e...N...=P.
        
   88c1 6196 d07a be94 1054 d444 a820 0595 | ..a..z...T.D. ..
   040b 8166 e084 a62d 1bff c05a 839b d9ab | ...f...-...Z....
   77ad 94e7 821d d7f2 e6c7 b335 dfdf cd5b | w..........5...[
   3960 d5af 2708 7f36 72c1 ab27 0fb5 291f | 9`..'..6r..'..).
   9587 3160 65c0 03ed 4ee5 b106 3d50 07   | ..1`e...N...=P.
        

Decoding process:

解码过程:

   88                                      | == Indexed - Add ==
                                           |   idx = 8
                                           | -> :status: 200
   c1                                      | == Indexed - Add ==
                                           |   idx = 65
                                           | -> cache-control: private
   61                                      | == Literal indexed ==
                                           |   Indexed name (idx = 33)
                                           |     date
   96                                      |   Literal value (len = 22)
                                           |     Huffman encoded:
   d07a be94 1054 d444 a820 0595 040b 8166 | .z...T.D. .....f
   e084 a62d 1bff                          | ...-..
                                           |     Decoded:
                                           | Mon, 21 Oct 2013 20:13:22
                                           | GMT
                                           | - evict: cache-control:
                                           |   private
                                           | -> date: Mon, 21 Oct 2013
                                           |   20:13:22 GMT
   c0                                      | == Indexed - Add ==
                                           |   idx = 64
                                           | -> location:
                                           |   https://www.example.com
   5a                                      | == Literal indexed ==
                                           |   Indexed name (idx = 26)
                                           |     content-encoding
   83                                      |   Literal value (len = 3)
                                           |     Huffman encoded:
   9bd9 ab                                 | ...
                                           |     Decoded:
                                           | gzip
                                           | - evict: date: Mon, 21 Oct
                                           |    2013 20:13:21 GMT
                                           | -> content-encoding: gzip
   77                                      | == Literal indexed ==
                                           |   Indexed name (idx = 55)
                                           |     set-cookie
   ad                                      |   Literal value (len = 45)
                                           |     Huffman encoded:
   94e7 821d d7f2 e6c7 b335 dfdf cd5b 3960 | .........5...[9`
   d5af 2708 7f36 72c1 ab27 0fb5 291f 9587 | ..'..6r..'..)...
   3160 65c0 03ed 4ee5 b106 3d50 07        | 1`e...N...=P.
                                           |     Decoded:
                                           | foo=ASDJKHQKBZXOQWEOPIUAXQ
                                           | WEOIU; max-age=3600; versi
        
   88                                      | == Indexed - Add ==
                                           |   idx = 8
                                           | -> :status: 200
   c1                                      | == Indexed - Add ==
                                           |   idx = 65
                                           | -> cache-control: private
   61                                      | == Literal indexed ==
                                           |   Indexed name (idx = 33)
                                           |     date
   96                                      |   Literal value (len = 22)
                                           |     Huffman encoded:
   d07a be94 1054 d444 a820 0595 040b 8166 | .z...T.D. .....f
   e084 a62d 1bff                          | ...-..
                                           |     Decoded:
                                           | Mon, 21 Oct 2013 20:13:22
                                           | GMT
                                           | - evict: cache-control:
                                           |   private
                                           | -> date: Mon, 21 Oct 2013
                                           |   20:13:22 GMT
   c0                                      | == Indexed - Add ==
                                           |   idx = 64
                                           | -> location:
                                           |   https://www.example.com
   5a                                      | == Literal indexed ==
                                           |   Indexed name (idx = 26)
                                           |     content-encoding
   83                                      |   Literal value (len = 3)
                                           |     Huffman encoded:
   9bd9 ab                                 | ...
                                           |     Decoded:
                                           | gzip
                                           | - evict: date: Mon, 21 Oct
                                           |    2013 20:13:21 GMT
                                           | -> content-encoding: gzip
   77                                      | == Literal indexed ==
                                           |   Indexed name (idx = 55)
                                           |     set-cookie
   ad                                      |   Literal value (len = 45)
                                           |     Huffman encoded:
   94e7 821d d7f2 e6c7 b335 dfdf cd5b 3960 | .........5...[9`
   d5af 2708 7f36 72c1 ab27 0fb5 291f 9587 | ..'..6r..'..)...
   3160 65c0 03ed 4ee5 b106 3d50 07        | 1`e...N...=P.
                                           |     Decoded:
                                           | foo=ASDJKHQKBZXOQWEOPIUAXQ
                                           | WEOIU; max-age=3600; versi
        
                                           | on=1
                                           | - evict: location:
                                           |   https://www.example.com
                                           | - evict: :status: 307
                                           | -> set-cookie: foo=ASDJKHQ
                                           |   KBZXOQWEOPIUAXQWEOIU; ma
                                           |   x-age=3600; version=1
        
                                           | on=1
                                           | - evict: location:
                                           |   https://www.example.com
                                           | - evict: :status: 307
                                           | -> set-cookie: foo=ASDJKHQ
                                           |   KBZXOQWEOPIUAXQWEOIU; ma
                                           |   x-age=3600; version=1
        

Dynamic Table (after decoding):

动态表(解码后):

   [  1] (s =  98) set-cookie: foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU;
                    max-age=3600; version=1
   [  2] (s =  52) content-encoding: gzip
   [  3] (s =  65) date: Mon, 21 Oct 2013 20:13:22 GMT
         Table size: 215
        
   [  1] (s =  98) set-cookie: foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU;
                    max-age=3600; version=1
   [  2] (s =  52) content-encoding: gzip
   [  3] (s =  65) date: Mon, 21 Oct 2013 20:13:22 GMT
         Table size: 215
        

Decoded header list:

解码标题列表:

   :status: 200
   cache-control: private
   date: Mon, 21 Oct 2013 20:13:22 GMT
   location: https://www.example.com
   content-encoding: gzip
   set-cookie: foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1
        
   :status: 200
   cache-control: private
   date: Mon, 21 Oct 2013 20:13:22 GMT
   location: https://www.example.com
   content-encoding: gzip
   set-cookie: foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1
        

Acknowledgments

致谢

This specification includes substantial input from the following individuals:

本规范包括以下人员的大量投入:

o Mike Bishop, Jeff Pinner, Julian Reschke, and Martin Thomson (substantial editorial contributions).

o Mike Bishop、Jeff Pinner、Julian Reschke和Martin Thomson(大量编辑贡献)。

o Johnny Graettinger (Huffman code statistics).

o 约翰尼·格雷廷格(哈夫曼代码统计)。

Authors' Addresses

作者地址

Roberto Peon Google, Inc

罗伯托·佩恩谷歌公司

   EMail: fenix@google.com
        
   EMail: fenix@google.com
        

Herve Ruellan Canon CRF

赫维·鲁埃兰佳能酒店

   EMail: herve.ruellan@crf.canon.fr
        
   EMail: herve.ruellan@crf.canon.fr