QUIC - wait for disk cache to load server config if the server is among
[chromium-blink-merge.git] / net / spdy / hpack / hpack_decoder_test.cc
blob37daac6b9fd59c21abefd069a5d5b1e8086e48ff
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/hpack_decoder.h"
7 #include <map>
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/logging.h"
12 #include "base/strings/string_piece.h"
13 #include "net/spdy/hpack/hpack_encoder.h"
14 #include "net/spdy/hpack/hpack_input_stream.h"
15 #include "net/spdy/hpack/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"
20 namespace net {
21 namespace test {
23 using base::StringPiece;
24 using std::string;
26 class HpackDecoderPeer {
27 public:
28 explicit HpackDecoderPeer(HpackDecoder* decoder) : decoder_(decoder) {}
30 void HandleHeaderRepresentation(StringPiece name, StringPiece value) {
31 decoder_->HandleHeaderRepresentation(name, value);
33 bool DecodeNextName(HpackInputStream* in, StringPiece* out) {
34 return decoder_->DecodeNextName(in, out);
36 HpackHeaderTable* header_table() { return &decoder_->header_table_; }
37 const SpdyHeaderBlock& decoded_block() const {
38 return decoder_->decoded_block_;
40 const string& headers_block_buffer() const {
41 return decoder_->headers_block_buffer_;
44 private:
45 HpackDecoder* decoder_;
48 namespace {
50 using base::StringPiece;
51 using std::string;
52 using test::a2b_hex;
54 using testing::ElementsAre;
55 using testing::Pair;
57 const size_t kLiteralBound = 1024;
59 class HpackDecoderTest : public ::testing::Test {
60 protected:
61 HpackDecoderTest()
62 : decoder_(ObtainHpackHuffmanTable()), decoder_peer_(&decoder_) {}
64 bool DecodeHeaderBlock(StringPiece str) {
65 return decoder_.HandleControlFrameHeadersData(0, str.data(), str.size()) &&
66 decoder_.HandleControlFrameHeadersComplete(0, nullptr);
69 const SpdyHeaderBlock& decoded_block() const {
70 // TODO(jgraettinger): HpackDecoderTest should implement
71 // SpdyHeadersHandlerInterface, and collect headers for examination.
72 return decoder_peer_.decoded_block();
75 const SpdyHeaderBlock& DecodeBlockExpectingSuccess(StringPiece str) {
76 EXPECT_TRUE(DecodeHeaderBlock(str));
77 return decoded_block();
80 void expectEntry(size_t index,
81 size_t size,
82 const string& name,
83 const string& value) {
84 const HpackEntry* entry = decoder_peer_.header_table()->GetByIndex(index);
85 EXPECT_EQ(name, entry->name()) << "index " << index;
86 EXPECT_EQ(value, entry->value());
87 EXPECT_EQ(size, entry->Size());
88 EXPECT_EQ(index, decoder_peer_.header_table()->IndexOf(entry));
91 HpackDecoder decoder_;
92 test::HpackDecoderPeer decoder_peer_;
95 TEST_F(HpackDecoderTest, HandleControlFrameHeadersData) {
96 // Strings under threshold are concatenated in the buffer.
97 EXPECT_TRUE(
98 decoder_.HandleControlFrameHeadersData(0, "small string one", 16));
99 EXPECT_TRUE(
100 decoder_.HandleControlFrameHeadersData(0, "small string two", 16));
101 // A string which would push the buffer over the threshold is refused.
102 EXPECT_FALSE(decoder_.HandleControlFrameHeadersData(
103 0, "fails", kMaxDecodeBufferSize - 32 + 1));
105 EXPECT_EQ(decoder_peer_.headers_block_buffer(),
106 "small string onesmall string two");
109 TEST_F(HpackDecoderTest, HandleHeaderRepresentation) {
110 // All cookie crumbs are joined.
111 decoder_peer_.HandleHeaderRepresentation("cookie", " part 1");
112 decoder_peer_.HandleHeaderRepresentation("cookie", "part 2 ");
113 decoder_peer_.HandleHeaderRepresentation("cookie", "part3");
115 // Already-delimited headers are passed through.
116 decoder_peer_.HandleHeaderRepresentation("passed-through",
117 string("foo\0baz", 7));
119 // Other headers are joined on \0. Case matters.
120 decoder_peer_.HandleHeaderRepresentation("joined", "not joined");
121 decoder_peer_.HandleHeaderRepresentation("joineD", "value 1");
122 decoder_peer_.HandleHeaderRepresentation("joineD", "value 2");
124 // Empty headers remain empty.
125 decoder_peer_.HandleHeaderRepresentation("empty", "");
127 // Joined empty headers work as expected.
128 decoder_peer_.HandleHeaderRepresentation("empty-joined", "");
129 decoder_peer_.HandleHeaderRepresentation("empty-joined", "foo");
130 decoder_peer_.HandleHeaderRepresentation("empty-joined", "");
131 decoder_peer_.HandleHeaderRepresentation("empty-joined", "");
133 // Non-contiguous cookie crumb.
134 decoder_peer_.HandleHeaderRepresentation("cookie", " fin!");
136 // Finish and emit all headers.
137 decoder_.HandleControlFrameHeadersComplete(0, nullptr);
139 EXPECT_THAT(decoded_block(),
140 ElementsAre(Pair("cookie", " part 1; part 2 ; part3; fin!"),
141 Pair("empty", ""),
142 Pair("empty-joined", string("\0foo\0\0", 6)),
143 Pair("joineD", string("value 1\0value 2", 15)),
144 Pair("joined", "not joined"),
145 Pair("passed-through", string("foo\0baz", 7))));
148 // Decoding an encoded name with a valid string literal should work.
149 TEST_F(HpackDecoderTest, DecodeNextNameLiteral) {
150 HpackInputStream input_stream(kLiteralBound, StringPiece("\x00\x04name", 6));
152 StringPiece string_piece;
153 EXPECT_TRUE(decoder_peer_.DecodeNextName(&input_stream, &string_piece));
154 EXPECT_EQ("name", string_piece);
155 EXPECT_FALSE(input_stream.HasMoreData());
158 TEST_F(HpackDecoderTest, DecodeNextNameLiteralWithHuffmanEncoding) {
159 string input = a2b_hex("008825a849e95ba97d7f");
160 HpackInputStream input_stream(kLiteralBound, input);
162 StringPiece string_piece;
163 EXPECT_TRUE(decoder_peer_.DecodeNextName(&input_stream, &string_piece));
164 EXPECT_EQ("custom-key", string_piece);
165 EXPECT_FALSE(input_stream.HasMoreData());
168 // Decoding an encoded name with a valid index should work.
169 TEST_F(HpackDecoderTest, DecodeNextNameIndexed) {
170 HpackInputStream input_stream(kLiteralBound, "\x01");
172 StringPiece string_piece;
173 EXPECT_TRUE(decoder_peer_.DecodeNextName(&input_stream, &string_piece));
174 EXPECT_EQ(":authority", string_piece);
175 EXPECT_FALSE(input_stream.HasMoreData());
178 // Decoding an encoded name with an invalid index should fail.
179 TEST_F(HpackDecoderTest, DecodeNextNameInvalidIndex) {
180 // One more than the number of static table entries.
181 HpackInputStream input_stream(kLiteralBound, "\x3e");
183 StringPiece string_piece;
184 EXPECT_FALSE(decoder_peer_.DecodeNextName(&input_stream, &string_piece));
187 // Decoding indexed static table field should work.
188 TEST_F(HpackDecoderTest, IndexedHeaderStatic) {
189 // Reference static table entries #2 and #5.
190 SpdyHeaderBlock header_set1 = DecodeBlockExpectingSuccess("\x82\x85");
191 SpdyHeaderBlock expected_header_set1;
192 expected_header_set1[":method"] = "GET";
193 expected_header_set1[":path"] = "/index.html";
194 EXPECT_TRUE(CompareSpdyHeaderBlocks(expected_header_set1, header_set1));
196 // Reference static table entry #2.
197 SpdyHeaderBlock header_set2 = DecodeBlockExpectingSuccess("\x82");
198 SpdyHeaderBlock expected_header_set2;
199 expected_header_set2[":method"] = "GET";
200 EXPECT_TRUE(CompareSpdyHeaderBlocks(expected_header_set2, header_set2));
203 TEST_F(HpackDecoderTest, IndexedHeaderDynamic) {
204 // First header block: add an entry to header table.
205 SpdyHeaderBlock header_set1 = DecodeBlockExpectingSuccess(
206 "\x40\x03"
207 "foo"
208 "\x03"
209 "bar");
210 SpdyHeaderBlock expected_header_set1;
211 expected_header_set1["foo"] = "bar";
212 EXPECT_TRUE(CompareSpdyHeaderBlocks(expected_header_set1, header_set1));
214 // Second header block: add another entry to header table.
215 SpdyHeaderBlock header_set2 = DecodeBlockExpectingSuccess(
216 "\xbe\x40\x04"
217 "spam"
218 "\x04"
219 "eggs");
220 SpdyHeaderBlock expected_header_set2;
221 expected_header_set2["foo"] = "bar";
222 expected_header_set2["spam"] = "eggs";
223 EXPECT_TRUE(CompareSpdyHeaderBlocks(expected_header_set2, header_set2));
225 // Third header block: refer to most recently added entry.
226 SpdyHeaderBlock header_set3 = DecodeBlockExpectingSuccess("\xbe");
227 SpdyHeaderBlock expected_header_set3;
228 expected_header_set3["spam"] = "eggs";
229 EXPECT_TRUE(CompareSpdyHeaderBlocks(expected_header_set3, header_set3));
232 // Test a too-large indexed header.
233 TEST_F(HpackDecoderTest, InvalidIndexedHeader) {
234 // High-bit set, and a prefix of one more than the number of static entries.
235 EXPECT_FALSE(DecodeHeaderBlock(StringPiece("\xbe", 1)));
238 // Test that a header block with a pseudo-header field following a regular one
239 // is treated as malformed. (HTTP2 draft-14 8.1.2.1., HPACK draft-09 3.1.)
241 TEST_F(HpackDecoderTest, InvalidPseudoHeaderPositionStatic) {
242 // Okay: ":path" (static entry 4) followed by "allow" (static entry 20).
243 EXPECT_TRUE(DecodeHeaderBlock(a2b_hex("8494")));
244 // Malformed: "allow" (static entry 20) followed by ":path" (static entry 4).
245 EXPECT_FALSE(DecodeHeaderBlock(a2b_hex("9484")));
248 TEST_F(HpackDecoderTest, InvalidPseudoHeaderPositionLiteral) {
249 // Okay: literal ":bar" followed by literal "foo".
250 EXPECT_TRUE(DecodeHeaderBlock(a2b_hex("40043a626172004003666f6f00")));
251 // Malformed: literal "foo" followed by literal ":bar".
252 EXPECT_FALSE(DecodeHeaderBlock(a2b_hex("4003666f6f0040043a62617200")));
255 TEST_F(HpackDecoderTest, ContextUpdateMaximumSize) {
256 EXPECT_EQ(kDefaultHeaderTableSizeSetting,
257 decoder_peer_.header_table()->max_size());
258 string input;
260 // Maximum-size update with size 126. Succeeds.
261 HpackOutputStream output_stream;
262 output_stream.AppendPrefix(kHeaderTableSizeUpdateOpcode);
263 output_stream.AppendUint32(126);
265 output_stream.TakeString(&input);
266 EXPECT_TRUE(DecodeHeaderBlock(StringPiece(input)));
267 EXPECT_EQ(126u, decoder_peer_.header_table()->max_size());
270 // Maximum-size update with kDefaultHeaderTableSizeSetting. Succeeds.
271 HpackOutputStream output_stream;
272 output_stream.AppendPrefix(kHeaderTableSizeUpdateOpcode);
273 output_stream.AppendUint32(kDefaultHeaderTableSizeSetting);
275 output_stream.TakeString(&input);
276 EXPECT_TRUE(DecodeHeaderBlock(StringPiece(input)));
277 EXPECT_EQ(kDefaultHeaderTableSizeSetting,
278 decoder_peer_.header_table()->max_size());
281 // Maximum-size update with kDefaultHeaderTableSizeSetting + 1. Fails.
282 HpackOutputStream output_stream;
283 output_stream.AppendPrefix(kHeaderTableSizeUpdateOpcode);
284 output_stream.AppendUint32(kDefaultHeaderTableSizeSetting + 1);
286 output_stream.TakeString(&input);
287 EXPECT_FALSE(DecodeHeaderBlock(StringPiece(input)));
288 EXPECT_EQ(kDefaultHeaderTableSizeSetting,
289 decoder_peer_.header_table()->max_size());
293 // Decoding two valid encoded literal headers with no indexing should
294 // work.
295 TEST_F(HpackDecoderTest, LiteralHeaderNoIndexing) {
296 // First header with indexed name, second header with string literal
297 // name.
298 const char input[] = "\x04\x0c/sample/path\x00\x06:path2\x0e/sample/path/2";
299 SpdyHeaderBlock header_set =
300 DecodeBlockExpectingSuccess(StringPiece(input, arraysize(input) - 1));
302 SpdyHeaderBlock expected_header_set;
303 expected_header_set[":path"] = "/sample/path";
304 expected_header_set[":path2"] = "/sample/path/2";
305 EXPECT_TRUE(CompareSpdyHeaderBlocks(expected_header_set, header_set));
308 // Decoding two valid encoded literal headers with incremental
309 // indexing and string literal names should work.
310 TEST_F(HpackDecoderTest, LiteralHeaderIncrementalIndexing) {
311 const char input[] = "\x44\x0c/sample/path\x40\x06:path2\x0e/sample/path/2";
312 SpdyHeaderBlock header_set =
313 DecodeBlockExpectingSuccess(StringPiece(input, arraysize(input) - 1));
315 SpdyHeaderBlock expected_header_set;
316 expected_header_set[":path"] = "/sample/path";
317 expected_header_set[":path2"] = "/sample/path/2";
318 EXPECT_TRUE(CompareSpdyHeaderBlocks(expected_header_set, header_set));
321 TEST_F(HpackDecoderTest, LiteralHeaderWithIndexingInvalidNameIndex) {
322 decoder_.ApplyHeaderTableSizeSetting(0);
324 // Name is the last static index. Works.
325 EXPECT_TRUE(DecodeHeaderBlock(StringPiece("\x7d\x03ooo")));
326 // Name is one beyond the last static index. Fails.
327 EXPECT_FALSE(DecodeHeaderBlock(StringPiece("\x7e\x03ooo")));
330 TEST_F(HpackDecoderTest, LiteralHeaderNoIndexingInvalidNameIndex) {
331 // Name is the last static index. Works.
332 EXPECT_TRUE(DecodeHeaderBlock(StringPiece("\x0f\x2e\x03ooo")));
333 // Name is one beyond the last static index. Fails.
334 EXPECT_FALSE(DecodeHeaderBlock(StringPiece("\x0f\x2f\x03ooo")));
337 TEST_F(HpackDecoderTest, LiteralHeaderNeverIndexedInvalidNameIndex) {
338 // Name is the last static index. Works.
339 EXPECT_TRUE(DecodeHeaderBlock(StringPiece("\x1f\x2e\x03ooo")));
340 // Name is one beyond the last static index. Fails.
341 EXPECT_FALSE(DecodeHeaderBlock(StringPiece("\x1f\x2f\x03ooo")));
344 // Round-tripping the header set from E.2.1 should work.
345 TEST_F(HpackDecoderTest, BasicE21) {
346 HpackEncoder encoder(ObtainHpackHuffmanTable());
348 SpdyHeaderBlock expected_header_set;
349 expected_header_set[":method"] = "GET";
350 expected_header_set[":scheme"] = "http";
351 expected_header_set[":path"] = "/";
352 expected_header_set[":authority"] = "www.example.com";
354 string encoded_header_set;
355 EXPECT_TRUE(
356 encoder.EncodeHeaderSet(expected_header_set, &encoded_header_set));
358 EXPECT_TRUE(DecodeHeaderBlock(encoded_header_set));
359 EXPECT_TRUE(CompareSpdyHeaderBlocks(expected_header_set, decoded_block()));
362 TEST_F(HpackDecoderTest, SectionD4RequestHuffmanExamples) {
363 SpdyHeaderBlock header_set;
365 // 82 | == Indexed - Add ==
366 // | idx = 2
367 // | -> :method: GET
368 // 86 | == Indexed - Add ==
369 // | idx = 6
370 // | -> :scheme: http
371 // 84 | == Indexed - Add ==
372 // | idx = 4
373 // | -> :path: /
374 // 41 | == Literal indexed ==
375 // | Indexed name (idx = 1)
376 // | :authority
377 // 8c | Literal value (len = 15)
378 // | Huffman encoded:
379 // f1e3 c2e5 f23a 6ba0 ab90 f4ff | .....:k.....
380 // | Decoded:
381 // | www.example.com
382 // | -> :authority: www.example.com
383 string first = a2b_hex(
384 "828684418cf1e3c2e5f23a6ba0ab90f4"
385 "ff");
386 header_set = DecodeBlockExpectingSuccess(first);
388 EXPECT_THAT(
389 header_set,
390 ElementsAre(Pair(":authority", "www.example.com"), Pair(":method", "GET"),
391 Pair(":path", "/"), Pair(":scheme", "http")));
393 expectEntry(62, 57, ":authority", "www.example.com");
394 EXPECT_EQ(57u, decoder_peer_.header_table()->size());
396 // 82 | == Indexed - Add ==
397 // | idx = 2
398 // | -> :method: GET
399 // 86 | == Indexed - Add ==
400 // | idx = 6
401 // | -> :scheme: http
402 // 84 | == Indexed - Add ==
403 // | idx = 4
404 // | -> :path: /
405 // be | == Indexed - Add ==
406 // | idx = 62
407 // | -> :authority: www.example.com
408 // 58 | == Literal indexed ==
409 // | Indexed name (idx = 24)
410 // | cache-control
411 // 86 | Literal value (len = 8)
412 // | Huffman encoded:
413 // a8eb 1064 9cbf | ...d..
414 // | Decoded:
415 // | no-cache
416 // | -> cache-control: no-cache
418 string second = a2b_hex("828684be5886a8eb10649cbf");
419 header_set = DecodeBlockExpectingSuccess(second);
421 EXPECT_THAT(
422 header_set,
423 ElementsAre(Pair(":authority", "www.example.com"), Pair(":method", "GET"),
424 Pair(":path", "/"), Pair(":scheme", "http"),
425 Pair("cache-control", "no-cache")));
427 expectEntry(62, 53, "cache-control", "no-cache");
428 expectEntry(63, 57, ":authority", "www.example.com");
429 EXPECT_EQ(110u, decoder_peer_.header_table()->size());
431 // 82 | == Indexed - Add ==
432 // | idx = 2
433 // | -> :method: GET
434 // 87 | == Indexed - Add ==
435 // | idx = 7
436 // | -> :scheme: https
437 // 85 | == Indexed - Add ==
438 // | idx = 5
439 // | -> :path: /index.html
440 // bf | == Indexed - Add ==
441 // | idx = 63
442 // | -> :authority: www.example.com
443 // 40 | == Literal indexed ==
444 // 88 | Literal name (len = 10)
445 // | Huffman encoded:
446 // 25a8 49e9 5ba9 7d7f | %.I.[.}.
447 // | Decoded:
448 // | custom-key
449 // 89 | Literal value (len = 12)
450 // | Huffman encoded:
451 // 25a8 49e9 5bb8 e8b4 bf | %.I.[....
452 // | Decoded:
453 // | custom-value
454 // | -> custom-key: custom-value
455 string third = a2b_hex(
456 "828785bf408825a849e95ba97d7f89"
457 "25a849e95bb8e8b4bf");
458 header_set = DecodeBlockExpectingSuccess(third);
460 EXPECT_THAT(
461 header_set,
462 ElementsAre(Pair(":authority", "www.example.com"), Pair(":method", "GET"),
463 Pair(":path", "/index.html"), Pair(":scheme", "https"),
464 Pair("custom-key", "custom-value")));
466 expectEntry(62, 54, "custom-key", "custom-value");
467 expectEntry(63, 53, "cache-control", "no-cache");
468 expectEntry(64, 57, ":authority", "www.example.com");
469 EXPECT_EQ(164u, decoder_peer_.header_table()->size());
472 TEST_F(HpackDecoderTest, SectionD6ResponseHuffmanExamples) {
473 SpdyHeaderBlock header_set;
474 decoder_.ApplyHeaderTableSizeSetting(256);
476 // 48 | == Literal indexed ==
477 // | Indexed name (idx = 8)
478 // | :status
479 // 82 | Literal value (len = 3)
480 // | Huffman encoded:
481 // 6402 | d.
482 // | Decoded:
483 // | 302
484 // | -> :status: 302
485 // 58 | == Literal indexed ==
486 // | Indexed name (idx = 24)
487 // | cache-control
488 // 85 | Literal value (len = 7)
489 // | Huffman encoded:
490 // aec3 771a 4b | ..w.K
491 // | Decoded:
492 // | private
493 // | -> cache-control: private
494 // 61 | == Literal indexed ==
495 // | Indexed name (idx = 33)
496 // | date
497 // 96 | Literal value (len = 29)
498 // | Huffman encoded:
499 // d07a be94 1054 d444 a820 0595 040b 8166 | .z...T.D. .....f
500 // e082 a62d 1bff | ...-..
501 // | Decoded:
502 // | Mon, 21 Oct 2013 20:13:21
503 // | GMT
504 // | -> date: Mon, 21 Oct 2013
505 // | 20:13:21 GMT
506 // 6e | == Literal indexed ==
507 // | Indexed name (idx = 46)
508 // | location
509 // 91 | Literal value (len = 23)
510 // | Huffman encoded:
511 // 9d29 ad17 1863 c78f 0b97 c8e9 ae82 ae43 | .)...c.........C
512 // d3 | .
513 // | Decoded:
514 // | https://www.example.com
515 // | -> location: https://www.e
516 // | xample.com
518 string first = a2b_hex(
519 "488264025885aec3771a4b6196d07abe"
520 "941054d444a8200595040b8166e082a6"
521 "2d1bff6e919d29ad171863c78f0b97c8"
522 "e9ae82ae43d3");
523 header_set = DecodeBlockExpectingSuccess(first);
525 EXPECT_THAT(
526 header_set,
527 ElementsAre(Pair(":status", "302"), Pair("cache-control", "private"),
528 Pair("date", "Mon, 21 Oct 2013 20:13:21 GMT"),
529 Pair("location", "https://www.example.com")));
531 expectEntry(62, 63, "location", "https://www.example.com");
532 expectEntry(63, 65, "date", "Mon, 21 Oct 2013 20:13:21 GMT");
533 expectEntry(64, 52, "cache-control", "private");
534 expectEntry(65, 42, ":status", "302");
535 EXPECT_EQ(222u, decoder_peer_.header_table()->size());
537 // 48 | == Literal indexed ==
538 // | Indexed name (idx = 8)
539 // | :status
540 // 83 | Literal value (len = 3)
541 // | Huffman encoded:
542 // 640e ff | d..
543 // | Decoded:
544 // | 307
545 // | - evict: :status: 302
546 // | -> :status: 307
547 // c1 | == Indexed - Add ==
548 // | idx = 65
549 // | -> cache-control: private
550 // c0 | == Indexed - Add ==
551 // | idx = 64
552 // | -> date: Mon, 21 Oct 2013
553 // | 20:13:21 GMT
554 // bf | == Indexed - Add ==
555 // | idx = 63
556 // | -> location:
557 // | https://www.example.com
558 string second = a2b_hex("4883640effc1c0bf");
559 header_set = DecodeBlockExpectingSuccess(second);
561 EXPECT_THAT(
562 header_set,
563 ElementsAre(Pair(":status", "307"), Pair("cache-control", "private"),
564 Pair("date", "Mon, 21 Oct 2013 20:13:21 GMT"),
565 Pair("location", "https://www.example.com")));
567 expectEntry(62, 42, ":status", "307");
568 expectEntry(63, 63, "location", "https://www.example.com");
569 expectEntry(64, 65, "date", "Mon, 21 Oct 2013 20:13:21 GMT");
570 expectEntry(65, 52, "cache-control", "private");
571 EXPECT_EQ(222u, decoder_peer_.header_table()->size());
573 // 88 | == Indexed - Add ==
574 // | idx = 8
575 // | -> :status: 200
576 // c1 | == Indexed - Add ==
577 // | idx = 65
578 // | -> cache-control: private
579 // 61 | == Literal indexed ==
580 // | Indexed name (idx = 33)
581 // | date
582 // 96 | Literal value (len = 22)
583 // | Huffman encoded:
584 // d07a be94 1054 d444 a820 0595 040b 8166 | .z...T.D. .....f
585 // e084 a62d 1bff | ...-..
586 // | Decoded:
587 // | Mon, 21 Oct 2013 20:13:22
588 // | GMT
589 // | - evict: cache-control:
590 // | private
591 // | -> date: Mon, 21 Oct 2013
592 // | 20:13:22 GMT
593 // c0 | == Indexed - Add ==
594 // | idx = 64
595 // | -> location:
596 // | https://www.example.com
597 // 5a | == Literal indexed ==
598 // | Indexed name (idx = 26)
599 // | content-encoding
600 // 83 | Literal value (len = 3)
601 // | Huffman encoded:
602 // 9bd9 ab | ...
603 // | Decoded:
604 // | gzip
605 // | - evict: date: Mon, 21 Oct
606 // | 2013 20:13:21 GMT
607 // | -> content-encoding: gzip
608 // 77 | == Literal indexed ==
609 // | Indexed name (idx = 55)
610 // | set-cookie
611 // ad | Literal value (len = 45)
612 // | Huffman encoded:
613 // 94e7 821d d7f2 e6c7 b335 dfdf cd5b 3960 | .........5...[9`
614 // d5af 2708 7f36 72c1 ab27 0fb5 291f 9587 | ..'..6r..'..)...
615 // 3160 65c0 03ed 4ee5 b106 3d50 07 | 1`e...N...=P.
616 // | Decoded:
617 // | foo=ASDJKHQKBZXOQWEOPIUAXQ
618 // | WEOIU; max-age=3600; versi
619 // | on=1
620 // | - evict: location:
621 // | https://www.example.com
622 // | - evict: :status: 307
623 // | -> set-cookie: foo=ASDJKHQ
624 // | KBZXOQWEOPIUAXQWEOIU;
625 // | max-age=3600; version=1
626 string third = a2b_hex(
627 "88c16196d07abe941054d444a8200595"
628 "040b8166e084a62d1bffc05a839bd9ab"
629 "77ad94e7821dd7f2e6c7b335dfdfcd5b"
630 "3960d5af27087f3672c1ab270fb5291f"
631 "9587316065c003ed4ee5b1063d5007");
632 header_set = DecodeBlockExpectingSuccess(third);
634 EXPECT_THAT(
635 header_set,
636 ElementsAre(Pair(":status", "200"), Pair("cache-control", "private"),
637 Pair("content-encoding", "gzip"),
638 Pair("date", "Mon, 21 Oct 2013 20:13:22 GMT"),
639 Pair("location", "https://www.example.com"),
640 Pair("set-cookie",
641 "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU;"
642 " max-age=3600; version=1")));
644 expectEntry(62, 98, "set-cookie",
645 "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU;"
646 " max-age=3600; version=1");
647 expectEntry(63, 52, "content-encoding", "gzip");
648 expectEntry(64, 65, "date", "Mon, 21 Oct 2013 20:13:22 GMT");
649 EXPECT_EQ(215u, decoder_peer_.header_table()->size());
652 } // namespace
653 } // namespace test
654 } // namespace net