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

Unified Diff: net/spdy/hpack/hpack_decoder3_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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/spdy/hpack/hpack_decoder3.cc ('k') | net/spdy/hpack/hpack_decoder_interface.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/hpack/hpack_decoder3_test.cc
diff --git a/net/spdy/hpack/hpack_decoder2_test.cc b/net/spdy/hpack/hpack_decoder3_test.cc
similarity index 86%
copy from net/spdy/hpack/hpack_decoder2_test.cc
copy to net/spdy/hpack/hpack_decoder3_test.cc
index efea044d19556dcdc6e047f88d7a163f29409a98..3f71724a4ffa168b774595317fc69306a0658404 100644
--- a/net/spdy/hpack/hpack_decoder2_test.cc
+++ b/net/spdy/hpack/hpack_decoder3_test.cc
@@ -1,10 +1,12 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
+// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "net/spdy/hpack/hpack_decoder2.h"
+#include "net/spdy/hpack/hpack_decoder3.h"
-// Tests of HpackDecoder2.
+// Tests of HpackDecoder3.
+
+#include <stdint.h>
#include <string>
#include <tuple>
@@ -12,47 +14,86 @@
#include <vector>
#include "base/logging.h"
-#include "base/strings/string_piece.h"
+#include "base/strings/string_number_conversions.h"
+#include "net/http2/hpack/decoder/hpack_decoder_state.h"
+#include "net/http2/hpack/decoder/hpack_decoder_tables.h"
#include "net/http2/hpack/tools/hpack_block_builder.h"
#include "net/http2/tools/http2_random.h"
+#include "net/spdy/hpack/hpack_constants.h"
#include "net/spdy/hpack/hpack_encoder.h"
-#include "net/spdy/hpack/hpack_entry.h"
#include "net/spdy/hpack/hpack_huffman_table.h"
#include "net/spdy/hpack/hpack_output_stream.h"
#include "net/spdy/spdy_test_utils.h"
+#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
using base::StringPiece;
using std::string;
+using ::testing::ElementsAre;
+using ::testing::Pair;
namespace net {
namespace test {
-class HpackDecoder2Peer {
+class HpackDecoderStatePeer {
public:
- explicit HpackDecoder2Peer(HpackDecoder2* decoder) : decoder_(decoder) {}
+ static HpackDecoderTables* GetDecoderTables(HpackDecoderState* state) {
+ return &state->decoder_tables_;
+ }
+};
+
+class Http2HpackDecoderPeer {
+ public:
+ static HpackDecoderState* GetDecoderState(Http2HpackDecoder* decoder) {
+ return &decoder->decoder_state_;
+ }
+ static HpackDecoderTables* GetDecoderTables(Http2HpackDecoder* decoder) {
+ return HpackDecoderStatePeer::GetDecoderTables(GetDecoderState(decoder));
+ }
+};
+
+class HpackDecoder3Peer {
+ public:
+ explicit HpackDecoder3Peer(HpackDecoder3* decoder) : decoder_(decoder) {}
void HandleHeaderRepresentation(StringPiece name, StringPiece value) {
- decoder_->HandleHeaderRepresentation(name, value);
+ decoder_->listener_adapter_.OnHeader(HpackEntryType::kIndexedLiteralHeader,
+ HpackString(name), HpackString(value));
+ }
+
+ HpackDecoderTables* GetDecoderTables() {
+ return Http2HpackDecoderPeer::GetDecoderTables(&decoder_->hpack_decoder_);
+ }
+
+ const HpackStringPair* GetTableEntry(uint32_t index) {
+ return GetDecoderTables()->Lookup(index);
+ }
+
+ size_t current_header_table_size() {
+ return GetDecoderTables()->current_header_table_size();
+ }
+
+ size_t header_table_size_limit() {
+ return GetDecoderTables()->header_table_size_limit();
+ }
+
+ void set_header_table_size_limit(size_t size) {
+ return GetDecoderTables()->DynamicTableSizeUpdate(size);
}
- HpackHeaderTable* header_table() { return &decoder_->header_table_; }
private:
- HpackDecoder2* decoder_;
+ HpackDecoder3* decoder_;
};
namespace {
-using testing::ElementsAre;
-using testing::Pair;
-
// Is HandleControlFrameHeadersStart to be called, and with what value?
enum StartChoice { START_WITH_HANDLER, START_WITHOUT_HANDLER, NO_START };
-class HpackDecoder2Test
+class HpackDecoder3Test
: public ::testing::TestWithParam<std::tuple<StartChoice, bool>> {
protected:
- HpackDecoder2Test() : decoder_(), decoder_peer_(&decoder_) {}
+ HpackDecoder3Test() : decoder_(), decoder_peer_(&decoder_) {}
void SetUp() override {
std::tie(start_choice_, randomly_split_input_buffer_) = GetParam();
@@ -72,6 +113,8 @@ class HpackDecoder2Test
}
bool HandleControlFrameHeadersData(StringPiece str) {
+ VLOG(3) << "HandleControlFrameHeadersData:\n"
+ << base::HexEncode(str.data(), str.size());
return decoder_.HandleControlFrameHeadersData(str.data(), str.size());
}
@@ -108,6 +151,15 @@ class HpackDecoder2Test
return true;
}
+ bool EncodeAndDecodeDynamicTableSizeUpdates(size_t first, size_t second) {
+ HpackBlockBuilder hbb;
+ hbb.AppendDynamicTableSizeUpdate(first);
+ if (second != first) {
+ hbb.AppendDynamicTableSizeUpdate(second);
+ }
+ return DecodeHeaderBlock(hbb.buffer());
+ }
+
const SpdyHeaderBlock& decoded_block() const {
if (start_choice_ == START_WITH_HANDLER) {
return handler_.decoded_block();
@@ -125,11 +177,10 @@ class HpackDecoder2Test
size_t size,
const string& name,
const string& value) {
- const HpackEntry* entry = decoder_peer_.header_table()->GetByIndex(index);
- EXPECT_EQ(name, entry->name()) << "index " << index;
- EXPECT_EQ(value, entry->value());
- EXPECT_EQ(size, entry->Size());
- EXPECT_EQ(index, decoder_peer_.header_table()->IndexOf(entry));
+ const HpackStringPair* entry = decoder_peer_.GetTableEntry(index);
+ EXPECT_EQ(name, entry->name) << "index " << index;
+ EXPECT_EQ(value, entry->value);
+ EXPECT_EQ(size, entry->size());
}
SpdyHeaderBlock MakeHeaderBlock(
@@ -142,8 +193,9 @@ class HpackDecoder2Test
}
Http2Random random_;
- HpackDecoder2 decoder_;
- test::HpackDecoder2Peer decoder_peer_;
+ HpackHuffmanTable huffman_table_;
+ HpackDecoder3 decoder_;
+ test::HpackDecoder3Peer decoder_peer_;
TestHeadersHandler handler_;
StartChoice start_choice_;
bool randomly_split_input_buffer_;
@@ -152,12 +204,12 @@ class HpackDecoder2Test
INSTANTIATE_TEST_CASE_P(
StartChoiceAndRandomlySplitChoice,
- HpackDecoder2Test,
+ HpackDecoder3Test,
::testing::Combine(
::testing::Values(START_WITH_HANDLER, START_WITHOUT_HANDLER, NO_START),
::testing::Bool()));
-TEST_P(HpackDecoder2Test, AddHeaderDataWithHandleControlFrameHeadersData) {
+TEST_P(HpackDecoder3Test, AddHeaderDataWithHandleControlFrameHeadersData) {
// The hpack decode buffer size is limited in size. This test verifies that
// adding encoded data under that limit is accepted, and data that exceeds the
// limit is rejected.
@@ -165,26 +217,22 @@ TEST_P(HpackDecoder2Test, AddHeaderDataWithHandleControlFrameHeadersData) {
const size_t kMaxBufferSizeBytes = 50;
const string a_value = string(49, 'x');
decoder_.set_max_decode_buffer_size_bytes(kMaxBufferSizeBytes);
- {
- HpackBlockBuilder hbb;
- hbb.AppendLiteralNameAndValue(HpackEntryType::kNeverIndexedLiteralHeader,
- false, "a", false, a_value);
- const auto& s = hbb.buffer();
- EXPECT_TRUE(decoder_.HandleControlFrameHeadersData(s.data(), s.size()));
- }
- {
- HpackBlockBuilder hbb;
- hbb.AppendLiteralNameAndValue(HpackEntryType::kNeverIndexedLiteralHeader,
- false, "b", false, string(51, 'x'));
- const auto& s = hbb.buffer();
- EXPECT_FALSE(decoder_.HandleControlFrameHeadersData(s.data(), s.size()));
- }
+ HpackBlockBuilder hbb;
+ hbb.AppendLiteralNameAndValue(HpackEntryType::kNeverIndexedLiteralHeader,
+ false, "a", false, a_value);
+ const string& s = hbb.buffer();
+ EXPECT_GT(s.size(), kMaxBufferSizeBytes);
+
+ // Any one in input buffer must not exceed kMaxBufferSizeBytes.
+ EXPECT_TRUE(HandleControlFrameHeadersData(s.substr(0, s.size() / 2)));
+ EXPECT_TRUE(HandleControlFrameHeadersData(s.substr(s.size() / 2)));
+ EXPECT_FALSE(HandleControlFrameHeadersData(s));
SpdyHeaderBlock expected_block = MakeHeaderBlock({{"a", a_value}});
EXPECT_EQ(expected_block, decoded_block());
}
-TEST_P(HpackDecoder2Test, NameTooLong) {
+TEST_P(HpackDecoder3Test, NameTooLong) {
// Verify that a name longer than the allowed size generates an error.
const size_t kMaxBufferSizeBytes = 50;
const string name = string(2 * kMaxBufferSizeBytes, 'x');
@@ -203,7 +251,7 @@ TEST_P(HpackDecoder2Test, NameTooLong) {
EXPECT_FALSE(HandleControlFrameHeadersData(fragment));
}
-TEST_P(HpackDecoder2Test, HeaderTooLongToBuffer) {
+TEST_P(HpackDecoder3Test, HeaderTooLongToBuffer) {
// Verify that a header longer than the allowed size generates an error if
// it isn't all in one input buffer.
const string name = "some-key";
@@ -222,7 +270,7 @@ TEST_P(HpackDecoder2Test, HeaderTooLongToBuffer) {
}
// Decode with incomplete data in buffer.
-TEST_P(HpackDecoder2Test, DecodeWithIncompleteData) {
+TEST_P(HpackDecoder3Test, DecodeWithIncompleteData) {
HandleControlFrameHeadersStart();
// No need to wait for more data.
@@ -256,7 +304,7 @@ TEST_P(HpackDecoder2Test, DecodeWithIncompleteData) {
EXPECT_EQ(expected_block3, decoded_block());
}
-TEST_P(HpackDecoder2Test, HandleHeaderRepresentation) {
+TEST_P(HpackDecoder3Test, HandleHeaderRepresentation) {
// Make sure the decoder is properly initialized.
HandleControlFrameHeadersStart();
HandleControlFrameHeadersData("");
@@ -301,7 +349,7 @@ TEST_P(HpackDecoder2Test, HandleHeaderRepresentation) {
}
// Decoding indexed static table field should work.
-TEST_P(HpackDecoder2Test, IndexedHeaderStatic) {
+TEST_P(HpackDecoder3Test, IndexedHeaderStatic) {
// Reference static table entries #2 and #5.
const SpdyHeaderBlock& header_set1 = DecodeBlockExpectingSuccess("\x82\x85");
SpdyHeaderBlock expected_header_set1;
@@ -316,7 +364,7 @@ TEST_P(HpackDecoder2Test, IndexedHeaderStatic) {
EXPECT_EQ(expected_header_set2, header_set2);
}
-TEST_P(HpackDecoder2Test, IndexedHeaderDynamic) {
+TEST_P(HpackDecoder3Test, IndexedHeaderDynamic) {
// First header block: add an entry to header table.
const SpdyHeaderBlock& header_set1 = DecodeBlockExpectingSuccess(
"\x40\x03"
@@ -346,14 +394,14 @@ TEST_P(HpackDecoder2Test, IndexedHeaderDynamic) {
}
// Test a too-large indexed header.
-TEST_P(HpackDecoder2Test, InvalidIndexedHeader) {
+TEST_P(HpackDecoder3Test, InvalidIndexedHeader) {
// High-bit set, and a prefix of one more than the number of static entries.
EXPECT_FALSE(DecodeHeaderBlock("\xbe"));
}
-TEST_P(HpackDecoder2Test, ContextUpdateMaximumSize) {
+TEST_P(HpackDecoder3Test, ContextUpdateMaximumSize) {
EXPECT_EQ(kDefaultHeaderTableSizeSetting,
- decoder_peer_.header_table()->max_size());
+ decoder_peer_.header_table_size_limit());
string input;
{
// Maximum-size update with size 126. Succeeds.
@@ -363,7 +411,7 @@ TEST_P(HpackDecoder2Test, ContextUpdateMaximumSize) {
output_stream.TakeString(&input);
EXPECT_TRUE(DecodeHeaderBlock(StringPiece(input)));
- EXPECT_EQ(126u, decoder_peer_.header_table()->max_size());
+ EXPECT_EQ(126u, decoder_peer_.header_table_size_limit());
}
{
// Maximum-size update with kDefaultHeaderTableSizeSetting. Succeeds.
@@ -374,7 +422,7 @@ TEST_P(HpackDecoder2Test, ContextUpdateMaximumSize) {
output_stream.TakeString(&input);
EXPECT_TRUE(DecodeHeaderBlock(StringPiece(input)));
EXPECT_EQ(kDefaultHeaderTableSizeSetting,
- decoder_peer_.header_table()->max_size());
+ decoder_peer_.header_table_size_limit());
}
{
// Maximum-size update with kDefaultHeaderTableSizeSetting + 1. Fails.
@@ -385,12 +433,12 @@ TEST_P(HpackDecoder2Test, ContextUpdateMaximumSize) {
output_stream.TakeString(&input);
EXPECT_FALSE(DecodeHeaderBlock(StringPiece(input)));
EXPECT_EQ(kDefaultHeaderTableSizeSetting,
- decoder_peer_.header_table()->max_size());
+ decoder_peer_.header_table_size_limit());
}
}
// Two HeaderTableSizeUpdates may appear at the beginning of the block
-TEST_P(HpackDecoder2Test, TwoTableSizeUpdates) {
+TEST_P(HpackDecoder3Test, TwoTableSizeUpdates) {
string input;
{
// Should accept two table size updates, update to second one
@@ -402,12 +450,12 @@ TEST_P(HpackDecoder2Test, TwoTableSizeUpdates) {
output_stream.TakeString(&input);
EXPECT_TRUE(DecodeHeaderBlock(StringPiece(input)));
- EXPECT_EQ(122u, decoder_peer_.header_table()->max_size());
+ EXPECT_EQ(122u, decoder_peer_.header_table_size_limit());
}
}
// Three HeaderTableSizeUpdates should result in an error
-TEST_P(HpackDecoder2Test, ThreeTableSizeUpdatesError) {
+TEST_P(HpackDecoder3Test, ThreeTableSizeUpdatesError) {
string input;
{
// Should reject three table size updates, update to second one
@@ -422,13 +470,13 @@ TEST_P(HpackDecoder2Test, ThreeTableSizeUpdatesError) {
output_stream.TakeString(&input);
EXPECT_FALSE(DecodeHeaderBlock(StringPiece(input)));
- EXPECT_EQ(10u, decoder_peer_.header_table()->max_size());
+ EXPECT_EQ(10u, decoder_peer_.header_table_size_limit());
}
}
// HeaderTableSizeUpdates may only appear at the beginning of the block
// Any other updates should result in an error
-TEST_P(HpackDecoder2Test, TableSizeUpdateSecondError) {
+TEST_P(HpackDecoder3Test, TableSizeUpdateSecondError) {
string input;
{
// Should reject a table size update appearing after a different entry
@@ -442,13 +490,13 @@ TEST_P(HpackDecoder2Test, TableSizeUpdateSecondError) {
EXPECT_FALSE(DecodeHeaderBlock(StringPiece(input)));
EXPECT_EQ(kDefaultHeaderTableSizeSetting,
- decoder_peer_.header_table()->max_size());
+ decoder_peer_.header_table_size_limit());
}
}
// HeaderTableSizeUpdates may only appear at the beginning of the block
// Any other updates should result in an error
-TEST_P(HpackDecoder2Test, TableSizeUpdateFirstThirdError) {
+TEST_P(HpackDecoder3Test, TableSizeUpdateFirstThirdError) {
string input;
{
// Should reject the second table size update
@@ -464,13 +512,13 @@ TEST_P(HpackDecoder2Test, TableSizeUpdateFirstThirdError) {
output_stream.TakeString(&input);
EXPECT_FALSE(DecodeHeaderBlock(StringPiece(input)));
- EXPECT_EQ(60u, decoder_peer_.header_table()->max_size());
+ EXPECT_EQ(60u, decoder_peer_.header_table_size_limit());
}
}
// Decoding two valid encoded literal headers with no indexing should
// work.
-TEST_P(HpackDecoder2Test, LiteralHeaderNoIndexing) {
+TEST_P(HpackDecoder3Test, LiteralHeaderNoIndexing) {
// First header with indexed name, second header with string literal
// name.
const char input[] = "\x04\x0c/sample/path\x00\x06:path2\x0e/sample/path/2";
@@ -485,7 +533,7 @@ TEST_P(HpackDecoder2Test, LiteralHeaderNoIndexing) {
// Decoding two valid encoded literal headers with incremental
// indexing and string literal names should work.
-TEST_P(HpackDecoder2Test, LiteralHeaderIncrementalIndexing) {
+TEST_P(HpackDecoder3Test, LiteralHeaderIncrementalIndexing) {
const char input[] = "\x44\x0c/sample/path\x40\x06:path2\x0e/sample/path/2";
const SpdyHeaderBlock& header_set =
DecodeBlockExpectingSuccess(StringPiece(input, arraysize(input) - 1));
@@ -496,8 +544,9 @@ TEST_P(HpackDecoder2Test, LiteralHeaderIncrementalIndexing) {
EXPECT_EQ(expected_header_set, header_set);
}
-TEST_P(HpackDecoder2Test, LiteralHeaderWithIndexingInvalidNameIndex) {
+TEST_P(HpackDecoder3Test, LiteralHeaderWithIndexingInvalidNameIndex) {
decoder_.ApplyHeaderTableSizeSetting(0);
+ EXPECT_TRUE(EncodeAndDecodeDynamicTableSizeUpdates(0, 0));
// Name is the last static index. Works.
EXPECT_TRUE(DecodeHeaderBlock(StringPiece("\x7d\x03ooo")));
@@ -505,27 +554,27 @@ TEST_P(HpackDecoder2Test, LiteralHeaderWithIndexingInvalidNameIndex) {
EXPECT_FALSE(DecodeHeaderBlock(StringPiece("\x7e\x03ooo")));
}
-TEST_P(HpackDecoder2Test, LiteralHeaderNoIndexingInvalidNameIndex) {
+TEST_P(HpackDecoder3Test, LiteralHeaderNoIndexingInvalidNameIndex) {
// Name is the last static index. Works.
EXPECT_TRUE(DecodeHeaderBlock(StringPiece("\x0f\x2e\x03ooo")));
// Name is one beyond the last static index. Fails.
EXPECT_FALSE(DecodeHeaderBlock(StringPiece("\x0f\x2f\x03ooo")));
}
-TEST_P(HpackDecoder2Test, LiteralHeaderNeverIndexedInvalidNameIndex) {
+TEST_P(HpackDecoder3Test, LiteralHeaderNeverIndexedInvalidNameIndex) {
// Name is the last static index. Works.
EXPECT_TRUE(DecodeHeaderBlock(StringPiece("\x1f\x2e\x03ooo")));
// Name is one beyond the last static index. Fails.
EXPECT_FALSE(DecodeHeaderBlock(StringPiece("\x1f\x2f\x03ooo")));
}
-TEST_P(HpackDecoder2Test, TruncatedIndex) {
+TEST_P(HpackDecoder3Test, TruncatedIndex) {
// Indexed Header, varint for index requires multiple bytes,
// but only one provided.
EXPECT_FALSE(DecodeHeaderBlock(StringPiece("\xff", 1)));
}
-TEST_P(HpackDecoder2Test, TruncatedHuffmanLiteral) {
+TEST_P(HpackDecoder3Test, TruncatedHuffmanLiteral) {
// Literal value, Huffman encoded, but with the last byte missing (i.e.
// drop the final ff shown below).
//
@@ -545,7 +594,7 @@ TEST_P(HpackDecoder2Test, TruncatedHuffmanLiteral) {
EXPECT_FALSE(DecodeHeaderBlock(first));
}
-TEST_P(HpackDecoder2Test, HuffmanEOSError) {
+TEST_P(HpackDecoder3Test, HuffmanEOSError) {
// Literal value, Huffman encoded, but with an additional ff byte at the end
// of the string, i.e. an EOS that is longer than permitted.
//
@@ -565,8 +614,9 @@ TEST_P(HpackDecoder2Test, HuffmanEOSError) {
EXPECT_FALSE(DecodeHeaderBlock(first));
}
-// Round-tripping the header set from E.2.1 should work.
-TEST_P(HpackDecoder2Test, BasicE21) {
+// Round-tripping the header set from RFC 7541 C.3.1 should work.
+// http://httpwg.org/specs/rfc7541.html#rfc.section.C.3.1
+TEST_P(HpackDecoder3Test, BasicC31) {
HpackEncoder encoder(ObtainHpackHuffmanTable());
SpdyHeaderBlock expected_header_set;
@@ -583,7 +633,9 @@ TEST_P(HpackDecoder2Test, BasicE21) {
EXPECT_EQ(expected_header_set, decoded_block());
}
-TEST_P(HpackDecoder2Test, SectionD4RequestHuffmanExamples) {
+// RFC 7541, Section C.4: Request Examples with Huffman Coding
+// http://httpwg.org/specs/rfc7541.html#rfc.section.C.4
+TEST_P(HpackDecoder3Test, SectionC4RequestHuffmanExamples) {
// TODO(jamessynge): Use net/http2/hpack/tools/hpack_example.h to parse the
// example directly, instead of having it as a comment.
// 82 | == Indexed - Add ==
@@ -617,7 +669,7 @@ TEST_P(HpackDecoder2Test, SectionD4RequestHuffmanExamples) {
// clang-format on
expectEntry(62, 57, ":authority", "www.example.com");
- EXPECT_EQ(57u, decoder_peer_.header_table()->size());
+ EXPECT_EQ(57u, decoder_peer_.current_header_table_size());
// 82 | == Indexed - Add ==
// | idx = 2
@@ -657,7 +709,7 @@ TEST_P(HpackDecoder2Test, SectionD4RequestHuffmanExamples) {
expectEntry(62, 53, "cache-control", "no-cache");
expectEntry(63, 57, ":authority", "www.example.com");
- EXPECT_EQ(110u, decoder_peer_.header_table()->size());
+ EXPECT_EQ(110u, decoder_peer_.current_header_table_size());
// 82 | == Indexed - Add ==
// | idx = 2
@@ -700,11 +752,15 @@ TEST_P(HpackDecoder2Test, SectionD4RequestHuffmanExamples) {
expectEntry(62, 54, "custom-key", "custom-value");
expectEntry(63, 53, "cache-control", "no-cache");
expectEntry(64, 57, ":authority", "www.example.com");
- EXPECT_EQ(164u, decoder_peer_.header_table()->size());
+ EXPECT_EQ(164u, decoder_peer_.current_header_table_size());
}
-TEST_P(HpackDecoder2Test, SectionD6ResponseHuffmanExamples) {
- decoder_.ApplyHeaderTableSizeSetting(256);
+// RFC 7541, Section C.6: Response Examples with Huffman Coding
+// http://httpwg.org/specs/rfc7541.html#rfc.section.C.6
+TEST_P(HpackDecoder3Test, SectionC6ResponseHuffmanExamples) {
+ // The example is based on a maximum dynamic table size of 256,
+ // which allows for testing dynamic table evictions.
+ decoder_peer_.set_header_table_size_limit(256);
// 48 | == Literal indexed ==
// | Indexed name (idx = 8)
@@ -768,7 +824,7 @@ TEST_P(HpackDecoder2Test, SectionD6ResponseHuffmanExamples) {
expectEntry(63, 65, "date", "Mon, 21 Oct 2013 20:13:21 GMT");
expectEntry(64, 52, "cache-control", "private");
expectEntry(65, 42, ":status", "302");
- EXPECT_EQ(222u, decoder_peer_.header_table()->size());
+ EXPECT_EQ(222u, decoder_peer_.current_header_table_size());
// 48 | == Literal indexed ==
// | Indexed name (idx = 8)
@@ -808,7 +864,7 @@ TEST_P(HpackDecoder2Test, SectionD6ResponseHuffmanExamples) {
expectEntry(63, 63, "location", "https://www.example.com");
expectEntry(64, 65, "date", "Mon, 21 Oct 2013 20:13:21 GMT");
expectEntry(65, 52, "cache-control", "private");
- EXPECT_EQ(222u, decoder_peer_.header_table()->size());
+ EXPECT_EQ(222u, decoder_peer_.current_header_table_size());
// 88 | == Indexed - Add ==
// | idx = 8
@@ -888,19 +944,21 @@ TEST_P(HpackDecoder2Test, SectionD6ResponseHuffmanExamples) {
" max-age=3600; version=1");
expectEntry(63, 52, "content-encoding", "gzip");
expectEntry(64, 65, "date", "Mon, 21 Oct 2013 20:13:22 GMT");
- EXPECT_EQ(215u, decoder_peer_.header_table()->size());
+ EXPECT_EQ(215u, decoder_peer_.current_header_table_size());
}
// Regression test: Found that entries with dynamic indexed names and literal
// values caused "use after free" MSAN failures if the name was evicted as it
// was being re-used.
-TEST_P(HpackDecoder2Test, ReuseNameOfEvictedEntry) {
+TEST_P(HpackDecoder3Test, ReuseNameOfEvictedEntry) {
// Each entry is measured as 32 bytes plus the sum of the lengths of the name
// and the value. Set the size big enough for at most one entry, and a fairly
// small one at that (31 ASCII characters).
decoder_.ApplyHeaderTableSizeSetting(63);
HpackBlockBuilder hbb;
+ hbb.AppendDynamicTableSizeUpdate(0);
+ hbb.AppendDynamicTableSizeUpdate(63);
const StringPiece name("some-name");
const StringPiece value1("some-value");
« no previous file with comments | « net/spdy/hpack/hpack_decoder3.cc ('k') | net/spdy/hpack/hpack_decoder_interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698