idnits 2.17.1 draft-ietf-httpbis-header-compression-07.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- ** The document seems to lack an IANA Considerations section. (See Section 2.2 of https://www.ietf.org/id-info/checklist for how to handle the case when there are no actions for IANA.) ** The document seems to lack a both a reference to RFC 2119 and the recommended RFC 2119 boilerplate, even if it appears to use RFC 2119 keywords. RFC 2119 keyword, line 256: '...uplicate entries MUST NOT be treated a...' RFC 2119 keyword, line 329: '...ny other indices MUST be treated as a ...' RFC 2119 keyword, line 350: '... decoder MAY pass the emitted header...' RFC 2119 keyword, line 365: '...r set, a decoder MUST obey the followi...' RFC 2119 keyword, line 440: '...The size of the header table MUST stay...' (9 more instances...) Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == Line 1161 has weird spacing: '... as hex len...' == Line 1162 has weird spacing: '...aligned in...' -- The document date (April 03, 2014) is 3673 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) -- Looks like a reference, but probably isn't: '26' on line 1327 -- Looks like a reference, but probably isn't: '13' on line 1203 -- Looks like a reference, but probably isn't: '14' on line 1258 -- Looks like a reference, but probably isn't: '15' on line 1228 -- Looks like a reference, but probably isn't: '10' on line 1227 -- Looks like a reference, but probably isn't: '17' on line 1289 -- Looks like a reference, but probably isn't: '11' on line 1257 -- Looks like a reference, but probably isn't: '18' on line 1260 -- Looks like a reference, but probably isn't: '12' on line 1290 -- Looks like a reference, but probably isn't: '25' on line 1420 == Outdated reference: A later version (-17) exists of draft-ietf-httpbis-http2-10 Summary: 2 errors (**), 0 flaws (~~), 4 warnings (==), 11 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 HTTPbis Working Group R. Peon 3 Internet-Draft Google, Inc 4 Intended status: Standards Track H. Ruellan 5 Expires: October 05, 2014 Canon CRF 6 April 03, 2014 8 HPACK - Header Compression for HTTP/2 9 draft-ietf-httpbis-header-compression-07 11 Abstract 13 This specification defines HPACK, a compression format for 14 efficiently representing HTTP header fields in the context of HTTP/2. 16 Editorial Note (To be removed by RFC Editor) 18 Discussion of this draft takes place on the HTTPBIS working group 19 mailing list (ietf-http-wg@w3.org), which is archived at . 22 Working Group information can be found at ; that specific to HTTP/2 are at . 25 The changes in this draft are summarized in Appendix A.1. 27 Status of This Memo 29 This Internet-Draft is submitted in full conformance with the 30 provisions of BCP 78 and BCP 79. 32 Internet-Drafts are working documents of the Internet Engineering 33 Task Force (IETF). Note that other groups may also distribute 34 working documents as Internet-Drafts. The list of current Internet- 35 Drafts is at http://datatracker.ietf.org/drafts/current/. 37 Internet-Drafts are draft documents valid for a maximum of six months 38 and may be updated, replaced, or obsoleted by other documents at any 39 time. It is inappropriate to use Internet-Drafts as reference 40 material or to cite them other than as "work in progress." 42 This Internet-Draft will expire on October 05, 2014. 44 Copyright Notice 46 Copyright (c) 2014 IETF Trust and the persons identified as the 47 document authors. All rights reserved. 49 This document is subject to BCP 78 and the IETF Trust's Legal 50 Provisions Relating to IETF Documents 51 (http://trustee.ietf.org/license-info) in effect on the date of 52 publication of this document. Please review these documents 53 carefully, as they describe your rights and restrictions with respect 54 to this document. Code Components extracted from this document must 55 include Simplified BSD License text as described in Section 4.e of 56 the Trust Legal Provisions and are provided without warranty as 57 described in the Simplified BSD License. 59 Table of Contents 61 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3 62 2. Overview . . . . . . . . . . . . . . . . . . . . . . . . . . 4 63 2.1. Outline . . . . . . . . . . . . . . . . . . . . . . . . . 4 64 3. Header Field Encoding . . . . . . . . . . . . . . . . . . . . 5 65 3.1. Encoding Concepts . . . . . . . . . . . . . . . . . . . . 5 66 3.1.1. Encoding Context . . . . . . . . . . . . . . . . . . 6 67 3.1.2. Header Table . . . . . . . . . . . . . . . . . . . . 6 68 3.1.3. Reference Set . . . . . . . . . . . . . . . . . . . . 6 69 3.1.4. Header Field Representation . . . . . . . . . . . . . 7 70 3.1.5. Header Field Emission . . . . . . . . . . . . . . . . 8 71 3.2. Header Block Decoding . . . . . . . . . . . . . . . . . . 8 72 3.2.1. Header Field Representation Processing . . . . . . . 8 73 3.2.2. Reference Set Emission . . . . . . . . . . . . . . . 10 74 3.2.3. Header Set Completion . . . . . . . . . . . . . . . . 10 75 3.3. Header Table Management . . . . . . . . . . . . . . . . . 10 76 3.3.1. Maximum Table Size . . . . . . . . . . . . . . . . . 10 77 3.3.2. Entry Eviction When Header Table Size Changes . . . . 10 78 3.3.3. Entry Eviction when Adding New Entries . . . . . . . 11 79 4. Detailed Format . . . . . . . . . . . . . . . . . . . . . . . 11 80 4.1. Low-level representations . . . . . . . . . . . . . . . . 11 81 4.1.1. Integer representation . . . . . . . . . . . . . . . 11 82 4.1.2. String Literal Representation . . . . . . . . . . . . 12 83 4.2. Indexed Header Field Representation . . . . . . . . . . . 13 84 4.3. Literal Header Field Representation . . . . . . . . . . . 14 85 4.3.1. Literal Header Field with Incremental Indexing . . . 14 86 4.3.2. Literal Header Field without Indexing . . . . . . . . 15 87 4.3.3. Literal Header Field never Indexed . . . . . . . . . 16 88 4.4. Encoding Context Update . . . . . . . . . . . . . . . . . 17 89 5. Security Considerations . . . . . . . . . . . . . . . . . . . 18 90 5.1. Compression-based Attacks . . . . . . . . . . . . . . . . 18 91 5.2. Memory Consumption . . . . . . . . . . . . . . . . . . . 19 92 5.3. Implementation Limits . . . . . . . . . . . . . . . . . . 19 93 6. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 19 94 7. References . . . . . . . . . . . . . . . . . . . . . . . . . 20 95 7.1. Normative References . . . . . . . . . . . . . . . . . . 20 96 7.2. Informative References . . . . . . . . . . . . . . . . . 20 97 Appendix A. Change Log (to be removed by RFC Editor before 98 publication . . . . . . . . . . . . . . . . . . . . 21 99 A.1. Since draft-ietf-httpbis-header-compression-06 . . . . . 21 100 A.2. Since draft-ietf-httpbis-header-compression-05 . . . . . 21 101 A.3. Since draft-ietf-httpbis-header-compression-04 . . . . . 21 102 A.4. Since draft-ietf-httpbis-header-compression-03 . . . . . 21 103 A.5. Since draft-ietf-httpbis-header-compression-02 . . . . . 22 104 A.6. Since draft-ietf-httpbis-header-compression-01 . . . . . 22 105 A.7. Since draft-ietf-httpbis-header-compression-00 . . . . . 22 106 Appendix B. Static Table . . . . . . . . . . . . . . . . . . . . 23 107 Appendix C. Huffman Codes . . . . . . . . . . . . . . . . . . . 25 108 Appendix D. Examples . . . . . . . . . . . . . . . . . . . . . . 31 109 D.1. Integer Representation Examples . . . . . . . . . . . . . 31 110 D.1.1. Example 1: Encoding 10 using a 5-bit prefix . . . . . 31 111 D.1.2. Example 2: Encoding 1337 using a 5-bit prefix . . . . 31 112 D.1.3. Example 3: Encoding 42 starting at an 113 octet-boundary . . . . . . . . . . . . . . . . . . . 32 114 D.2. Header Field Representation Examples . . . . . . . . . . 32 115 D.2.1. Literal Header Field with Indexing . . . . . . . . . 32 116 D.2.2. Literal Header Field without Indexing . . . . . . . . 33 117 D.2.3. Indexed Header Field . . . . . . . . . . . . . . . . 34 118 D.2.4. Indexed Header Field from Static Table . . . . . . . 35 119 D.3. Request Examples without Huffman . . . . . . . . . . . . 35 120 D.3.1. First request . . . . . . . . . . . . . . . . . . . . 35 121 D.3.2. Second request . . . . . . . . . . . . . . . . . . . 37 122 D.3.3. Third request . . . . . . . . . . . . . . . . . . . . 38 123 D.4. Request Examples with Huffman . . . . . . . . . . . . . . 40 124 D.4.1. First request . . . . . . . . . . . . . . . . . . . . 40 125 D.4.2. Second request . . . . . . . . . . . . . . . . . . . 41 126 D.4.3. Third request . . . . . . . . . . . . . . . . . . . . 42 127 D.5. Response Examples without Huffman . . . . . . . . . . . . 44 128 D.5.1. First response . . . . . . . . . . . . . . . . . . . 44 129 D.5.2. Second response . . . . . . . . . . . . . . . . . . . 46 130 D.5.3. Third response . . . . . . . . . . . . . . . . . . . 47 131 D.6. Response Examples with Huffman . . . . . . . . . . . . . 49 132 D.6.1. First response . . . . . . . . . . . . . . . . . . . 49 133 D.6.2. Second response . . . . . . . . . . . . . . . . . . . 52 134 D.6.3. Third response . . . . . . . . . . . . . . . . . . . 53 136 1. Introduction 137 This specification defines HPACK, a compression format for 138 efficiently representing HTTP header fields in the context of HTTP/2 139 (see [HTTP2]). 141 2. Overview 143 In HTTP/1.1 (see [HTTP-p1]), header fields are encoded without any 144 form of compression. As web pages have grown to include dozens to 145 hundreds of requests, the redundant header fields in these requests 146 now measurably increase latency and unnecessarily consume bandwidth 147 (see [PERF1] and [PERF2]). 149 SPDY [SPDY] initially addressed this redundancy by compressing header 150 fields using the DEFLATE format [DEFLATE], which proved very 151 effective at efficiently representing the redundant header fields. 152 However, that approach exposed a security risk as demonstrated by the 153 CRIME attack (see [CRIME]). 155 This document describes HPACK, a new compressor for header fields 156 which eliminates redundant header fields, is not vulnerable to known 157 security attacks, and which also has a bounded memory requirement for 158 use in constrained environments. 160 2.1. Outline 162 The HTTP header field encoding defined in this document is based on a 163 header table that maps name-value pairs to index values. The header 164 table is incrementally updated during the HTTP/2 connection. 166 A set of header fields is treated as an unordered collection of name- 167 value pairs. Names and values are considered to be opaque sequences 168 of octets. The order of header fields is not guaranteed to be 169 preserved after being compressed and decompressed. 171 As two consecutive sets of header fields often have header fields in 172 common, each set is coded as a difference from the previous set. The 173 goal is to only encode the changes (header fields present in one of 174 the sets that are absent from the other) between the two sets of 175 header fields. 177 A header field is represented either literally or as a reference to a 178 name-value pair in the header table. A set of header fields is 179 stored as a set of references to entries in the header table 180 (possibly keeping only a subset of it, as some header fields may be 181 missing a corresponding entry in the header table). Differences 182 between consecutive sets of header fields are encoded as changes to 183 the set of references. 185 The encoder is responsible for deciding which header fields to insert 186 as new entries in the header table. The decoder executes the 187 modifications to the header table and reference set prescribed by the 188 encoder, reconstructing the set of header fields in the process. 189 This enables decoders to remain simple and understand a wide variety 190 of encoders. 192 Examples illustrating the use of these different mechanisms to 193 represent header fields are available in Appendix D. 195 3. Header Field Encoding 197 3.1. Encoding Concepts 199 The encoding and decoding of header fields relies on some components 200 and concepts: 202 Header Field: A name-value pair. Both the name and value are 203 treated as opaque sequences of octets. 205 Header Table: The header table (see Section 3.1.2) is a component 206 used to associate stored header fields to index values. 208 Static Table: The static table (see Appendix B) is a component used 209 to associate static header fields to index values. This data is 210 ordered, read-only, always accessible, and may be shared amongst 211 all encoding contexts. 213 Reference Set: The reference set (see Section 3.1.3) is a component 214 containing an unordered set of references to entries in the header 215 table. This is used for the differential encoding of a new header 216 set. 218 Header Set: A header set is an unordered group of header fields that 219 are encoded jointly. A complete set of key-value pairs contained 220 in a HTTP request or response is a header set. 222 Header Field Representation: A header field can be represented in 223 encoded form either as a literal or as an index (see 224 Section 3.1.4). 226 Header Block: The entire set of encoded header field representations 227 which, when decoded, yield a complete header set. 229 Header Field Emission: When decoding a set of header field 230 representations, some operations emit a header field (see 231 Section 3.1.5). Emitted header fields are added to the current 232 header set and cannot be removed. 234 3.1.1. Encoding Context 236 The set of mutable structures used within an encoding context include 237 a header table and a reference set. Everything else is either 238 immutable or conceptual. 240 HTTP messages are exchanged between a client and a server in both 241 directions. The encoding of header fields in each direction is 242 independent from the other direction. There is a single encoding 243 context for each direction used to encode all header fields sent in 244 that direction. 246 3.1.2. Header Table 248 A header table consists of a list of header fields maintained in 249 first-in, first-out order. The first and newest entry in a header 250 table is always at index 1, and the oldest entry of a header table is 251 at the index len(header table). 253 The header table is initially empty. 255 There is typically no need for the header table to contain duplicate 256 entries. However, duplicate entries MUST NOT be treated as an error 257 by a decoder. 259 The encoder decides how to update the header table and as such can 260 control how much memory is used by the header table. To limit the 261 memory requirements of the decoder, the header table size is strictly 262 bounded (see Section 3.3.1). 264 The header table is updated during the processing of a set of header 265 field representations (see Section 3.2.1). 267 3.1.3. Reference Set 269 A reference set is an unordered set of references to entries of the 270 header table. 272 The reference set is initially empty. 274 The reference set is updated during the processing of a set of header 275 field representations (see Section 3.2.1). 277 The reference set enables differential encoding, whereby only 278 differences between the previous header set and the current header 279 set need to be encoded. The use of differential encoding is optional 280 for any header set. 282 When an entry is evicted from the header table, if it was referenced 283 from the reference set, its reference is removed from the reference 284 set. 286 To limit the memory requirements on the decoder side for handling the 287 reference set, only entries within the header table can be contained 288 in the reference set. To still allow entries from the static table 289 to take advantage of the differential encoding, when a header field 290 is represented as a reference to an entry of the static table, this 291 entry is inserted into the header table (see Section 3.2.1). 293 3.1.4. Header Field Representation 295 An encoded header field can be represented either as a literal or as 296 an index. 298 Literal Representation: A literal representation defines a new 299 header field. The header field name is represented either 300 literally or as a reference to an entry of the header table. The 301 header field value is represented literally. 303 Three different literal representations are provided: 305 * A literal representation that does not add the header field to 306 the header table (see Section 4.3.2). 308 * A literal representation that does not add the header field to 309 the header table and require that this header field always use 310 a literal representation, in particular when re-encoded by an 311 intermediary (see Section 4.3.3). 313 * A literal representation that adds the header field as a new 314 entry at the beginning of the header table (see Section 4.3.1). 316 Indexed Representation: The indexed representation defines a header 317 field as a reference to an entry in either the header table or the 318 static table (see Section 4.2). 320 Indices between 1 and len(header table), inclusive, refer to 321 elements in the header table, with index 1 referring to the 322 beginning of the table. 324 Indices between len(header table) + 1 and len(header table) + 325 len(static table), inclusive, refer to elements in the static 326 table, where the index len(header table) + 1 refers to the first 327 entry in the static table. 329 Any other indices MUST be treated as a decoding error. 331 <---------- Index Address Space ----------> 332 <-- Header Table --> <-- Static Table --> 333 +---+-----------+---+ +---+-----------+---+ 334 | 1 | ... | k | |k+1| ... | n | 335 +---+-----------+---+ +---+-----------+---+ 336 ^ | 337 | V 338 Insertion Point Drop Point 340 Index Address Space 342 3.1.5. Header Field Emission 344 The emission of a header field is the process of marking a header 345 field as belonging to the current header set. Once a header has been 346 emitted, it cannot be removed from the current header set. 348 On the decoding side, an emitted header field can be safely passed to 349 the upper processing layer as part of the current header set. The 350 decoder MAY pass the emitted header fields to the upper processing 351 layer in any order. 353 By emitting header fields instead of emitting header sets, the 354 decoder can be implemented in a streaming way, and as such has only 355 to keep in memory the header table and the reference set. This 356 bounds the amount of memory used by the decoder, even in presence of 357 a very large set of header fields. The management of memory for 358 handling very large sets of header fields can therefore be deferred 359 to the upper processing layers. 361 3.2. Header Block Decoding 363 The processing of a header block to obtain a header set is defined in 364 this section. To ensure that the decoding will successfully produce 365 a header set, a decoder MUST obey the following rules. 367 3.2.1. Header Field Representation Processing 369 All the header field representations contained in a header block are 370 processed in the order in which they are presented, as specified 371 below. 373 An _indexed representation_ with an index value of 0 entails one of 374 the following actions, depending on what is encoded next: 376 o The reference set is emptied. 378 o The maximum size of the header table is updated. 380 An _indexed representation_ corresponding to an entry _present_ in 381 the reference set entails the following actions: 383 o The entry is removed from the reference set. 385 An _indexed representation_ corresponding to an entry _not present_ 386 in the reference set entails the following actions: 388 o If referencing an element of the static table: 390 * The header field corresponding to the referenced entry is 391 emitted. 393 * The referenced static entry is inserted at the beginning of the 394 header table. 396 * A reference to this new header table entry is added to the 397 reference set, except if this new entry didn't fit in the 398 header table. 400 o If referencing an element of the header table: 402 * The header field corresponding to the referenced entry is 403 emitted. 405 * The referenced header table entry is added to the reference 406 set. 408 A _literal representation_ that is _not added_ to the header table 409 entails the following action: 411 o The header field is emitted. 413 A _literal representation_ that is _added_ to the header table 414 entails the following actions: 416 o The header field is emitted. 418 o The header field is inserted at the beginning of the header table. 420 o A reference to the new entry is added to the reference set (except 421 if this new entry didn't fit in the header table). 423 3.2.2. Reference Set Emission 425 Once all the representations contained in a header block have been 426 processed, the header fields referenced in the reference set which 427 have not previously been emitted during this processing are emitted. 429 3.2.3. Header Set Completion 431 Once all of the header field representations have been processed, and 432 the remaining items in the reference set have been emitted, the 433 header set is complete. 435 3.3. Header Table Management 437 3.3.1. Maximum Table Size 439 To limit the memory requirements on the decoder side, the size of the 440 header table is bounded. The size of the header table MUST stay 441 lower than or equal to its maximum size. 443 By default, the maximum size of the header table is equal to the 444 value of the HTTP/2 setting SETTINGS_HEADER_TABLE_SIZE defined by the 445 decoder (see [HTTP2]). The encoder can change this maximum size (see 446 Section 4.4), but it must stay lower than or equal to the value of 447 SETTINGS_HEADER_TABLE_SIZE. 449 The size of the header table is the sum of the size of its entries. 451 The size of an entry is the sum of its name's length in octets (as 452 defined in Section 4.1.2), of its value's length in octets 453 (Section 4.1.2) and of 32 octets. 455 The lengths are measured on the non-encoded entry name and entry 456 value (for the case when a Huffman encoding is used to transmit 457 string values). 459 The 32 octets are an accounting for the entry structure overhead. 460 For example, an entry structure using two 64-bits pointers to 461 reference the name and the value and the entry, and two 64-bits 462 integer for counting the number of references to these name and value 463 would use 32 octets. 465 3.3.2. Entry Eviction When Header Table Size Changes 467 Whenever an entry is evicted from the header table, any reference to 468 that entry contained by the reference set is removed. 470 Whenever the maximum size for the header table is made smaller, 471 entries are evicted from the end of the header table until the size 472 of the header table is less than or equal to the maximum size. 474 The eviction of an entry from the header table causes the index of 475 the entries in the static table to be reduced by one. 477 3.3.3. Entry Eviction when Adding New Entries 479 Whenever a new entry is to be added to the table, any name referenced 480 by the representation of this new entry is cached, and then entries 481 are evicted from the end of the header table until the size of the 482 header table is less than or equal to (maximum size - new entry 483 size), or until the table is empty. 485 If the size of the new entry is less than or equal to the maximum 486 size, that entry is added to the table. It is not an error to 487 attempt to add an entry that is larger than the maximum size. 489 4. Detailed Format 491 4.1. Low-level representations 493 4.1.1. Integer representation 495 Integers are used to represent name indexes, pair indexes or string 496 lengths. To allow for optimized processing, an integer 497 representation always finishes at the end of an octet. 499 An integer is represented in two parts: a prefix that fills the 500 current octet and an optional list of octets that are used if the 501 integer value does not fit within the prefix. The number of bits of 502 the prefix (called N) is a parameter of the integer representation. 504 The N-bit prefix allows filling the current octet. If the value is 505 small enough (strictly less than 2^N-1), it is encoded within the 506 N-bit prefix. Otherwise all the bits of the prefix are set to 1 and 507 the value is encoded using an unsigned variable length integer 508 representation (see ). N is always between 1 and 8 bits. An integer 510 starting at an octet-boundary will have an 8-bit prefix. 512 The algorithm to represent an integer I is as follows: 514 if I < 2^N - 1, encode I on N bits 515 else 516 encode (2^N - 1) on N bits 517 I = I - (2^N - 1) 518 while I >= 128 519 encode (I % 128 + 128) on 8 bits 520 I = I / 128 521 encode I on 8 bits 523 For informational purpose, the algorithm to decode an integer I is as 524 follows: 526 decode I from the next N bits 527 if I < 2^N - 1, return I 528 else 529 M = 0 530 repeat 531 B = next octet 532 I = I + (B & 127) * 2^M 533 M = M + 7 534 while B & 128 == 128 535 return I 537 Examples illustrating the encoding of integers are available in 538 Appendix D.1. 540 This integer representation allows for values of indefinite size. It 541 is also possible for an encoder to send a large number of zero 542 values, which can waste octets and could be used to overflow integer 543 values. Excessively large integer encodings - in value or octet 544 length - MUST be treated as a decoding error. Different limits can 545 be set for each of the different uses of integers, based on 546 implementation constraints. 548 4.1.2. String Literal Representation 550 Header field names and header field values can be represented as 551 literal string. A literal string is encoded as a sequence of octets, 552 either by directly encoding the literal string's octets, or by using 553 a canonical [CANON] Huffman encoding [HUFF]. 555 0 1 2 3 4 5 6 7 556 +---+---+---+---+---+---+---+---+ 557 | H | String Length (7+) | 558 +---+---------------------------+ 559 | String Data (Length octets) | 560 +-------------------------------+ 562 String Literal Representation 564 A literal string representation contains the following fields: 566 H: A one bit flag, H, indicating whether or not the octets of the 567 string are Huffman encoded. 569 String Length: The number of octets used to encode the string 570 literal, encoded as an integer with 7-bit prefix (see 571 Section 4.1.1). 573 String Data: The encoded data of the string literal. If H is '0', 574 then the encoded data is the raw octets of the string literal. If 575 H is '1', then the encoded data is the Huffman encoding of the 576 string literal. 578 String literals which use Huffman encoding are encoded with the 579 Huffman codes defined in Appendix C (see examples inRequest Examples 580 with Huffman Appendix D.4 and in Response Examples with Huffman 581 Appendix D.6). The encoded data is the bitwise concatenation of the 582 Huffman codes corresponding to each octet of the string literal. 584 As the Huffman encoded data doesn't always end at an octet boundary, 585 some padding is inserted after it up to the next octet boundary. To 586 prevent this padding to be misinterpreted as part of the string 587 literal, the most significant bits of the EOS (end-of-string) entry 588 in the Huffman table are used. 590 Upon decoding, an incomplete Huffman code at the end of the encoded 591 data is to be considered as padding and discarded. A padding 592 strictly longer than 7 bits MUST be treated as a decoding error. A 593 padding not corresponding to the most significant bits of the EOS 594 entry MUST be treated as a decoding error. A Huffman encoded string 595 literal containing the EOS entry MUST be treated as a decoding error. 597 4.2. Indexed Header Field Representation 599 An indexed header field representation either identifies an entry in 600 the header table or static table. The processing of an indexed 601 header field representation is described in Section 3.2.1. 603 0 1 2 3 4 5 6 7 604 +---+---+---+---+---+---+---+---+ 605 | 1 | Index (7+) | 606 +---+---------------------------+ 608 Indexed Header Field 610 This representation starts with the '1' 1-bit pattern, followed by 611 the index of the matching pair, represented as an integer with a 612 7-bit prefix. 614 The index value of 0 is not used. It MUST be treated as a decoding 615 error if found in an indexed header field representation. 617 4.3. Literal Header Field Representation 619 Literal header field representations contain a literal header field 620 value. Header field names are either provided as a literal or by 621 reference to an existing header table or static table entry. 623 Literal representations all result in the emission of a header field 624 when decoded. 626 4.3.1. Literal Header Field with Incremental Indexing 628 A literal header field with incremental indexing adds a new entry to 629 the header table. 631 0 1 2 3 4 5 6 7 632 +---+---+---+---+---+---+---+---+ 633 | 0 | 1 | Index (6+) | 634 +---+---+-----------------------+ 635 | H | Value Length (7+) | 636 +---+---------------------------+ 637 | Value String (Length octets) | 638 +-------------------------------+ 640 Literal Header Field with Incremental Indexing - Indexed Name 642 0 1 2 3 4 5 6 7 643 +---+---+---+---+---+---+---+---+ 644 | 0 | 1 | 0 | 645 +---+---+-----------------------+ 646 | H | Name Length (7+) | 647 +---+---------------------------+ 648 | Name String (Length octets) | 649 +---+---------------------------+ 650 | H | Value Length (7+) | 651 +---+---------------------------+ 652 | Value String (Length octets) | 653 +-------------------------------+ 655 Literal Header Field with Incremental Indexing - New Name 657 This representation starts with the '01' 2-bit pattern. 659 If the header field name matches the header field name of a (name, 660 value) pair stored in the Header Table or Static Table, the header 661 field name can be represented using the index of that entry. In this 662 case, the index of the entry, index (which is strictly greater than 663 0), is represented as an integer with a 6-bit prefix (see 664 Section 4.1.1). 666 Otherwise, the header field name is represented as a literal. The 667 value 0 is represented on 6 bits followed by the header field name 668 (see Section 4.1.2). 670 The header field name representation is followed by the header field 671 value represented as a literal string as described in Section 4.1.2. 673 4.3.2. Literal Header Field without Indexing 675 A literal header field without indexing causes the emission of a 676 header field without altering the header table. 678 0 1 2 3 4 5 6 7 679 +---+---+---+---+---+---+---+---+ 680 | 0 | 0 | 0 | 0 | Index (4+) | 681 +---+---+-----------------------+ 682 | H | Value Length (7+) | 683 +---+---------------------------+ 684 | Value String (Length octets) | 685 +-------------------------------+ 687 Literal Header Field without Indexing - Indexed Name 689 0 1 2 3 4 5 6 7 690 +---+---+---+---+---+---+---+---+ 691 | 0 | 0 | 0 | 0 | 0 | 692 +---+---+-----------------------+ 693 | H | Name Length (7+) | 694 +---+---------------------------+ 695 | Name String (Length octets) | 696 +---+---------------------------+ 697 | H | Value Length (7+) | 698 +---+---------------------------+ 699 | Value String (Length octets) | 700 +-------------------------------+ 702 Literal Header Field without Indexing - New Name 704 The literal header field without indexing representation starts with 705 the '0000' 4-bit pattern. 707 If the header field name matches the header field name of a (name, 708 value) pair stored in the Header Table or Static Table, the header 709 field name can be represented using the index of that entry. In this 710 case, the index of the entry, index (which is strictly greater than 711 0), is represented as an integer with a 6-bit prefix (see 712 Section 4.1.1). 714 Otherwise, the header field name is represented as a literal. The 715 value 0 is represented on 4 bits followed by the header field name 716 (see Section 4.1.2). 718 The header field name representation is followed by the header field 719 value represented as a literal string as described in Section 4.1.2. 721 4.3.3. Literal Header Field never Indexed 723 A literal header field never indexed causes the emission of a header 724 field without altering the header table. 726 0 1 2 3 4 5 6 7 727 +---+---+---+---+---+---+---+---+ 728 | 0 | 0 | 0 | 1 | Index (4+) | 729 +---+---+-----------------------+ 730 | H | Value Length (7+) | 731 +---+---------------------------+ 732 | Value String (Length octets) | 733 +-------------------------------+ 735 Literal Header Field never Indexed - Indexed Name 737 0 1 2 3 4 5 6 7 738 +---+---+---+---+---+---+---+---+ 739 | 0 | 0 | 0 | 1 | 0 | 740 +---+---+-----------------------+ 741 | H | Name Length (7+) | 742 +---+---------------------------+ 743 | Name String (Length octets) | 744 +---+---------------------------+ 745 | H | Value Length (7+) | 746 +---+---------------------------+ 747 | Value String (Length octets) | 748 +-------------------------------+ 750 Literal Header Field never Indexed - New Name 752 The literal header field never indexed representation starts with the 753 '0001' 4-bit pattern. 755 When a header field is represented as a literal header field never 756 indexed, it MUST always be encoded with this same representation. In 757 particular, when a peer sends a header field that it received 758 represented as a literal header field never indexed, it MUST use the 759 same representation to forward this header field. 761 This representation is intended for protecting header field values 762 that are not to be put at risk by compressing them (see Section 5.1 763 for more details). 765 The encoding of the representation is the same as for the literal 766 header field without indexing representation (see Section 4.3.2). 768 4.4. Encoding Context Update 770 An encoding context update causes the immediate application of a 771 change to the encoding context. 773 0 1 2 3 4 5 6 7 774 +---+---+---+---+---+---+---+---+ 775 | 0 | 0 | 1 | F | ... | 776 +---+---------------------------+ 778 Context Update 780 An encoding context update starts with the '001' 3-bit pattern. 782 It is followed by a flag specifying the type of the change, and by 783 any data necessary to describe the change itself. 785 0 1 2 3 4 5 6 7 786 +---+---+---+---+---+---+---+---+ 787 | 0 | 0 | 1 | 1 | 0 | 788 +---+---------------------------+ 790 Reference Set Emptying 792 The flag bit being set to '1' signals that the reference set is 793 emptied. The remaining bits are set to '0'. 795 0 1 2 3 4 5 6 7 796 +---+---+---+---+---+---+---+---+ 797 | 0 | 0 | 1 | 0 | Max size (4+) | 798 +---+---------------------------+ 800 Maximum Header Table Size Change 802 The flag bit being set to '0' signals that a change to the maximum 803 size of the header table. This new maximum size MUST be lower than 804 or equal to the value of the setting SETTINGS_HEADER_TABLE_SIZE (see 805 [HTTP2]). 807 The new maximum size is encoded as an integer with a 4-bit prefix. 809 Change in the maximum size of the header table can trigger entry 810 evictions (see Section 3.3.2). 812 5. Security Considerations 814 5.1. Compression-based Attacks 816 Compression can create a weak point allowing an attacker to recover 817 secret data. For example, the CRIME attack (see [CRIME]) took 818 advantage of the DEFLATE mechanism (see [DEFLATE]) of SPDY (see 819 [SPDY]) to efficiently probe the compression context. The full-text 820 compression mechanism of DEFLATE allowed the attacker to learn some 821 information from each failed attempt at guessing the secret. 823 For this reason, HPACK provides only limited compression mechanisms 824 in the form of an indexing table and of a static Huffman encoding. 826 The indexing table can still provide information to an attacker that 827 would be able to probe the compression context. However, this 828 information is limited to the knowledge of whether the attacker's 829 guess is correct or not. 831 Still, an attacker could take advantage of this limited information 832 for breaking low-entropy secrets using a brute-force attack. A 833 server usually has some protections against such brute-force attack. 834 Here, the attack would target the client, where it would be harder to 835 detect. The attack would be even more dangerous if the attacker is 836 able to prevent the traffic generated by its brute-force attack from 837 reaching the server. 839 To offer some protection against such type of attacks, HPACK enables 840 an endpoint to indicate that a header field must never be compressed, 841 across any hop up to the other endpoint (see Section 4.3.3). An 842 endpoint MUST use this feature to prevent the compression of any 843 header field whose value contains a secret which could be put at risk 844 by a brute-force attack. 846 For optimal processing, a sensitive value (for example a cookie) 847 needs to have an entropy high enough to not be endangered by a brute- 848 force attack, in order to take advantage of HPACK indexing. 850 There is currently no known threat taking advantage of the use of a 851 fixed Huffman encoding. A study has shown that using a fixed Huffman 852 encoding table created an information leakage, however this same 853 study concluded that an attacker could not take advantage of this 854 information leakage to recover any meaningful amount of information 855 (see [PETAL]). 857 5.2. Memory Consumption 859 An attacker can try to cause an endpoint to exhaust its memory. 860 HPACK is designed to limit both the peak and state amounts of memory 861 allocated by an endpoint. 863 The amount of memory used by the compressor state is limited by the 864 value of the setting SETTINGS_HEADER_TABLE_SIZE. This limitation 865 takes into account both the size of the data stored in the header 866 table, and the overhead required by the table structure itself. 868 For the decoding side, an endpoint can limit the amount of state 869 memory used by setting an appropriate value for 870 SETTINGS_HEADER_TABLE_SIZE. For the encoding side, the endpoint can 871 limit the amount of state memory it uses by defining a header table 872 maximum size lower than the value of SETTINGS_HEADER_TABLE_SIZE 873 defined by its peer (see Section 4.4). 875 The amount of temporary memory consumed is linked to the set of 876 header fields emitted or received. However, this amount of temporary 877 memory can be limited by processing these header fields in a 878 streaming manner. 880 5.3. Implementation Limits 882 An implementation of HPACK needs to ensure that large values for 883 integers, long encoding for integers, or long string literal do not 884 create security weaknesses. 886 An implementation has to set a limit for the values it accepts for 887 integers, as well as for the encoded length (see Section 4.1.1). In 888 the same way, it has to set a limit to the length it accepts for 889 string literals (see Section 4.1.2). 891 6. Acknowledgements 893 This document includes substantial editorial contributions from the 894 following individuals: Mike Bishop, Jeff Pinner, Julian Reschke, 895 Martin Thomson. 897 7. References 899 7.1. Normative References 901 [HTTP-p1] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer 902 Protocol (HTTP/1.1): Message Syntax and Routing", draft- 903 ietf-httpbis-p1-messaging-26 (work in progress), February 904 2014. 906 [HTTP2] Belshe, M., Peon, R., and M. Thomson, Ed., "Hypertext 907 Transfer Protocol version 2", draft-ietf-httpbis-http2-10 908 (work in progress), February 2014. 910 7.2. Informative References 912 [CANON] Schwartz, E. and B. Kallick, "Generating a canonical 913 prefix encoding", Communications of the ACM Volume 7 Issue 914 3, pp. 166-169, March 1964, 915 . 917 [CRIME] Rizzo, J. and T. Duong, "The CRIME Attack", September 918 2012, . 922 [DEFLATE] Deutsch, P., "DEFLATE Compressed Data Format Specification 923 version 1.3", RFC 1951, May 1996. 925 [HUFF] Huffman, D., "A Method for the Construction of Minimum 926 Redundancy Codes", Proceedings of the Institute of Radio 927 Engineers Volume 40, Number 9, pp. 1098-1101, September 928 1952, . 931 [PERF1] Belshe, M., "IETF83: SPDY and What to Consider for HTTP/ 932 2.0", March 2012, . 935 [PERF2] McManus, P., "SPDY: What I Like About You", September 936 2011, . 939 [PETAL] Tan, J. and J. Nahata, "PETAL: Preset Encoding Table 940 Information Leakage", April 2013, . 943 [SPDY] Belshe, M. and R. Peon, "SPDY Protocol", draft-mbelshe- 944 httpbis-spdy-00 (work in progress), February 2012. 946 Appendix A. Change Log (to be removed by RFC Editor before publication 948 A.1. Since draft-ietf-httpbis-header-compression-06 950 o Updated format to include literal headers that must never be 951 compressed. 953 o Updated security considerations. 955 o Moved integer encoding examples to the appendix. 957 o Updated Huffman table. 959 o Updated static header table (adding and removing status values). 961 o Updated examples. 963 A.2. Since draft-ietf-httpbis-header-compression-05 965 o Regenerated examples. 967 o Only one Huffman table for requests and responses. 969 o Added maximum size for header table, independent of 970 SETTINGS_HEADER_TABLE_SIZE. 972 o Added pseudo-code for integer decoding. 974 o Improved examples (removing unnecessary removals). 976 A.3. Since draft-ietf-httpbis-header-compression-04 978 o Updated examples: take into account changes in the spec, and show 979 more features. 981 o Use 'octet' everywhere instead of having both 'byte' and 'octet'. 983 o Added reference set emptying. 985 o Editorial changes and clarifications. 987 o Added "host" header to the static table. 989 o Ordering for list of values (either NULL- or comma-separated). 991 A.4. Since draft-ietf-httpbis-header-compression-03 992 o A large number of editorial changes; changed the description of 993 evicting/adding new entries. 995 o Removed substitution indexing 997 o Changed 'initial headers' to 'static headers', as per issue #258 999 o Merged 'request' and 'response' static headers, as per issue #259 1001 o Changed text to indicate that new headers are added at index 0 and 1002 expire from the largest index, as per issue #233 1004 A.5. Since draft-ietf-httpbis-header-compression-02 1006 o Corrected error in integer encoding pseudocode. 1008 A.6. Since draft-ietf-httpbis-header-compression-01 1010 o Refactored of Header Encoding Section: split definitions and 1011 processing rule. 1013 o Backward incompatible change: Updated reference set management as 1014 per issue #214. This changes how the interaction between the 1015 reference set and eviction works. This also changes the working 1016 of the reference set in some specific cases. 1018 o Backward incompatible change: modified initial header list, as per 1019 issue #188. 1021 o Added example of 32 octets entry structure (issue #191). 1023 o Added Header Set Completion section. Reflowed some text. 1024 Clarified some writing which was akward. Added text about 1025 duplicate header entry encoding. Clarified some language w.r.t 1026 Header Set. Changed x-my-header to mynewheader. Added text in 1027 the HeaderEmission section indicating that the application may 1028 also be able to free up memory more quickly. Added information in 1029 Security Considerations section. 1031 A.7. Since draft-ietf-httpbis-header-compression-00 1033 Fixed bug/omission in integer representation algorithm. 1035 Changed the document title. 1037 Header matching text rewritten. 1039 Changed the definition of header emission. 1041 Changed the name of the setting which dictates how much memory the 1042 compression context should use. 1044 Removed "specific use cases" section 1046 Corrected erroneous statement about what index can be contained in 1047 one octet 1049 Added descriptions of opcodes 1051 Removed security claims from introduction. 1053 Appendix B. Static Table 1055 The static table consists of an unchangeable ordered list of (name, 1056 value) pairs. The first entry in the table is always represented by 1057 the index len(header table) + 1, and the last entry in the table is 1058 represented by the index len(header table) + len(static table). 1060 The following table lists the pre-defined header fields that make-up 1061 the static table. 1063 +-------+-----------------------------+--------------+ 1064 | Index | Header Name | Header Value | 1065 +-------+-----------------------------+--------------+ 1066 | 1 | :authority | | 1067 | 2 | :method | GET | 1068 | 3 | :method | POST | 1069 | 4 | :path | / | 1070 | 5 | :path | /index.html | 1071 | 6 | :scheme | http | 1072 | 7 | :scheme | https | 1073 | 8 | :status | 200 | 1074 | 9 | :status | 204 | 1075 | 10 | :status | 206 | 1076 | 11 | :status | 304 | 1077 | 12 | :status | 400 | 1078 | 13 | :status | 404 | 1079 | 14 | :status | 500 | 1080 | 15 | accept-charset | | 1081 | 16 | accept-encoding | | 1082 | 17 | accept-language | | 1083 | 18 | accept-ranges | | 1084 | 19 | accept | | 1085 | 20 | access-control-allow-origin | | 1086 | 21 | age | | 1087 | 22 | allow | | 1088 | 23 | authorization | | 1089 | 24 | cache-control | | 1090 | 25 | content-disposition | | 1091 | 26 | content-encoding | | 1092 | 27 | content-language | | 1093 | 28 | content-length | | 1094 | 29 | content-location | | 1095 | 30 | content-range | | 1096 | 31 | content-type | | 1097 | 32 | cookie | | 1098 | 33 | date | | 1099 | 34 | etag | | 1100 | 35 | expect | | 1101 | 36 | expires | | 1102 | 37 | from | | 1103 | 38 | host | | 1104 | 39 | if-match | | 1105 | 40 | if-modified-since | | 1106 | 41 | if-none-match | | 1107 | 42 | if-range | | 1108 | 43 | if-unmodified-since | | 1109 | 44 | last-modified | | 1110 | 45 | link | | 1111 | 46 | location | | 1112 | 47 | max-forwards | | 1113 | 48 | proxy-authenticate | | 1114 | 49 | proxy-authorization | | 1115 | 50 | range | | 1116 | 51 | referer | | 1117 | 52 | refresh | | 1118 | 53 | retry-after | | 1119 | 54 | server | | 1120 | 55 | set-cookie | | 1121 | 56 | strict-transport-security | | 1122 | 57 | transfer-encoding | | 1123 | 58 | user-agent | | 1124 | 59 | vary | | 1125 | 60 | via | | 1126 | 61 | www-authenticate | | 1127 +-------+-----------------------------+--------------+ 1129 Table 1: Static Table Entries 1131 The table give the index of each entry in the static table. The full 1132 index of each entry, to be used for encoding a reference to this 1133 entry, is computed by adding the number of entries in the header 1134 table to this index. 1136 Appendix C. Huffman Codes 1138 The following codes are used when encoding string literals with an 1139 Huffman coding (see Section 4.1.2). 1141 Each row in the table specifies one Huffman code: 1143 sym: The symbol to be represented. It is the decimal value of an 1144 octet, possibly prepended with its ASCII representation. A 1145 specific symbol, "EOS", is used to indicate the end of a string 1146 literal. 1148 code as bits: The Huffman code for the symbol represented as a 1149 base-2 integer. 1151 code as hex: The Huffman code for the symbol, represented as a 1152 hexadecimal integer, aligned on the least significant bit. 1154 len: The number of bits for the Huffman code of the symbol. 1156 As an example, the Huffman code for the symbol 48 (corresponding to 1157 the ASCII character "0") consists in the 5 bits "0", "0", "1", "0", 1158 "1". This corresponds to the value 5 encoded on 5 bits. 1160 code 1161 code as bits as hex len 1162 sym aligned to MSB aligned in 1163 to LSB bits 1164 ( 0) |11111111|11111111|11101110|10 3ffffba [26] 1165 ( 1) |11111111|11111111|11101110|11 3ffffbb [26] 1166 ( 2) |11111111|11111111|11101111|00 3ffffbc [26] 1167 ( 3) |11111111|11111111|11101111|01 3ffffbd [26] 1168 ( 4) |11111111|11111111|11101111|10 3ffffbe [26] 1169 ( 5) |11111111|11111111|11101111|11 3ffffbf [26] 1170 ( 6) |11111111|11111111|11110000|00 3ffffc0 [26] 1171 ( 7) |11111111|11111111|11110000|01 3ffffc1 [26] 1172 ( 8) |11111111|11111111|11110000|10 3ffffc2 [26] 1173 ( 9) |11111111|11111111|11110000|11 3ffffc3 [26] 1174 ( 10) |11111111|11111111|11110001|00 3ffffc4 [26] 1175 ( 11) |11111111|11111111|11110001|01 3ffffc5 [26] 1176 ( 12) |11111111|11111111|11110001|10 3ffffc6 [26] 1177 ( 13) |11111111|11111111|11110001|11 3ffffc7 [26] 1178 ( 14) |11111111|11111111|11110010|00 3ffffc8 [26] 1179 ( 15) |11111111|11111111|11110010|01 3ffffc9 [26] 1180 ( 16) |11111111|11111111|11110010|10 3ffffca [26] 1181 ( 17) |11111111|11111111|11110010|11 3ffffcb [26] 1182 ( 18) |11111111|11111111|11110011|00 3ffffcc [26] 1183 ( 19) |11111111|11111111|11110011|01 3ffffcd [26] 1184 ( 20) |11111111|11111111|11110011|10 3ffffce [26] 1185 ( 21) |11111111|11111111|11110011|11 3ffffcf [26] 1186 ( 22) |11111111|11111111|11110100|00 3ffffd0 [26] 1187 ( 23) |11111111|11111111|11110100|01 3ffffd1 [26] 1188 ( 24) |11111111|11111111|11110100|10 3ffffd2 [26] 1189 ( 25) |11111111|11111111|11110100|11 3ffffd3 [26] 1190 ( 26) |11111111|11111111|11110101|00 3ffffd4 [26] 1191 ( 27) |11111111|11111111|11110101|01 3ffffd5 [26] 1192 ( 28) |11111111|11111111|11110101|10 3ffffd6 [26] 1193 ( 29) |11111111|11111111|11110101|11 3ffffd7 [26] 1194 ( 30) |11111111|11111111|11110110|00 3ffffd8 [26] 1195 ( 31) |11111111|11111111|11110110|01 3ffffd9 [26] 1196 ' ' ( 32) |00110 6 [ 5] 1197 '!' ( 33) |11111111|11100 1ffc [13] 1198 '"' ( 34) |11111000|0 1f0 [ 9] 1199 '#' ( 35) |11111111|111100 3ffc [14] 1200 '$' ( 36) |11111111|1111100 7ffc [15] 1201 '%' ( 37) |011110 1e [ 6] 1202 '&' ( 38) |1100100 64 [ 7] 1203 ''' ( 39) |11111111|11101 1ffd [13] 1204 '(' ( 40) |11111110|10 3fa [10] 1205 ')' ( 41) |11111000|1 1f1 [ 9] 1206 '*' ( 42) |11111110|11 3fb [10] 1207 '+' ( 43) |11111111|00 3fc [10] 1208 ',' ( 44) |1100101 65 [ 7] 1209 '-' ( 45) |1100110 66 [ 7] 1210 '.' ( 46) |011111 1f [ 6] 1211 '/' ( 47) |00111 7 [ 5] 1212 '0' ( 48) |0000 0 [ 4] 1213 '1' ( 49) |0001 1 [ 4] 1214 '2' ( 50) |0010 2 [ 4] 1215 '3' ( 51) |01000 8 [ 5] 1216 '4' ( 52) |100000 20 [ 6] 1217 '5' ( 53) |100001 21 [ 6] 1218 '6' ( 54) |100010 22 [ 6] 1219 '7' ( 55) |100011 23 [ 6] 1220 '8' ( 56) |100100 24 [ 6] 1221 '9' ( 57) |100101 25 [ 6] 1222 ':' ( 58) |100110 26 [ 6] 1223 ';' ( 59) |11101100| ec [ 8] 1224 '<' ( 60) |11111111|11111110|0 1fffc [17] 1225 '=' ( 61) |100111 27 [ 6] 1226 '>' ( 62) |11111111|1111101 7ffd [15] 1227 '?' ( 63) |11111111|01 3fd [10] 1228 '@' ( 64) |11111111|1111110 7ffe [15] 1229 'A' ( 65) |1100111 67 [ 7] 1230 'B' ( 66) |11101101| ed [ 8] 1231 'C' ( 67) |11101110| ee [ 8] 1232 'D' ( 68) |1101000 68 [ 7] 1233 'E' ( 69) |11101111| ef [ 8] 1234 'F' ( 70) |1101001 69 [ 7] 1235 'G' ( 71) |1101010 6a [ 7] 1236 'H' ( 72) |11111001|0 1f2 [ 9] 1237 'I' ( 73) |11110000| f0 [ 8] 1238 'J' ( 74) |11111001|1 1f3 [ 9] 1239 'K' ( 75) |11111010|0 1f4 [ 9] 1240 'L' ( 76) |11111010|1 1f5 [ 9] 1241 'M' ( 77) |1101011 6b [ 7] 1242 'N' ( 78) |1101100 6c [ 7] 1243 'O' ( 79) |11110001| f1 [ 8] 1244 'P' ( 80) |11110010| f2 [ 8] 1245 'Q' ( 81) |11111011|0 1f6 [ 9] 1246 'R' ( 82) |11111011|1 1f7 [ 9] 1247 'S' ( 83) |1101101 6d [ 7] 1248 'T' ( 84) |101000 28 [ 6] 1249 'U' ( 85) |11110011| f3 [ 8] 1250 'V' ( 86) |11111100|0 1f8 [ 9] 1251 'W' ( 87) |11111100|1 1f9 [ 9] 1252 'X' ( 88) |11110100| f4 [ 8] 1253 'Y' ( 89) |11111101|0 1fa [ 9] 1254 'Z' ( 90) |11111101|1 1fb [ 9] 1255 '[' ( 91) |11111111|100 7fc [11] 1256 '\' ( 92) |11111111|11111111|11110110|10 3ffffda [26] 1257 ']' ( 93) |11111111|101 7fd [11] 1258 '^' ( 94) |11111111|111101 3ffd [14] 1259 '_' ( 95) |1101110 6e [ 7] 1260 '`' ( 96) |11111111|11111111|10 3fffe [18] 1261 'a' ( 97) |01001 9 [ 5] 1262 'b' ( 98) |1101111 6f [ 7] 1263 'c' ( 99) |01010 a [ 5] 1264 'd' (100) |101001 29 [ 6] 1265 'e' (101) |01011 b [ 5] 1266 'f' (102) |1110000 70 [ 7] 1267 'g' (103) |101010 2a [ 6] 1268 'h' (104) |101011 2b [ 6] 1269 'i' (105) |01100 c [ 5] 1270 'j' (106) |11110101| f5 [ 8] 1271 'k' (107) |11110110| f6 [ 8] 1272 'l' (108) |101100 2c [ 6] 1273 'm' (109) |101101 2d [ 6] 1274 'n' (110) |101110 2e [ 6] 1275 'o' (111) |01101 d [ 5] 1276 'p' (112) |101111 2f [ 6] 1277 'q' (113) |11111110|0 1fc [ 9] 1278 'r' (114) |110000 30 [ 6] 1279 's' (115) |110001 31 [ 6] 1280 't' (116) |01110 e [ 5] 1281 'u' (117) |1110001 71 [ 7] 1282 'v' (118) |1110010 72 [ 7] 1283 'w' (119) |1110011 73 [ 7] 1284 'x' (120) |1110100 74 [ 7] 1285 'y' (121) |1110101 75 [ 7] 1286 'z' (122) |11110111| f7 [ 8] 1287 '{' (123) |11111111|11111110|1 1fffd [17] 1288 '|' (124) |11111111|1100 ffc [12] 1289 '}' (125) |11111111|11111111|0 1fffe [17] 1290 '~' (126) |11111111|1101 ffd [12] 1291 (127) |11111111|11111111|11110110|11 3ffffdb [26] 1292 (128) |11111111|11111111|11110111|00 3ffffdc [26] 1293 (129) |11111111|11111111|11110111|01 3ffffdd [26] 1294 (130) |11111111|11111111|11110111|10 3ffffde [26] 1295 (131) |11111111|11111111|11110111|11 3ffffdf [26] 1296 (132) |11111111|11111111|11111000|00 3ffffe0 [26] 1297 (133) |11111111|11111111|11111000|01 3ffffe1 [26] 1298 (134) |11111111|11111111|11111000|10 3ffffe2 [26] 1299 (135) |11111111|11111111|11111000|11 3ffffe3 [26] 1300 (136) |11111111|11111111|11111001|00 3ffffe4 [26] 1301 (137) |11111111|11111111|11111001|01 3ffffe5 [26] 1302 (138) |11111111|11111111|11111001|10 3ffffe6 [26] 1303 (139) |11111111|11111111|11111001|11 3ffffe7 [26] 1304 (140) |11111111|11111111|11111010|00 3ffffe8 [26] 1305 (141) |11111111|11111111|11111010|01 3ffffe9 [26] 1306 (142) |11111111|11111111|11111010|10 3ffffea [26] 1307 (143) |11111111|11111111|11111010|11 3ffffeb [26] 1308 (144) |11111111|11111111|11111011|00 3ffffec [26] 1309 (145) |11111111|11111111|11111011|01 3ffffed [26] 1310 (146) |11111111|11111111|11111011|10 3ffffee [26] 1311 (147) |11111111|11111111|11111011|11 3ffffef [26] 1312 (148) |11111111|11111111|11111100|00 3fffff0 [26] 1313 (149) |11111111|11111111|11111100|01 3fffff1 [26] 1314 (150) |11111111|11111111|11111100|10 3fffff2 [26] 1315 (151) |11111111|11111111|11111100|11 3fffff3 [26] 1316 (152) |11111111|11111111|11111101|00 3fffff4 [26] 1317 (153) |11111111|11111111|11111101|01 3fffff5 [26] 1318 (154) |11111111|11111111|11111101|10 3fffff6 [26] 1319 (155) |11111111|11111111|11111101|11 3fffff7 [26] 1320 (156) |11111111|11111111|11111110|00 3fffff8 [26] 1321 (157) |11111111|11111111|11111110|01 3fffff9 [26] 1322 (158) |11111111|11111111|11111110|10 3fffffa [26] 1323 (159) |11111111|11111111|11111110|11 3fffffb [26] 1324 (160) |11111111|11111111|11111111|00 3fffffc [26] 1325 (161) |11111111|11111111|11111111|01 3fffffd [26] 1326 (162) |11111111|11111111|11111111|10 3fffffe [26] 1327 (163) |11111111|11111111|11111111|11 3ffffff [26] 1328 (164) |11111111|11111111|11000000|0 1ffff80 [25] 1329 (165) |11111111|11111111|11000000|1 1ffff81 [25] 1330 (166) |11111111|11111111|11000001|0 1ffff82 [25] 1331 (167) |11111111|11111111|11000001|1 1ffff83 [25] 1332 (168) |11111111|11111111|11000010|0 1ffff84 [25] 1333 (169) |11111111|11111111|11000010|1 1ffff85 [25] 1334 (170) |11111111|11111111|11000011|0 1ffff86 [25] 1335 (171) |11111111|11111111|11000011|1 1ffff87 [25] 1336 (172) |11111111|11111111|11000100|0 1ffff88 [25] 1337 (173) |11111111|11111111|11000100|1 1ffff89 [25] 1338 (174) |11111111|11111111|11000101|0 1ffff8a [25] 1339 (175) |11111111|11111111|11000101|1 1ffff8b [25] 1340 (176) |11111111|11111111|11000110|0 1ffff8c [25] 1341 (177) |11111111|11111111|11000110|1 1ffff8d [25] 1342 (178) |11111111|11111111|11000111|0 1ffff8e [25] 1343 (179) |11111111|11111111|11000111|1 1ffff8f [25] 1344 (180) |11111111|11111111|11001000|0 1ffff90 [25] 1345 (181) |11111111|11111111|11001000|1 1ffff91 [25] 1346 (182) |11111111|11111111|11001001|0 1ffff92 [25] 1347 (183) |11111111|11111111|11001001|1 1ffff93 [25] 1348 (184) |11111111|11111111|11001010|0 1ffff94 [25] 1349 (185) |11111111|11111111|11001010|1 1ffff95 [25] 1350 (186) |11111111|11111111|11001011|0 1ffff96 [25] 1351 (187) |11111111|11111111|11001011|1 1ffff97 [25] 1352 (188) |11111111|11111111|11001100|0 1ffff98 [25] 1353 (189) |11111111|11111111|11001100|1 1ffff99 [25] 1354 (190) |11111111|11111111|11001101|0 1ffff9a [25] 1355 (191) |11111111|11111111|11001101|1 1ffff9b [25] 1356 (192) |11111111|11111111|11001110|0 1ffff9c [25] 1357 (193) |11111111|11111111|11001110|1 1ffff9d [25] 1358 (194) |11111111|11111111|11001111|0 1ffff9e [25] 1359 (195) |11111111|11111111|11001111|1 1ffff9f [25] 1360 (196) |11111111|11111111|11010000|0 1ffffa0 [25] 1361 (197) |11111111|11111111|11010000|1 1ffffa1 [25] 1362 (198) |11111111|11111111|11010001|0 1ffffa2 [25] 1363 (199) |11111111|11111111|11010001|1 1ffffa3 [25] 1364 (200) |11111111|11111111|11010010|0 1ffffa4 [25] 1365 (201) |11111111|11111111|11010010|1 1ffffa5 [25] 1366 (202) |11111111|11111111|11010011|0 1ffffa6 [25] 1367 (203) |11111111|11111111|11010011|1 1ffffa7 [25] 1368 (204) |11111111|11111111|11010100|0 1ffffa8 [25] 1369 (205) |11111111|11111111|11010100|1 1ffffa9 [25] 1370 (206) |11111111|11111111|11010101|0 1ffffaa [25] 1371 (207) |11111111|11111111|11010101|1 1ffffab [25] 1372 (208) |11111111|11111111|11010110|0 1ffffac [25] 1373 (209) |11111111|11111111|11010110|1 1ffffad [25] 1374 (210) |11111111|11111111|11010111|0 1ffffae [25] 1375 (211) |11111111|11111111|11010111|1 1ffffaf [25] 1376 (212) |11111111|11111111|11011000|0 1ffffb0 [25] 1377 (213) |11111111|11111111|11011000|1 1ffffb1 [25] 1378 (214) |11111111|11111111|11011001|0 1ffffb2 [25] 1379 (215) |11111111|11111111|11011001|1 1ffffb3 [25] 1380 (216) |11111111|11111111|11011010|0 1ffffb4 [25] 1381 (217) |11111111|11111111|11011010|1 1ffffb5 [25] 1382 (218) |11111111|11111111|11011011|0 1ffffb6 [25] 1383 (219) |11111111|11111111|11011011|1 1ffffb7 [25] 1384 (220) |11111111|11111111|11011100|0 1ffffb8 [25] 1385 (221) |11111111|11111111|11011100|1 1ffffb9 [25] 1386 (222) |11111111|11111111|11011101|0 1ffffba [25] 1387 (223) |11111111|11111111|11011101|1 1ffffbb [25] 1388 (224) |11111111|11111111|11011110|0 1ffffbc [25] 1389 (225) |11111111|11111111|11011110|1 1ffffbd [25] 1390 (226) |11111111|11111111|11011111|0 1ffffbe [25] 1391 (227) |11111111|11111111|11011111|1 1ffffbf [25] 1392 (228) |11111111|11111111|11100000|0 1ffffc0 [25] 1393 (229) |11111111|11111111|11100000|1 1ffffc1 [25] 1394 (230) |11111111|11111111|11100001|0 1ffffc2 [25] 1395 (231) |11111111|11111111|11100001|1 1ffffc3 [25] 1396 (232) |11111111|11111111|11100010|0 1ffffc4 [25] 1397 (233) |11111111|11111111|11100010|1 1ffffc5 [25] 1398 (234) |11111111|11111111|11100011|0 1ffffc6 [25] 1399 (235) |11111111|11111111|11100011|1 1ffffc7 [25] 1400 (236) |11111111|11111111|11100100|0 1ffffc8 [25] 1401 (237) |11111111|11111111|11100100|1 1ffffc9 [25] 1402 (238) |11111111|11111111|11100101|0 1ffffca [25] 1403 (239) |11111111|11111111|11100101|1 1ffffcb [25] 1404 (240) |11111111|11111111|11100110|0 1ffffcc [25] 1405 (241) |11111111|11111111|11100110|1 1ffffcd [25] 1406 (242) |11111111|11111111|11100111|0 1ffffce [25] 1407 (243) |11111111|11111111|11100111|1 1ffffcf [25] 1408 (244) |11111111|11111111|11101000|0 1ffffd0 [25] 1409 (245) |11111111|11111111|11101000|1 1ffffd1 [25] 1410 (246) |11111111|11111111|11101001|0 1ffffd2 [25] 1411 (247) |11111111|11111111|11101001|1 1ffffd3 [25] 1412 (248) |11111111|11111111|11101010|0 1ffffd4 [25] 1413 (249) |11111111|11111111|11101010|1 1ffffd5 [25] 1414 (250) |11111111|11111111|11101011|0 1ffffd6 [25] 1415 (251) |11111111|11111111|11101011|1 1ffffd7 [25] 1416 (252) |11111111|11111111|11101100|0 1ffffd8 [25] 1417 (253) |11111111|11111111|11101100|1 1ffffd9 [25] 1418 (254) |11111111|11111111|11101101|0 1ffffda [25] 1419 (255) |11111111|11111111|11101101|1 1ffffdb [25] 1420 EOS (256) |11111111|11111111|11101110|0 1ffffdc [25] 1422 Appendix D. Examples 1424 A number of examples are worked through here, covering integer 1425 encoding, header field representation, and the encoding of whole sets 1426 of header fields, for both requests and responses, and with and 1427 without Huffman coding. 1429 D.1. Integer Representation Examples 1431 This section shows the representation of integer values in details 1432 (see Section 4.1.1). 1434 D.1.1. Example 1: Encoding 10 using a 5-bit prefix 1436 The value 10 is to be encoded with a 5-bit prefix. 1438 o 10 is less than 31 (2^5 - 1) and is represented using the 5-bit 1439 prefix. 1441 0 1 2 3 4 5 6 7 1442 +---+---+---+---+---+---+---+---+ 1443 | X | X | X | 0 | 1 | 0 | 1 | 0 | 10 stored on 5 bits 1444 +---+---+---+---+---+---+---+---+ 1446 D.1.2. Example 2: Encoding 1337 using a 5-bit prefix 1448 The value I=1337 is to be encoded with a 5-bit prefix. 1450 1337 is greater than 31 (2^5 - 1). 1452 The 5-bit prefix is filled with its max value (31). 1454 I = 1337 - (2^5 - 1) = 1306. 1456 I (1306) is greater than or equal to 128, the while loop body 1457 executes: 1459 I % 128 == 26 1461 26 + 128 == 154 1462 154 is encoded in 8 bits as: 10011010 1464 I is set to 10 (1306 / 128 == 10) 1466 I is no longer greater than or equal to 128, the while loop 1467 terminates. 1469 I, now 10, is encoded on 8 bits as: 00001010. 1471 The process ends. 1473 0 1 2 3 4 5 6 7 1474 +---+---+---+---+---+---+---+---+ 1475 | X | X | X | 1 | 1 | 1 | 1 | 1 | Prefix = 31, I = 1306 1476 | 1 | 0 | 0 | 1 | 1 | 0 | 1 | 0 | 1306>=128, encode(154), I=1306/128 1477 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 10<128, encode(10), done 1478 +---+---+---+---+---+---+---+---+ 1480 D.1.3. Example 3: Encoding 42 starting at an octet-boundary 1482 The value 42 is to be encoded starting at an octet-boundary. This 1483 implies that a 8-bit prefix is used. 1485 o 42 is less than 255 (2^8 - 1) and is represented using the 8-bit 1486 prefix. 1488 0 1 2 3 4 5 6 7 1489 +---+---+---+---+---+---+---+---+ 1490 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 42 stored on 8 bits 1491 +---+---+---+---+---+---+---+---+ 1493 D.2. Header Field Representation Examples 1495 This section shows several independent representation examples. 1497 D.2.1. Literal Header Field with Indexing 1499 The header field representation uses a literal name and a literal 1500 value. 1502 Header set to encode: 1504 custom-key: custom-header 1506 Reference set: empty. 1508 Hex dump of encoded data: 1510 400a 6375 7374 6f6d 2d6b 6579 0d63 7573 | @.custom-key.cus 1511 746f 6d2d 6865 6164 6572 | tom-header 1513 Decoding process: 1515 40 | == Literal indexed == 1516 0a | Literal name (len = 10) 1517 6375 7374 6f6d 2d6b 6579 | custom-key 1518 0d | Literal value (len = 13) 1519 6375 7374 6f6d 2d68 6561 6465 72 | custom-header 1520 | -> custom-key: custom-head\ 1521 | er 1523 Header Table (after decoding): 1525 [ 1] (s = 55) custom-key: custom-header 1526 Table size: 55 1528 Decoded header set: 1530 custom-key: custom-header 1532 D.2.2. Literal Header Field without Indexing 1534 The header field representation uses an indexed name and a literal 1535 value. 1537 Header set to encode: 1539 :path: /sample/path 1541 Reference set: empty. 1543 Hex dump of encoded data: 1545 040c 2f73 616d 706c 652f 7061 7468 | ../sample/path 1547 Decoding process: 1549 04 | == Literal not indexed == 1550 | Indexed name (idx = 4) 1551 | :path 1552 0c | Literal value (len = 12) 1553 2f73 616d 706c 652f 7061 7468 | /sample/path 1554 | -> :path: /sample/path 1556 Header table (after decoding): empty. 1558 Decoded header set: 1560 :path: /sample/path 1562 D.2.3. Indexed Header Field 1564 The header field representation uses an indexed header field, from 1565 the static table. Upon using it, the static table entry is copied 1566 into the header table. 1568 Header set to encode: 1570 :method: GET 1572 Reference set: empty. 1574 Hex dump of encoded data: 1576 82 | . 1578 Decoding process: 1580 82 | == Indexed - Add == 1581 | idx = 2 1582 | -> :method: GET 1584 Header Table (after decoding): 1586 [ 1] (s = 42) :method: GET 1587 Table size: 42 1589 Decoded header set: 1591 :method: GET 1593 D.2.4. Indexed Header Field from Static Table 1595 The header field representation uses an indexed header field, from 1596 the static table. In this example, the SETTINGS_HEADER_TABLE_SIZE is 1597 set to 0, therefore, the entry is not copied into the header table. 1599 Header set to encode: 1601 :method: GET 1603 Reference set: empty. 1605 Hex dump of encoded data: 1607 82 | . 1609 Decoding process: 1611 82 | == Indexed - Add == 1612 | idx = 2 1613 | -> :method: GET 1615 Header table (after decoding): empty. 1617 Decoded header set: 1619 :method: GET 1621 D.3. Request Examples without Huffman 1623 This section shows several consecutive header sets, corresponding to 1624 HTTP requests, on the same connection. 1626 D.3.1. First request 1627 Header set to encode: 1629 :method: GET 1630 :scheme: http 1631 :path: / 1632 :authority: www.example.com 1634 Reference set: empty. 1636 Hex dump of encoded data: 1638 8287 8644 0f77 7777 2e65 7861 6d70 6c65 | ...D.www.example 1639 2e63 6f6d | .com 1641 Decoding process: 1643 82 | == Indexed - Add == 1644 | idx = 2 1645 | -> :method: GET 1646 87 | == Indexed - Add == 1647 | idx = 7 1648 | -> :scheme: http 1649 86 | == Indexed - Add == 1650 | idx = 6 1651 | -> :path: / 1652 44 | == Literal indexed == 1653 | Indexed name (idx = 4) 1654 | :authority 1655 0f | Literal value (len = 15) 1656 7777 772e 6578 616d 706c 652e 636f 6d | www.example.com 1657 | -> :authority: www.example\ 1658 | .com 1660 Header Table (after decoding): 1662 [ 1] (s = 57) :authority: www.example.com 1663 [ 2] (s = 38) :path: / 1664 [ 3] (s = 43) :scheme: http 1665 [ 4] (s = 42) :method: GET 1666 Table size: 180 1668 Decoded header set: 1670 :method: GET 1671 :scheme: http 1672 :path: / 1673 :authority: www.example.com 1675 D.3.2. Second request 1677 This request takes advantage of the differential encoding of header 1678 sets. 1680 Header set to encode: 1682 :method: GET 1683 :scheme: http 1684 :path: / 1685 :authority: www.example.com 1686 cache-control: no-cache 1688 Reference set: 1690 [ 1] :authority: www.example.com 1691 [ 2] :path: / 1692 [ 3] :scheme: http 1693 [ 4] :method: GET 1695 Hex dump of encoded data: 1697 5c08 6e6f 2d63 6163 6865 | \.no-cache 1699 Decoding process: 1701 5c | == Literal indexed == 1702 | Indexed name (idx = 28) 1703 | cache-control 1704 08 | Literal value (len = 8) 1705 6e6f 2d63 6163 6865 | no-cache 1706 | -> cache-control: no-cache 1708 Header Table (after decoding): 1710 [ 1] (s = 53) cache-control: no-cache 1711 [ 2] (s = 57) :authority: www.example.com 1712 [ 3] (s = 38) :path: / 1713 [ 4] (s = 43) :scheme: http 1714 [ 5] (s = 42) :method: GET 1715 Table size: 233 1717 Decoded header set: 1719 cache-control: no-cache 1720 :authority: www.example.com 1721 :path: / 1722 :scheme: http 1723 :method: GET 1725 D.3.3. Third request 1727 This request has not enough headers in common with the previous 1728 request to take advantage of the differential encoding. Therefore, 1729 the reference set is emptied before encoding the header fields. 1731 Header set to encode: 1733 :method: GET 1734 :scheme: https 1735 :path: /index.html 1736 :authority: www.example.com 1737 custom-key: custom-value 1739 Reference set: 1741 [ 1] cache-control: no-cache 1742 [ 2] :authority: www.example.com 1743 [ 3] :path: / 1744 [ 4] :scheme: http 1745 [ 5] :method: GET 1747 Hex dump of encoded data: 1749 3085 8c8b 8440 0a63 7573 746f 6d2d 6b65 | 0....@.custom-ke 1750 790c 6375 7374 6f6d 2d76 616c 7565 | y.custom-value 1751 Decoding process: 1753 30 | == Empty reference set == 1754 | idx = 0 1755 | flag = 1 1756 85 | == Indexed - Add == 1757 | idx = 5 1758 | -> :method: GET 1759 8c | == Indexed - Add == 1760 | idx = 12 1761 | -> :scheme: https 1762 8b | == Indexed - Add == 1763 | idx = 11 1764 | -> :path: /index.html 1765 84 | == Indexed - Add == 1766 | idx = 4 1767 | -> :authority: www.example\ 1768 | .com 1769 40 | == Literal indexed == 1770 0a | Literal name (len = 10) 1771 6375 7374 6f6d 2d6b 6579 | custom-key 1772 0c | Literal value (len = 12) 1773 6375 7374 6f6d 2d76 616c 7565 | custom-value 1774 | -> custom-key: custom-valu\ 1775 | e 1777 Header Table (after decoding): 1779 [ 1] (s = 54) custom-key: custom-value 1780 [ 2] (s = 48) :path: /index.html 1781 [ 3] (s = 44) :scheme: https 1782 [ 4] (s = 53) cache-control: no-cache 1783 [ 5] (s = 57) :authority: www.example.com 1784 [ 6] (s = 38) :path: / 1785 [ 7] (s = 43) :scheme: http 1786 [ 8] (s = 42) :method: GET 1787 Table size: 379 1789 Decoded header set: 1791 :method: GET 1792 :scheme: https 1793 :path: /index.html 1794 :authority: www.example.com 1795 custom-key: custom-value 1797 D.4. Request Examples with Huffman 1799 This section shows the same examples as the previous section, but 1800 using Huffman encoding for the literal values. 1802 D.4.1. First request 1804 Header set to encode: 1806 :method: GET 1807 :scheme: http 1808 :path: / 1809 :authority: www.example.com 1811 Reference set: empty. 1813 Hex dump of encoded data: 1815 8287 8644 8ce7 cf9b ebe8 9b6f b16f a9b6 | ...D.......o.o.. 1816 ff | . 1818 Decoding process: 1820 82 | == Indexed - Add == 1821 | idx = 2 1822 | -> :method: GET 1823 87 | == Indexed - Add == 1824 | idx = 7 1825 | -> :scheme: http 1826 86 | == Indexed - Add == 1827 | idx = 6 1828 | -> :path: / 1829 44 | == Literal indexed == 1830 | Indexed name (idx = 4) 1831 | :authority 1832 8c | Literal value (len = 15) 1833 | Huffman encoded: 1834 e7cf 9beb e89b 6fb1 6fa9 b6ff | ......o.o... 1835 | Decoded: 1836 | www.example.com 1837 | -> :authority: www.example\ 1838 | .com 1840 Header Table (after decoding): 1842 [ 1] (s = 57) :authority: www.example.com 1843 [ 2] (s = 38) :path: / 1844 [ 3] (s = 43) :scheme: http 1845 [ 4] (s = 42) :method: GET 1846 Table size: 180 1848 Decoded header set: 1850 :method: GET 1851 :scheme: http 1852 :path: / 1853 :authority: www.example.com 1855 D.4.2. Second request 1857 This request takes advantage of the differential encoding of header 1858 sets. 1860 Header set to encode: 1862 :method: GET 1863 :scheme: http 1864 :path: / 1865 :authority: www.example.com 1866 cache-control: no-cache 1868 Reference set: 1870 [ 1] :authority: www.example.com 1871 [ 2] :path: / 1872 [ 3] :scheme: http 1873 [ 4] :method: GET 1875 Hex dump of encoded data: 1877 5c86 b9b9 9495 56bf | \.....V. 1879 Decoding process: 1881 5c | == Literal indexed == 1882 | Indexed name (idx = 28) 1883 | cache-control 1884 86 | Literal value (len = 8) 1885 | Huffman encoded: 1886 b9b9 9495 56bf | ....V. 1887 | Decoded: 1888 | no-cache 1889 | -> cache-control: no-cache 1891 Header Table (after decoding): 1893 [ 1] (s = 53) cache-control: no-cache 1894 [ 2] (s = 57) :authority: www.example.com 1895 [ 3] (s = 38) :path: / 1896 [ 4] (s = 43) :scheme: http 1897 [ 5] (s = 42) :method: GET 1898 Table size: 233 1900 Decoded header set: 1902 cache-control: no-cache 1903 :authority: www.example.com 1904 :path: / 1905 :scheme: http 1906 :method: GET 1908 D.4.3. Third request 1910 This request has not enough headers in common with the previous 1911 request to take advantage of the differential encoding. Therefore, 1912 the reference set is emptied before encoding the header fields. 1914 Header set to encode: 1916 :method: GET 1917 :scheme: https 1918 :path: /index.html 1919 :authority: www.example.com 1920 custom-key: custom-value 1922 Reference set: 1924 [ 1] cache-control: no-cache 1925 [ 2] :authority: www.example.com 1926 [ 3] :path: / 1927 [ 4] :scheme: http 1928 [ 5] :method: GET 1930 Hex dump of encoded data: 1932 3085 8c8b 8440 8857 1c5c db73 7b2f af89 | 0....@.W.\.s{/.. 1933 571c 5cdb 7372 4d9c 57 | W.\.srM.W 1935 Decoding process: 1937 30 | == Empty reference set == 1938 | idx = 0 1939 | flag = 1 1940 85 | == Indexed - Add == 1941 | idx = 5 1942 | -> :method: GET 1943 8c | == Indexed - Add == 1944 | idx = 12 1945 | -> :scheme: https 1946 8b | == Indexed - Add == 1947 | idx = 11 1948 | -> :path: /index.html 1949 84 | == Indexed - Add == 1950 | idx = 4 1951 | -> :authority: www.example\ 1952 | .com 1953 40 | == Literal indexed == 1954 88 | Literal name (len = 10) 1955 | Huffman encoded: 1956 571c 5cdb 737b 2faf | W.\.s{/. 1957 | Decoded: 1958 | custom-key 1959 89 | Literal value (len = 12) 1960 | Huffman encoded: 1961 571c 5cdb 7372 4d9c 57 | W.\.srM.W 1962 | Decoded: 1963 | custom-value 1964 | -> custom-key: custom-valu\ 1965 | e 1967 Header Table (after decoding): 1969 [ 1] (s = 54) custom-key: custom-value 1970 [ 2] (s = 48) :path: /index.html 1971 [ 3] (s = 44) :scheme: https 1972 [ 4] (s = 53) cache-control: no-cache 1973 [ 5] (s = 57) :authority: www.example.com 1974 [ 6] (s = 38) :path: / 1975 [ 7] (s = 43) :scheme: http 1976 [ 8] (s = 42) :method: GET 1977 Table size: 379 1979 Decoded header set: 1981 :method: GET 1982 :scheme: https 1983 :path: /index.html 1984 :authority: www.example.com 1985 custom-key: custom-value 1987 D.5. Response Examples without Huffman 1989 This section shows several consecutive header sets, corresponding to 1990 HTTP responses, on the same connection. SETTINGS_HEADER_TABLE_SIZE 1991 is set to the value of 256 octets, causing some evictions to occur. 1993 D.5.1. First response 1995 Header set to encode: 1997 :status: 302 1998 cache-control: private 1999 date: Mon, 21 Oct 2013 20:13:21 GMT 2000 location: https://www.example.com 2002 Reference set: empty. 2004 Hex dump of encoded data: 2006 4803 3330 3259 0770 7269 7661 7465 631d | H.302Y.privatec. 2007 4d6f 6e2c 2032 3120 4f63 7420 3230 3133 | Mon, 21 Oct 2013 2008 2032 303a 3133 3a32 3120 474d 5471 1768 | 20:13:21 GMTq.h 2009 7474 7073 3a2f 2f77 7777 2e65 7861 6d70 | ttps://www.examp 2010 6c65 2e63 6f6d | le.com 2011 Decoding process: 2013 48 | == Literal indexed == 2014 | Indexed name (idx = 8) 2015 | :status 2016 03 | Literal value (len = 3) 2017 3330 32 | 302 2018 | -> :status: 302 2019 59 | == Literal indexed == 2020 | Indexed name (idx = 25) 2021 | cache-control 2022 07 | Literal value (len = 7) 2023 7072 6976 6174 65 | private 2024 | -> cache-control: private 2025 63 | == Literal indexed == 2026 | Indexed name (idx = 35) 2027 | date 2028 1d | Literal value (len = 29) 2029 4d6f 6e2c 2032 3120 4f63 7420 3230 3133 | Mon, 21 Oct 2013 2030 2032 303a 3133 3a32 3120 474d 54 | 20:13:21 GMT 2031 | -> date: Mon, 21 Oct 2013 \ 2032 | 20:13:21 GMT 2033 71 | == Literal indexed == 2034 | Indexed name (idx = 49) 2035 | location 2036 17 | Literal value (len = 23) 2037 6874 7470 733a 2f2f 7777 772e 6578 616d | https://www.exam 2038 706c 652e 636f 6d | ple.com 2039 | -> location: https://www.e\ 2040 | xample.com 2042 Header Table (after decoding): 2044 [ 1] (s = 63) location: https://www.example.com 2045 [ 2] (s = 65) date: Mon, 21 Oct 2013 20:13:21 GMT 2046 [ 3] (s = 52) cache-control: private 2047 [ 4] (s = 42) :status: 302 2048 Table size: 222 2050 Decoded header set: 2052 :status: 302 2053 cache-control: private 2054 date: Mon, 21 Oct 2013 20:13:21 GMT 2055 location: https://www.example.com 2057 D.5.2. Second response 2059 The (":status", "302") header field is evicted from the header table 2060 to free space to allow adding the (":status", "200") header field, 2061 copied from the static table into the header table. The (":status", 2062 "302") header field doesn't need to be removed from the reference set 2063 as it is evicted from the header table. 2065 Header set to encode: 2067 :status: 200 2068 cache-control: private 2069 date: Mon, 21 Oct 2013 20:13:21 GMT 2070 location: https://www.example.com 2072 Reference set: 2074 [ 1] location: https://www.example.com 2075 [ 2] date: Mon, 21 Oct 2013 20:13:21 GMT 2076 [ 3] cache-control: private 2077 [ 4] :status: 302 2079 Hex dump of encoded data: 2081 8c | . 2083 Decoding process: 2085 8c | == Indexed - Add == 2086 | idx = 12 2087 | - evict: :status: 302 2088 | -> :status: 200 2090 Header Table (after decoding): 2092 [ 1] (s = 42) :status: 200 2093 [ 2] (s = 63) location: https://www.example.com 2094 [ 3] (s = 65) date: Mon, 21 Oct 2013 20:13:21 GMT 2095 [ 4] (s = 52) cache-control: private 2096 Table size: 222 2098 Decoded header set: 2100 :status: 200 2101 location: https://www.example.com 2102 date: Mon, 21 Oct 2013 20:13:21 GMT 2103 cache-control: private 2105 D.5.3. Third response 2107 Several header fields are evicted from the header table during the 2108 processing of this header set. Before evicting a header belonging to 2109 the reference set, it is emitted, by coding it twice as an Indexed 2110 Representation. The first representation removes the header field 2111 from the reference set, the second one adds it again to the reference 2112 set, also emitting it. 2114 Header set to encode: 2116 :status: 200 2117 cache-control: private 2118 date: Mon, 21 Oct 2013 20:13:22 GMT 2119 location: https://www.example.com 2120 content-encoding: gzip 2121 set-cookie: foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1 2123 Reference set: 2125 [ 1] :status: 200 2126 [ 2] location: https://www.example.com 2127 [ 3] date: Mon, 21 Oct 2013 20:13:21 GMT 2128 [ 4] cache-control: private 2130 Hex dump of encoded data: 2132 8484 431d 4d6f 6e2c 2032 3120 4f63 7420 | ..C.Mon, 21 Oct 2133 3230 3133 2032 303a 3133 3a32 3220 474d | 2013 20:13:22 GM 2134 545e 0467 7a69 7084 8483 837b 3866 6f6f | T^.gzip....{8foo 2135 3d41 5344 4a4b 4851 4b42 5a58 4f51 5745 | =ASDJKHQKBZXOQWE 2136 4f50 4955 4158 5157 454f 4955 3b20 6d61 | OPIUAXQWEOIU; ma 2137 782d 6167 653d 3336 3030 3b20 7665 7273 | x-age=3600; vers 2138 696f 6e3d 31 | ion=1 2140 Decoding process: 2142 84 | == Indexed - Remove == 2143 | idx = 4 2144 | -> cache-control: private 2145 84 | == Indexed - Add == 2146 | idx = 4 2147 | -> cache-control: private 2148 43 | == Literal indexed == 2149 | Indexed name (idx = 3) 2150 | date 2151 1d | Literal value (len = 29) 2152 4d6f 6e2c 2032 3120 4f63 7420 3230 3133 | Mon, 21 Oct 2013 2153 2032 303a 3133 3a32 3220 474d 54 | 20:13:22 GMT 2154 | - evict: cache-control: pr\ 2155 | ivate 2156 | -> date: Mon, 21 Oct 2013 \ 2157 | 20:13:22 GMT 2158 5e | == Literal indexed == 2159 | Indexed name (idx = 30) 2160 | content-encoding 2161 04 | Literal value (len = 4) 2162 677a 6970 | gzip 2163 | - evict: date: Mon, 21 Oct\ 2164 | 2013 20:13:21 GMT 2165 | -> content-encoding: gzip 2166 84 | == Indexed - Remove == 2167 | idx = 4 2168 | -> location: https://www.e\ 2169 | xample.com 2170 84 | == Indexed - Add == 2171 | idx = 4 2172 | -> location: https://www.e\ 2173 | xample.com 2174 83 | == Indexed - Remove == 2175 | idx = 3 2176 | -> :status: 200 2177 83 | == Indexed - Add == 2178 | idx = 3 2179 | -> :status: 200 2180 7b | == Literal indexed == 2181 | Indexed name (idx = 59) 2182 | set-cookie 2183 38 | Literal value (len = 56) 2184 666f 6f3d 4153 444a 4b48 514b 425a 584f | foo=ASDJKHQKBZXO 2185 5157 454f 5049 5541 5851 5745 4f49 553b | QWEOPIUAXQWEOIU; 2186 206d 6178 2d61 6765 3d33 3630 303b 2076 | max-age=3600; v 2187 6572 7369 6f6e 3d31 | ersion=1 2188 | - evict: location: https:/\ 2189 | /www.example.com 2190 | - evict: :status: 200 2191 | -> set-cookie: foo=ASDJKHQ\ 2192 | KBZXOQWEOPIUAXQWEOIU; ma\ 2193 | x-age=3600; version=1 2195 Header Table (after decoding): 2197 [ 1] (s = 98) set-cookie: foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age\ 2198 =3600; version=1 2199 [ 2] (s = 52) content-encoding: gzip 2200 [ 3] (s = 65) date: Mon, 21 Oct 2013 20:13:22 GMT 2201 Table size: 215 2203 Decoded header set: 2205 cache-control: private 2206 date: Mon, 21 Oct 2013 20:13:22 GMT 2207 content-encoding: gzip 2208 location: https://www.example.com 2209 :status: 200 2210 set-cookie: foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1 2212 D.6. Response Examples with Huffman 2214 This section shows the same examples as the previous section, but 2215 using Huffman encoding for the literal values. The eviction 2216 mechanism uses the length of the decoded literal values, so the same 2217 evictions occurs as in the previous section. 2219 D.6.1. First response 2221 Header set to encode: 2223 :status: 302 2224 cache-control: private 2225 date: Mon, 21 Oct 2013 20:13:21 GMT 2226 location: https://www.example.com 2228 Reference set: empty. 2230 Hex dump of encoded data: 2232 4882 4017 5985 bf06 724b 9763 93d6 dbb2 | H.@.Y...rK.c.... 2233 9884 de2a 7188 0506 2098 5131 09b5 6ba3 | ...*q... .Q1..k. 2234 7191 adce bf19 8e7e 7cf9 bebe 89b6 fb16 | q.......|....... 2235 fa9b 6f | ..o 2237 Decoding process: 2239 48 | == Literal indexed == 2240 | Indexed name (idx = 8) 2241 | :status 2242 82 | Literal value (len = 3) 2243 | Huffman encoded: 2244 4017 | @. 2245 | Decoded: 2246 | 302 2247 | -> :status: 302 2248 59 | == Literal indexed == 2249 | Indexed name (idx = 25) 2250 | cache-control 2251 85 | Literal value (len = 7) 2252 | Huffman encoded: 2253 bf06 724b 97 | ..rK. 2254 | Decoded: 2255 | private 2256 | -> cache-control: private 2257 63 | == Literal indexed == 2258 | Indexed name (idx = 35) 2259 | date 2260 93 | Literal value (len = 29) 2261 | Huffman encoded: 2262 d6db b298 84de 2a71 8805 0620 9851 3109 | ......*q... .Q1. 2263 b56b a3 | .k. 2264 | Decoded: 2265 | Mon, 21 Oct 2013 20:13:21 \ 2266 | GMT 2267 | -> date: Mon, 21 Oct 2013 \ 2268 | 20:13:21 GMT 2269 71 | == Literal indexed == 2270 | Indexed name (idx = 49) 2271 | location 2272 91 | Literal value (len = 23) 2273 | Huffman encoded: 2274 adce bf19 8e7e 7cf9 bebe 89b6 fb16 fa9b | ......|......... 2275 6f | o 2276 | Decoded: 2277 | https://www.example.com 2278 | -> location: https://www.e\ 2279 | xample.com 2281 Header Table (after decoding): 2283 [ 1] (s = 63) location: https://www.example.com 2284 [ 2] (s = 65) date: Mon, 21 Oct 2013 20:13:21 GMT 2285 [ 3] (s = 52) cache-control: private 2286 [ 4] (s = 42) :status: 302 2287 Table size: 222 2289 Decoded header set: 2291 :status: 302 2292 cache-control: private 2293 date: Mon, 21 Oct 2013 20:13:21 GMT 2294 location: https://www.example.com 2296 D.6.2. Second response 2298 The (":status", "302") header field is evicted from the header table 2299 to free space to allow adding the (":status", "200") header field, 2300 copied from the static table into the header table. The (":status", 2301 "302") header field doesn't need to be removed from the reference set 2302 as it is evicted from the header table. 2304 Header set to encode: 2306 :status: 200 2307 cache-control: private 2308 date: Mon, 21 Oct 2013 20:13:21 GMT 2309 location: https://www.example.com 2311 Reference set: 2313 [ 1] location: https://www.example.com 2314 [ 2] date: Mon, 21 Oct 2013 20:13:21 GMT 2315 [ 3] cache-control: private 2316 [ 4] :status: 302 2318 Hex dump of encoded data: 2320 8c | . 2322 Decoding process: 2324 8c | == Indexed - Add == 2325 | idx = 12 2326 | - evict: :status: 302 2327 | -> :status: 200 2329 Header Table (after decoding): 2331 [ 1] (s = 42) :status: 200 2332 [ 2] (s = 63) location: https://www.example.com 2333 [ 3] (s = 65) date: Mon, 21 Oct 2013 20:13:21 GMT 2334 [ 4] (s = 52) cache-control: private 2335 Table size: 222 2337 Decoded header set: 2339 :status: 200 2340 location: https://www.example.com 2341 date: Mon, 21 Oct 2013 20:13:21 GMT 2342 cache-control: private 2344 D.6.3. Third response 2346 Several header fields are evicted from the header table during the 2347 processing of this header set. Before evicting a header belonging to 2348 the reference set, it is emitted, by coding it twice as an Indexed 2349 Representation. The first representation removes the header field 2350 from the reference set, the second one adds it again to the reference 2351 set, also emitting it. 2353 Header set to encode: 2355 :status: 200 2356 cache-control: private 2357 date: Mon, 21 Oct 2013 20:13:22 GMT 2358 location: https://www.example.com 2359 content-encoding: gzip 2360 set-cookie: foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1 2361 Reference set: 2363 [ 1] :status: 200 2364 [ 2] location: https://www.example.com 2365 [ 3] date: Mon, 21 Oct 2013 20:13:21 GMT 2366 [ 4] cache-control: private 2368 Hex dump of encoded data: 2370 8484 4393 d6db b298 84de 2a71 8805 0620 | ..C.......*q... 2371 9851 3111 b56b a35e 84ab dd97 ff84 8483 | .Q1..k.^........ 2372 837b b1e0 d6cf 9f6e 8f9f d3e5 f6fa 76fe | .{.....n......v. 2373 fd3c 7edf 9eff 1f2f 0f3c fe9f 6fcf 7f8f | ......./....o... 2374 879f 61ad 4f4c c9a9 73a2 200e c372 5e18 | ..a.OL..s. ..r^. 2375 b1b7 4e3f | ..N? 2377 Decoding process: 2379 84 | == Indexed - Remove == 2380 | idx = 4 2381 | -> cache-control: private 2382 84 | == Indexed - Add == 2383 | idx = 4 2384 | -> cache-control: private 2385 43 | == Literal indexed == 2386 | Indexed name (idx = 3) 2387 | date 2388 93 | Literal value (len = 29) 2389 | Huffman encoded: 2390 d6db b298 84de 2a71 8805 0620 9851 3111 | ......*q... .Q1. 2391 b56b a3 | .k. 2392 | Decoded: 2393 | Mon, 21 Oct 2013 20:13:22 \ 2394 | GMT 2395 | - evict: cache-control: pr\ 2396 | ivate 2397 | -> date: Mon, 21 Oct 2013 \ 2398 | 20:13:22 GMT 2399 5e | == Literal indexed == 2400 | Indexed name (idx = 30) 2401 | content-encoding 2402 84 | Literal value (len = 4) 2403 | Huffman encoded: 2404 abdd 97ff | .... 2405 | Decoded: 2406 | gzip 2407 | - evict: date: Mon, 21 Oct\ 2408 | 2013 20:13:21 GMT 2409 | -> content-encoding: gzip 2410 84 | == Indexed - Remove == 2411 | idx = 4 2412 | -> location: https://www.e\ 2413 | xample.com 2414 84 | == Indexed - Add == 2415 | idx = 4 2416 | -> location: https://www.e\ 2417 | xample.com 2418 83 | == Indexed - Remove == 2419 | idx = 3 2420 | -> :status: 200 2421 83 | == Indexed - Add == 2422 | idx = 3 2423 | -> :status: 200 2424 7b | == Literal indexed == 2425 | Indexed name (idx = 59) 2426 | set-cookie 2427 b1 | Literal value (len = 56) 2428 | Huffman encoded: 2429 e0d6 cf9f 6e8f 9fd3 e5f6 fa76 fefd 3c7e | ....n......v.... 2430 df9e ff1f 2f0f 3cfe 9f6f cf7f 8f87 9f61 | ..../....o.....a 2431 ad4f 4cc9 a973 a220 0ec3 725e 18b1 b74e | .OL..s. ..r^...N 2432 3f | ? 2433 | Decoded: 2434 | foo=ASDJKHQKBZXOQWEOPIUAXQ\ 2435 | WEOIU; max-age=3600; versi\ 2436 | on=1 2437 | - evict: location: https:/\ 2438 | /www.example.com 2439 | - evict: :status: 200 2440 | -> set-cookie: foo=ASDJKHQ\ 2441 | KBZXOQWEOPIUAXQWEOIU; ma\ 2442 | x-age=3600; version=1 2444 Header Table (after decoding): 2446 [ 1] (s = 98) set-cookie: foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age\ 2447 =3600; version=1 2448 [ 2] (s = 52) content-encoding: gzip 2449 [ 3] (s = 65) date: Mon, 21 Oct 2013 20:13:22 GMT 2450 Table size: 215 2452 Decoded header set: 2454 cache-control: private 2455 date: Mon, 21 Oct 2013 20:13:22 GMT 2456 content-encoding: gzip 2457 location: https://www.example.com 2458 :status: 200 2459 set-cookie: foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1 2461 Authors' Addresses 2463 Roberto Peon 2464 Google, Inc 2466 EMail: fenix@google.com 2468 Herve Ruellan 2469 Canon CRF 2471 EMail: herve.ruellan@crf.canon.fr