1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "net/spdy/hpack_decoder.h"
10 #include "base/basictypes.h"
11 #include "base/logging.h"
12 #include "base/strings/string_piece.h"
13 #include "net/spdy/hpack_encoder.h"
14 #include "net/spdy/hpack_input_stream.h"
15 #include "net/spdy/hpack_output_stream.h"
16 #include "net/spdy/spdy_test_utils.h"
17 #include "testing/gmock/include/gmock/gmock.h"
18 #include "testing/gtest/include/gtest/gtest.h"
24 using base::StringPiece
;
27 class HpackDecoderPeer
{
29 explicit HpackDecoderPeer(HpackDecoder
* decoder
)
30 : decoder_(decoder
) {}
32 void HandleHeaderRepresentation(StringPiece name
, StringPiece value
) {
33 decoder_
->HandleHeaderRepresentation(name
, value
);
35 bool DecodeNextName(HpackInputStream
* in
, StringPiece
* out
) {
36 return decoder_
->DecodeNextName(in
, out
);
38 HpackHeaderTable
* header_table() {
39 return &decoder_
->header_table_
;
41 void set_cookie_value(string value
) {
42 decoder_
->cookie_value_
= value
;
44 string
cookie_value() {
45 return decoder_
->cookie_value_
;
47 const SpdyHeaderBlock
& decoded_block() const {
48 return decoder_
->decoded_block_
;
50 const string
& headers_block_buffer() const {
51 return decoder_
->headers_block_buffer_
;
55 HpackDecoder
* decoder_
;
62 using base::StringPiece
;
66 using testing::ElementsAre
;
69 const size_t kLiteralBound
= 1024;
71 class HpackDecoderTest
: public ::testing::Test
{
74 : decoder_(ObtainHpackHuffmanTable()),
75 decoder_peer_(&decoder_
) {}
77 bool DecodeHeaderBlock(StringPiece str
) {
78 return decoder_
.HandleControlFrameHeadersData(0, str
.data(), str
.size()) &&
79 decoder_
.HandleControlFrameHeadersComplete(0);
82 const SpdyHeaderBlock
& decoded_block() const {
83 // TODO(jgraettinger): HpackDecoderTest should implement
84 // SpdyHeadersHandlerInterface, and collect headers for examination.
85 return decoder_peer_
.decoded_block();
88 const SpdyHeaderBlock
& DecodeBlockExpectingSuccess(StringPiece str
) {
89 EXPECT_TRUE(DecodeHeaderBlock(str
));
90 return decoded_block();
93 void expectEntry(size_t index
, size_t size
, const string
& name
,
94 const string
& value
) {
95 const HpackEntry
* entry
= decoder_peer_
.header_table()->GetByIndex(index
);
96 EXPECT_EQ(name
, entry
->name()) << "index " << index
;
97 EXPECT_EQ(value
, entry
->value());
98 EXPECT_EQ(size
, entry
->Size());
99 EXPECT_EQ(index
, decoder_peer_
.header_table()->IndexOf(entry
));
102 HpackDecoder decoder_
;
103 test::HpackDecoderPeer decoder_peer_
;
106 TEST_F(HpackDecoderTest
, HandleControlFrameHeadersData
) {
107 // Strings under threshold are concatenated in the buffer.
108 EXPECT_TRUE(decoder_
.HandleControlFrameHeadersData(
109 0, "small string one", 16));
110 EXPECT_TRUE(decoder_
.HandleControlFrameHeadersData(
111 0, "small string two", 16));
112 // A string which would push the buffer over the threshold is refused.
113 EXPECT_FALSE(decoder_
.HandleControlFrameHeadersData(
114 0, "fails", kMaxDecodeBufferSize
- 32 + 1));
116 EXPECT_EQ(decoder_peer_
.headers_block_buffer(),
117 "small string onesmall string two");
120 TEST_F(HpackDecoderTest
, HandleControlFrameHeadersComplete
) {
121 decoder_peer_
.set_cookie_value("foobar=baz");
123 // Incremental cookie buffer should be emitted and cleared.
124 decoder_
.HandleControlFrameHeadersData(0, "\x82\x85", 2);
125 decoder_
.HandleControlFrameHeadersComplete(0);
127 EXPECT_THAT(decoded_block(), ElementsAre(
128 Pair(":method", "GET"),
129 Pair(":path", "/index.html"),
130 Pair("cookie", "foobar=baz")));
131 EXPECT_EQ(decoder_peer_
.cookie_value(), "");
134 TEST_F(HpackDecoderTest
, HandleHeaderRepresentation
) {
135 // All cookie crumbs are joined.
136 decoder_peer_
.HandleHeaderRepresentation("cookie", " part 1");
137 decoder_peer_
.HandleHeaderRepresentation("cookie", "part 2 ");
138 decoder_peer_
.HandleHeaderRepresentation("cookie", "part3");
140 // Already-delimited headers are passed through.
141 decoder_peer_
.HandleHeaderRepresentation("passed-through",
142 string("foo\0baz", 7));
144 // Other headers are joined on \0. Case matters.
145 decoder_peer_
.HandleHeaderRepresentation("joined", "not joined");
146 decoder_peer_
.HandleHeaderRepresentation("joineD", "value 1");
147 decoder_peer_
.HandleHeaderRepresentation("joineD", "value 2");
149 // Empty headers remain empty.
150 decoder_peer_
.HandleHeaderRepresentation("empty", "");
152 // Joined empty headers work as expected.
153 decoder_peer_
.HandleHeaderRepresentation("empty-joined", "");
154 decoder_peer_
.HandleHeaderRepresentation("empty-joined", "foo");
155 decoder_peer_
.HandleHeaderRepresentation("empty-joined", "");
156 decoder_peer_
.HandleHeaderRepresentation("empty-joined", "");
158 // Non-contiguous cookie crumb.
159 decoder_peer_
.HandleHeaderRepresentation("cookie", " fin!");
161 // Finish and emit all headers.
162 decoder_
.HandleControlFrameHeadersComplete(0);
164 EXPECT_THAT(decoded_block(), ElementsAre(
165 Pair("cookie", " part 1; part 2 ; part3; fin!"),
167 Pair("empty-joined", string("\0foo\0\0", 6)),
168 Pair("joineD", string("value 1\0value 2", 15)),
169 Pair("joined", "not joined"),
170 Pair("passed-through", string("foo\0baz", 7))));
173 // Decoding an encoded name with a valid string literal should work.
174 TEST_F(HpackDecoderTest
, DecodeNextNameLiteral
) {
175 HpackInputStream
input_stream(kLiteralBound
, StringPiece("\x00\x04name", 6));
177 StringPiece string_piece
;
178 EXPECT_TRUE(decoder_peer_
.DecodeNextName(&input_stream
, &string_piece
));
179 EXPECT_EQ("name", string_piece
);
180 EXPECT_FALSE(input_stream
.HasMoreData());
183 TEST_F(HpackDecoderTest
, DecodeNextNameLiteralWithHuffmanEncoding
) {
184 string input
= a2b_hex("008825a849e95ba97d7f");
185 HpackInputStream
input_stream(kLiteralBound
, input
);
187 StringPiece string_piece
;
188 EXPECT_TRUE(decoder_peer_
.DecodeNextName(&input_stream
, &string_piece
));
189 EXPECT_EQ("custom-key", string_piece
);
190 EXPECT_FALSE(input_stream
.HasMoreData());
193 // Decoding an encoded name with a valid index should work.
194 TEST_F(HpackDecoderTest
, DecodeNextNameIndexed
) {
195 HpackInputStream
input_stream(kLiteralBound
, "\x01");
197 StringPiece string_piece
;
198 EXPECT_TRUE(decoder_peer_
.DecodeNextName(&input_stream
, &string_piece
));
199 EXPECT_EQ(":authority", string_piece
);
200 EXPECT_FALSE(input_stream
.HasMoreData());
203 // Decoding an encoded name with an invalid index should fail.
204 TEST_F(HpackDecoderTest
, DecodeNextNameInvalidIndex
) {
205 // One more than the number of static table entries.
206 HpackInputStream
input_stream(kLiteralBound
, "\x3e");
208 StringPiece string_piece
;
209 EXPECT_FALSE(decoder_peer_
.DecodeNextName(&input_stream
, &string_piece
));
212 // Decoding indexed static table field should work.
213 TEST_F(HpackDecoderTest
, IndexedHeaderStatic
) {
214 // Reference static table entries #2 and #5.
215 SpdyHeaderBlock header_set1
= DecodeBlockExpectingSuccess("\x82\x85");
216 SpdyHeaderBlock expected_header_set1
;
217 expected_header_set1
[":method"] = "GET";
218 expected_header_set1
[":path"] = "/index.html";
219 EXPECT_EQ(expected_header_set1
, header_set1
);
221 // Reference static table entry #2.
222 SpdyHeaderBlock header_set2
= DecodeBlockExpectingSuccess("\x82");
223 SpdyHeaderBlock expected_header_set2
;
224 expected_header_set2
[":method"] = "GET";
225 EXPECT_EQ(expected_header_set2
, header_set2
);
228 TEST_F(HpackDecoderTest
, IndexedHeaderDynamic
) {
229 // First header block: add an entry to header table.
230 SpdyHeaderBlock header_set1
=
231 DecodeBlockExpectingSuccess("\x40\x03" "foo" "\x03" "bar");
232 SpdyHeaderBlock expected_header_set1
;
233 expected_header_set1
["foo"] = "bar";
234 EXPECT_EQ(expected_header_set1
, header_set1
);
236 // Second header block: add another entry to header table.
237 SpdyHeaderBlock header_set2
=
238 DecodeBlockExpectingSuccess("\xbe\x40\x04" "spam" "\x04" "eggs");
239 SpdyHeaderBlock expected_header_set2
;
240 expected_header_set2
["foo"] = "bar";
241 expected_header_set2
["spam"] = "eggs";
242 EXPECT_EQ(expected_header_set2
, header_set2
);
244 // Third header block: refer to most recently added entry.
245 SpdyHeaderBlock header_set3
= DecodeBlockExpectingSuccess("\xbe");
246 SpdyHeaderBlock expected_header_set3
;
247 expected_header_set3
["spam"] = "eggs";
248 EXPECT_EQ(expected_header_set3
, header_set3
);
251 // Test a too-large indexed header.
252 TEST_F(HpackDecoderTest
, InvalidIndexedHeader
) {
253 // High-bit set, and a prefix of one more than the number of static entries.
254 EXPECT_FALSE(DecodeHeaderBlock(StringPiece("\xbe", 1)));
257 // Test that a header block with a pseudo-header field following a regular one
258 // is treated as malformed. (HTTP2 draft-14 8.1.2.1., HPACK draft-09 3.1.)
260 TEST_F(HpackDecoderTest
, InvalidPseudoHeaderPositionStatic
) {
261 // Okay: ":path" (static entry 4) followed by "allow" (static entry 20).
262 EXPECT_TRUE(DecodeHeaderBlock(a2b_hex("8494")));
263 // Malformed: "allow" (static entry 20) followed by ":path" (static entry 4).
264 EXPECT_FALSE(DecodeHeaderBlock(a2b_hex("9484")));
267 TEST_F(HpackDecoderTest
, InvalidPseudoHeaderPositionLiteral
) {
268 // Okay: literal ":bar" followed by literal "foo".
269 EXPECT_TRUE(DecodeHeaderBlock(a2b_hex("40043a626172004003666f6f00")));
270 // Malformed: literal "foo" followed by literal ":bar".
271 EXPECT_FALSE(DecodeHeaderBlock(a2b_hex("4003666f6f0040043a62617200")));
274 TEST_F(HpackDecoderTest
, ContextUpdateMaximumSize
) {
275 EXPECT_EQ(kDefaultHeaderTableSizeSetting
,
276 decoder_peer_
.header_table()->max_size());
279 // Maximum-size update with size 126. Succeeds.
280 HpackOutputStream output_stream
;
281 output_stream
.AppendPrefix(kHeaderTableSizeUpdateOpcode
);
282 output_stream
.AppendUint32(126);
284 output_stream
.TakeString(&input
);
285 EXPECT_TRUE(DecodeHeaderBlock(StringPiece(input
)));
286 EXPECT_EQ(126u, decoder_peer_
.header_table()->max_size());
289 // Maximum-size update with kDefaultHeaderTableSizeSetting. Succeeds.
290 HpackOutputStream output_stream
;
291 output_stream
.AppendPrefix(kHeaderTableSizeUpdateOpcode
);
292 output_stream
.AppendUint32(kDefaultHeaderTableSizeSetting
);
294 output_stream
.TakeString(&input
);
295 EXPECT_TRUE(DecodeHeaderBlock(StringPiece(input
)));
296 EXPECT_EQ(kDefaultHeaderTableSizeSetting
,
297 decoder_peer_
.header_table()->max_size());
300 // Maximum-size update with kDefaultHeaderTableSizeSetting + 1. Fails.
301 HpackOutputStream output_stream
;
302 output_stream
.AppendPrefix(kHeaderTableSizeUpdateOpcode
);
303 output_stream
.AppendUint32(kDefaultHeaderTableSizeSetting
+ 1);
305 output_stream
.TakeString(&input
);
306 EXPECT_FALSE(DecodeHeaderBlock(StringPiece(input
)));
307 EXPECT_EQ(kDefaultHeaderTableSizeSetting
,
308 decoder_peer_
.header_table()->max_size());
312 // Decoding two valid encoded literal headers with no indexing should
314 TEST_F(HpackDecoderTest
, LiteralHeaderNoIndexing
) {
315 // First header with indexed name, second header with string literal
317 const char input
[] = "\x04\x0c/sample/path\x00\x06:path2\x0e/sample/path/2";
318 SpdyHeaderBlock header_set
=
319 DecodeBlockExpectingSuccess(StringPiece(input
, arraysize(input
) - 1));
321 SpdyHeaderBlock expected_header_set
;
322 expected_header_set
[":path"] = "/sample/path";
323 expected_header_set
[":path2"] = "/sample/path/2";
324 EXPECT_EQ(expected_header_set
, header_set
);
327 // Decoding two valid encoded literal headers with incremental
328 // indexing and string literal names should work.
329 TEST_F(HpackDecoderTest
, LiteralHeaderIncrementalIndexing
) {
330 const char input
[] = "\x44\x0c/sample/path\x40\x06:path2\x0e/sample/path/2";
331 SpdyHeaderBlock header_set
=
332 DecodeBlockExpectingSuccess(StringPiece(input
, arraysize(input
) - 1));
334 SpdyHeaderBlock expected_header_set
;
335 expected_header_set
[":path"] = "/sample/path";
336 expected_header_set
[":path2"] = "/sample/path/2";
337 EXPECT_EQ(expected_header_set
, header_set
);
340 TEST_F(HpackDecoderTest
, LiteralHeaderWithIndexingInvalidNameIndex
) {
341 decoder_
.ApplyHeaderTableSizeSetting(0);
343 // Name is the last static index. Works.
344 EXPECT_TRUE(DecodeHeaderBlock(StringPiece("\x7d\x03ooo")));
345 // Name is one beyond the last static index. Fails.
346 EXPECT_FALSE(DecodeHeaderBlock(StringPiece("\x7e\x03ooo")));
349 TEST_F(HpackDecoderTest
, LiteralHeaderNoIndexingInvalidNameIndex
) {
350 // Name is the last static index. Works.
351 EXPECT_TRUE(DecodeHeaderBlock(StringPiece("\x0f\x2e\x03ooo")));
352 // Name is one beyond the last static index. Fails.
353 EXPECT_FALSE(DecodeHeaderBlock(StringPiece("\x0f\x2f\x03ooo")));
356 TEST_F(HpackDecoderTest
, LiteralHeaderNeverIndexedInvalidNameIndex
) {
357 // Name is the last static index. Works.
358 EXPECT_TRUE(DecodeHeaderBlock(StringPiece("\x1f\x2e\x03ooo")));
359 // Name is one beyond the last static index. Fails.
360 EXPECT_FALSE(DecodeHeaderBlock(StringPiece("\x1f\x2f\x03ooo")));
363 // Round-tripping the header set from E.2.1 should work.
364 TEST_F(HpackDecoderTest
, BasicE21
) {
365 HpackEncoder
encoder(ObtainHpackHuffmanTable());
367 SpdyHeaderBlock expected_header_set
;
368 expected_header_set
[":method"] = "GET";
369 expected_header_set
[":scheme"] = "http";
370 expected_header_set
[":path"] = "/";
371 expected_header_set
[":authority"] = "www.example.com";
373 string encoded_header_set
;
374 EXPECT_TRUE(encoder
.EncodeHeaderSet(
375 expected_header_set
, &encoded_header_set
));
377 EXPECT_TRUE(DecodeHeaderBlock(encoded_header_set
));
378 EXPECT_EQ(expected_header_set
, decoded_block());
381 TEST_F(HpackDecoderTest
, SectionD4RequestHuffmanExamples
) {
382 SpdyHeaderBlock header_set
;
384 // 82 | == Indexed - Add ==
387 // 86 | == Indexed - Add ==
389 // | -> :scheme: http
390 // 84 | == Indexed - Add ==
393 // 41 | == Literal indexed ==
394 // | Indexed name (idx = 1)
396 // 8c | Literal value (len = 15)
397 // | Huffman encoded:
398 // f1e3 c2e5 f23a 6ba0 ab90 f4ff | .....:k.....
401 // | -> :authority: www.example.com
402 string first
= a2b_hex("828684418cf1e3c2e5f23a6ba0ab90f4"
404 header_set
= DecodeBlockExpectingSuccess(first
);
406 EXPECT_THAT(header_set
, ElementsAre(
407 Pair(":authority", "www.example.com"),
408 Pair(":method", "GET"),
410 Pair(":scheme", "http")));
412 expectEntry(62, 57, ":authority", "www.example.com");
413 EXPECT_EQ(57u, decoder_peer_
.header_table()->size());
415 // 82 | == Indexed - Add ==
418 // 86 | == Indexed - Add ==
420 // | -> :scheme: http
421 // 84 | == Indexed - Add ==
424 // be | == Indexed - Add ==
426 // | -> :authority: www.example.com
427 // 58 | == Literal indexed ==
428 // | Indexed name (idx = 24)
430 // 86 | Literal value (len = 8)
431 // | Huffman encoded:
432 // a8eb 1064 9cbf | ...d..
435 // | -> cache-control: no-cache
437 string second
= a2b_hex("828684be5886a8eb10649cbf");
438 header_set
= DecodeBlockExpectingSuccess(second
);
440 EXPECT_THAT(header_set
, ElementsAre(
441 Pair(":authority", "www.example.com"),
442 Pair(":method", "GET"),
444 Pair(":scheme", "http"),
445 Pair("cache-control", "no-cache")));
447 expectEntry(62, 53, "cache-control", "no-cache");
448 expectEntry(63, 57, ":authority", "www.example.com");
449 EXPECT_EQ(110u, decoder_peer_
.header_table()->size());
451 // 82 | == Indexed - Add ==
454 // 87 | == Indexed - Add ==
456 // | -> :scheme: https
457 // 85 | == Indexed - Add ==
459 // | -> :path: /index.html
460 // bf | == Indexed - Add ==
462 // | -> :authority: www.example.com
463 // 40 | == Literal indexed ==
464 // 88 | Literal name (len = 10)
465 // | Huffman encoded:
466 // 25a8 49e9 5ba9 7d7f | %.I.[.}.
469 // 89 | Literal value (len = 12)
470 // | Huffman encoded:
471 // 25a8 49e9 5bb8 e8b4 bf | %.I.[....
474 // | -> custom-key: custom-value
475 string third
= a2b_hex("828785bf408825a849e95ba97d7f89"
476 "25a849e95bb8e8b4bf");
477 header_set
= DecodeBlockExpectingSuccess(third
);
479 EXPECT_THAT(header_set
, ElementsAre(
480 Pair(":authority", "www.example.com"),
481 Pair(":method", "GET"),
482 Pair(":path", "/index.html"),
483 Pair(":scheme", "https"),
484 Pair("custom-key", "custom-value")));
486 expectEntry(62, 54, "custom-key", "custom-value");
487 expectEntry(63, 53, "cache-control", "no-cache");
488 expectEntry(64, 57, ":authority", "www.example.com");
489 EXPECT_EQ(164u, decoder_peer_
.header_table()->size());
492 TEST_F(HpackDecoderTest
, SectionD6ResponseHuffmanExamples
) {
493 SpdyHeaderBlock header_set
;
494 decoder_
.ApplyHeaderTableSizeSetting(256);
496 // 48 | == Literal indexed ==
497 // | Indexed name (idx = 8)
499 // 82 | Literal value (len = 3)
500 // | Huffman encoded:
505 // 58 | == Literal indexed ==
506 // | Indexed name (idx = 24)
508 // 85 | Literal value (len = 7)
509 // | Huffman encoded:
510 // aec3 771a 4b | ..w.K
513 // | -> cache-control: private
514 // 61 | == Literal indexed ==
515 // | Indexed name (idx = 33)
517 // 96 | Literal value (len = 29)
518 // | Huffman encoded:
519 // d07a be94 1054 d444 a820 0595 040b 8166 | .z...T.D. .....f
520 // e082 a62d 1bff | ...-..
522 // | Mon, 21 Oct 2013 20:13:21
524 // | -> date: Mon, 21 Oct 2013
526 // 6e | == Literal indexed ==
527 // | Indexed name (idx = 46)
529 // 91 | Literal value (len = 23)
530 // | Huffman encoded:
531 // 9d29 ad17 1863 c78f 0b97 c8e9 ae82 ae43 | .)...c.........C
534 // | https://www.example.com
535 // | -> location: https://www.e
538 string first
= a2b_hex("488264025885aec3771a4b6196d07abe"
539 "941054d444a8200595040b8166e082a6"
540 "2d1bff6e919d29ad171863c78f0b97c8"
542 header_set
= DecodeBlockExpectingSuccess(first
);
544 EXPECT_THAT(header_set
, ElementsAre(
545 Pair(":status", "302"),
546 Pair("cache-control", "private"),
547 Pair("date", "Mon, 21 Oct 2013 20:13:21 GMT"),
548 Pair("location", "https://www.example.com")));
550 expectEntry(62, 63, "location", "https://www.example.com");
551 expectEntry(63, 65, "date", "Mon, 21 Oct 2013 20:13:21 GMT");
552 expectEntry(64, 52, "cache-control", "private");
553 expectEntry(65, 42, ":status", "302");
554 EXPECT_EQ(222u, decoder_peer_
.header_table()->size());
556 // 48 | == Literal indexed ==
557 // | Indexed name (idx = 8)
559 // 83 | Literal value (len = 3)
560 // | Huffman encoded:
564 // | - evict: :status: 302
566 // c1 | == Indexed - Add ==
568 // | -> cache-control: private
569 // c0 | == Indexed - Add ==
571 // | -> date: Mon, 21 Oct 2013
573 // bf | == Indexed - Add ==
576 // | https://www.example.com
577 string second
= a2b_hex("4883640effc1c0bf");
578 header_set
= DecodeBlockExpectingSuccess(second
);
580 EXPECT_THAT(header_set
, ElementsAre(
581 Pair(":status", "307"),
582 Pair("cache-control", "private"),
583 Pair("date", "Mon, 21 Oct 2013 20:13:21 GMT"),
584 Pair("location", "https://www.example.com")));
586 expectEntry(62, 42, ":status", "307");
587 expectEntry(63, 63, "location", "https://www.example.com");
588 expectEntry(64, 65, "date", "Mon, 21 Oct 2013 20:13:21 GMT");
589 expectEntry(65, 52, "cache-control", "private");
590 EXPECT_EQ(222u, decoder_peer_
.header_table()->size());
592 // 88 | == Indexed - Add ==
595 // c1 | == Indexed - Add ==
597 // | -> cache-control: private
598 // 61 | == Literal indexed ==
599 // | Indexed name (idx = 33)
601 // 96 | Literal value (len = 22)
602 // | Huffman encoded:
603 // d07a be94 1054 d444 a820 0595 040b 8166 | .z...T.D. .....f
604 // e084 a62d 1bff | ...-..
606 // | Mon, 21 Oct 2013 20:13:22
608 // | - evict: cache-control:
610 // | -> date: Mon, 21 Oct 2013
612 // c0 | == Indexed - Add ==
615 // | https://www.example.com
616 // 5a | == Literal indexed ==
617 // | Indexed name (idx = 26)
618 // | content-encoding
619 // 83 | Literal value (len = 3)
620 // | Huffman encoded:
624 // | - evict: date: Mon, 21 Oct
625 // | 2013 20:13:21 GMT
626 // | -> content-encoding: gzip
627 // 77 | == Literal indexed ==
628 // | Indexed name (idx = 55)
630 // ad | Literal value (len = 45)
631 // | Huffman encoded:
632 // 94e7 821d d7f2 e6c7 b335 dfdf cd5b 3960 | .........5...[9`
633 // d5af 2708 7f36 72c1 ab27 0fb5 291f 9587 | ..'..6r..'..)...
634 // 3160 65c0 03ed 4ee5 b106 3d50 07 | 1`e...N...=P.
636 // | foo=ASDJKHQKBZXOQWEOPIUAXQ
637 // | WEOIU; max-age=3600; versi
639 // | - evict: location:
640 // | https://www.example.com
641 // | - evict: :status: 307
642 // | -> set-cookie: foo=ASDJKHQ
643 // | KBZXOQWEOPIUAXQWEOIU;
644 // | max-age=3600; version=1
645 string third
= a2b_hex("88c16196d07abe941054d444a8200595"
646 "040b8166e084a62d1bffc05a839bd9ab"
647 "77ad94e7821dd7f2e6c7b335dfdfcd5b"
648 "3960d5af27087f3672c1ab270fb5291f"
649 "9587316065c003ed4ee5b1063d5007");
650 header_set
= DecodeBlockExpectingSuccess(third
);
652 EXPECT_THAT(header_set
, ElementsAre(
653 Pair(":status", "200"),
654 Pair("cache-control", "private"),
655 Pair("content-encoding", "gzip"),
656 Pair("date", "Mon, 21 Oct 2013 20:13:22 GMT"),
657 Pair("location", "https://www.example.com"),
658 Pair("set-cookie", "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU;"
659 " max-age=3600; version=1")));
661 expectEntry(62, 98, "set-cookie", "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU;"
662 " max-age=3600; version=1");
663 expectEntry(63, 52, "content-encoding", "gzip");
664 expectEntry(64, 65, "date", "Mon, 21 Oct 2013 20:13:22 GMT");
665 EXPECT_EQ(215u, decoder_peer_
.header_table()->size());