Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Side by Side Diff: net/spdy/hpack/hpack_decoder_test.cc

Issue 2644683002: Add HpackDecoder3, an adapter using HpackDecoder (in net/http2/hpack/decoder). (Closed)
Patch Set: Nits. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/spdy/hpack/hpack_decoder_interface.h ('k') | net/spdy/spdy_flags.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/spdy/hpack/hpack_decoder.h" 5 #include "net/spdy/hpack/hpack_decoder.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 input_stream.MarkCurrentPosition(); 536 input_stream.MarkCurrentPosition();
537 EXPECT_EQ(20u, input_stream.ParsedBytes()); 537 EXPECT_EQ(20u, input_stream.ParsedBytes());
538 538
539 EXPECT_FALSE( 539 EXPECT_FALSE(
540 decoder_peer_.DecodeNextStringLiteral(&input_stream, false, &str)); 540 decoder_peer_.DecodeNextStringLiteral(&input_stream, false, &str));
541 EXPECT_TRUE(input_stream.NeedMoreData()); 541 EXPECT_TRUE(input_stream.NeedMoreData());
542 input_stream.MarkCurrentPosition(); 542 input_stream.MarkCurrentPosition();
543 EXPECT_EQ(21u, input_stream.ParsedBytes()); 543 EXPECT_EQ(21u, input_stream.ParsedBytes());
544 } 544 }
545 545
546 // Round-tripping the header set from E.2.1 should work. 546 // Round-tripping the header set from RFC 7541 C.3.1 should work.
547 TEST_P(HpackDecoderTest, BasicE21) { 547 // http://httpwg.org/specs/rfc7541.html#rfc.section.C.3.1
548 TEST_P(HpackDecoderTest, BasicC31) {
548 HpackEncoder encoder(ObtainHpackHuffmanTable()); 549 HpackEncoder encoder(ObtainHpackHuffmanTable());
549 550
550 SpdyHeaderBlock expected_header_set; 551 SpdyHeaderBlock expected_header_set;
551 expected_header_set[":method"] = "GET"; 552 expected_header_set[":method"] = "GET";
552 expected_header_set[":scheme"] = "http"; 553 expected_header_set[":scheme"] = "http";
553 expected_header_set[":path"] = "/"; 554 expected_header_set[":path"] = "/";
554 expected_header_set[":authority"] = "www.example.com"; 555 expected_header_set[":authority"] = "www.example.com";
555 556
556 string encoded_header_set; 557 string encoded_header_set;
557 EXPECT_TRUE( 558 EXPECT_TRUE(
558 encoder.EncodeHeaderSet(expected_header_set, &encoded_header_set)); 559 encoder.EncodeHeaderSet(expected_header_set, &encoded_header_set));
559 560
560 EXPECT_TRUE(DecodeHeaderBlock(encoded_header_set)); 561 EXPECT_TRUE(DecodeHeaderBlock(encoded_header_set));
561 EXPECT_EQ(expected_header_set, decoded_block()); 562 EXPECT_EQ(expected_header_set, decoded_block());
562 } 563 }
563 564
564 TEST_P(HpackDecoderTest, SectionD4RequestHuffmanExamples) { 565 // RFC 7541, Section C.4: Request Examples with Huffman Coding
566 // http://httpwg.org/specs/rfc7541.html#rfc.section.C.4
567 TEST_P(HpackDecoderTest, SectionC4RequestHuffmanExamples) {
565 // 82 | == Indexed - Add == 568 // 82 | == Indexed - Add ==
566 // | idx = 2 569 // | idx = 2
567 // | -> :method: GET 570 // | -> :method: GET
568 // 86 | == Indexed - Add == 571 // 86 | == Indexed - Add ==
569 // | idx = 6 572 // | idx = 6
570 // | -> :scheme: http 573 // | -> :scheme: http
571 // 84 | == Indexed - Add == 574 // 84 | == Indexed - Add ==
572 // | idx = 4 575 // | idx = 4
573 // | -> :path: / 576 // | -> :path: /
574 // 41 | == Literal indexed == 577 // 41 | == Literal indexed ==
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 Pair(":path", "/index.html"), 664 Pair(":path", "/index.html"),
662 Pair(":authority", "www.example.com"), 665 Pair(":authority", "www.example.com"),
663 Pair("custom-key", "custom-value"))); 666 Pair("custom-key", "custom-value")));
664 667
665 expectEntry(62, 54, "custom-key", "custom-value"); 668 expectEntry(62, 54, "custom-key", "custom-value");
666 expectEntry(63, 53, "cache-control", "no-cache"); 669 expectEntry(63, 53, "cache-control", "no-cache");
667 expectEntry(64, 57, ":authority", "www.example.com"); 670 expectEntry(64, 57, ":authority", "www.example.com");
668 EXPECT_EQ(164u, decoder_peer_.header_table()->size()); 671 EXPECT_EQ(164u, decoder_peer_.header_table()->size());
669 } 672 }
670 673
671 TEST_P(HpackDecoderTest, SectionD6ResponseHuffmanExamples) { 674 // RFC 7541, Section C.6: Response Examples with Huffman Coding
675 // http://httpwg.org/specs/rfc7541.html#rfc.section.C.6
676 TEST_P(HpackDecoderTest, SectionC6ResponseHuffmanExamples) {
672 decoder_.ApplyHeaderTableSizeSetting(256); 677 decoder_.ApplyHeaderTableSizeSetting(256);
673 678
674 // 48 | == Literal indexed == 679 // 48 | == Literal indexed ==
675 // | Indexed name (idx = 8) 680 // | Indexed name (idx = 8)
676 // | :status 681 // | :status
677 // 82 | Literal value (len = 3) 682 // 82 | Literal value (len = 3)
678 // | Huffman encoded: 683 // | Huffman encoded:
679 // 6402 | d. 684 // 6402 | d.
680 // | Decoded: 685 // | Decoded:
681 // | 302 686 // | 302
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU;" 849 "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU;"
845 " max-age=3600; version=1"); 850 " max-age=3600; version=1");
846 expectEntry(63, 52, "content-encoding", "gzip"); 851 expectEntry(63, 52, "content-encoding", "gzip");
847 expectEntry(64, 65, "date", "Mon, 21 Oct 2013 20:13:22 GMT"); 852 expectEntry(64, 65, "date", "Mon, 21 Oct 2013 20:13:22 GMT");
848 EXPECT_EQ(215u, decoder_peer_.header_table()->size()); 853 EXPECT_EQ(215u, decoder_peer_.header_table()->size());
849 } 854 }
850 855
851 } // namespace 856 } // namespace
852 } // namespace test 857 } // namespace test
853 } // namespace net 858 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/hpack/hpack_decoder_interface.h ('k') | net/spdy/spdy_flags.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698