diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-11-20 10:33:36 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-11-22 11:45:12 +0000 |
commit | be59a35641616a4cf23c4a13fa0632624b021c1b (patch) | |
tree | 9da183258bdf9cc413f7562079d25ace6955467f /chromium/net/http2 | |
parent | d702e4b6a64574e97fc7df8fe3238cde70242080 (diff) | |
download | qtwebengine-chromium-be59a35641616a4cf23c4a13fa0632624b021c1b.tar.gz |
BASELINE: Update Chromium to 62.0.3202.101
Change-Id: I2d5eca8117600df6d331f6166ab24d943d9814ac
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/net/http2')
21 files changed, 147 insertions, 115 deletions
diff --git a/chromium/net/http2/PRESUBMIT.py b/chromium/net/http2/PRESUBMIT.py index 9e6980d1880..f6012042bd5 100644 --- a/chromium/net/http2/PRESUBMIT.py +++ b/chromium/net/http2/PRESUBMIT.py @@ -34,6 +34,9 @@ def CheckChange(input_api, message_type): r"\bbase::StringPrintf\b", r"\bbase::StringAppendF\b", r"\bbase::HexDigitToInt\b", + r"\bbase::HexEncode\b", + r"\bHexDecode\b", + r"\bHexDump\b", ] messages = [ "Include \"http2/platform/api/http2_export.h\" " @@ -46,6 +49,9 @@ def CheckChange(input_api, message_type): "instead of \"base/strings/string_piece.h\"", "Use Http2StringPiece instead of base::StringPiece", "Use Http2StringPrintf instead of base::StringPrintf", + "Use Http2HexEncode instead of base::HexEncode", + "Use Http2HexDecode instead of HexDecode", + "Use Http2HexDump instead of HexDump", ] for forbidden_regex, message in zip(forbidden_regex_list, messages): result.extend(CheckForbiddenRegex( diff --git a/chromium/net/http2/hpack/decoder/hpack_block_decoder_test.cc b/chromium/net/http2/hpack/decoder/hpack_block_decoder_test.cc index 2a74c84a447..66c1519111c 100644 --- a/chromium/net/http2/hpack/decoder/hpack_block_decoder_test.cc +++ b/chromium/net/http2/hpack/decoder/hpack_block_decoder_test.cc @@ -4,6 +4,8 @@ #include "net/http2/hpack/decoder/hpack_block_decoder.h" +#include <cstdint> + // Tests of HpackBlockDecoder. #include <sstream> @@ -53,14 +55,14 @@ class HpackBlockDecoderTest : public RandomDecoderTest { } AssertionResult DecodeAndValidateSeveralWays(DecodeBuffer* db, - Validator validator) { + const Validator& validator) { bool return_non_zero_on_first = false; return RandomDecoderTest::DecodeAndValidateSeveralWays( db, return_non_zero_on_first, validator); } AssertionResult DecodeAndValidateSeveralWays(const HpackBlockBuilder& hbb, - Validator validator) { + const Validator& validator) { DecodeBuffer db(hbb.buffer()); return DecodeAndValidateSeveralWays(&db, validator); } diff --git a/chromium/net/http2/hpack/decoder/http2_hpack_decoder.cc b/chromium/net/http2/hpack/decoder/hpack_decoder.cc index 4a31db3ac35..8d70c71f72b 100644 --- a/chromium/net/http2/hpack/decoder/http2_hpack_decoder.cc +++ b/chromium/net/http2/hpack/decoder/hpack_decoder.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/http2/hpack/decoder/http2_hpack_decoder.h" +#include "net/http2/hpack/decoder/hpack_decoder.h" #include "base/logging.h" #include "base/trace_event/memory_usage_estimator.h" @@ -10,40 +10,38 @@ namespace net { -Http2HpackDecoder::Http2HpackDecoder(HpackDecoderListener* listener, - size_t max_string_size) +HpackDecoder::HpackDecoder(HpackDecoderListener* listener, + size_t max_string_size) : decoder_state_(listener), entry_buffer_(&decoder_state_, max_string_size), block_decoder_(&entry_buffer_), error_detected_(false) {} -Http2HpackDecoder::~Http2HpackDecoder() {} +HpackDecoder::~HpackDecoder() {} -void Http2HpackDecoder::set_listener(HpackDecoderListener* listener) { +void HpackDecoder::set_listener(HpackDecoderListener* listener) { return decoder_state_.set_listener(listener); } -HpackDecoderListener* Http2HpackDecoder::listener() const { +HpackDecoderListener* HpackDecoder::listener() const { return decoder_state_.listener(); } -void Http2HpackDecoder::set_tables_debug_listener( +void HpackDecoder::set_tables_debug_listener( HpackDecoderTablesDebugListener* debug_listener) { decoder_state_.set_tables_debug_listener(debug_listener); } -void Http2HpackDecoder::set_max_string_size_bytes( - size_t max_string_size_bytes) { +void HpackDecoder::set_max_string_size_bytes(size_t max_string_size_bytes) { entry_buffer_.set_max_string_size_bytes(max_string_size_bytes); } -void Http2HpackDecoder::ApplyHeaderTableSizeSetting( - uint32_t max_header_table_size) { +void HpackDecoder::ApplyHeaderTableSizeSetting(uint32_t max_header_table_size) { decoder_state_.ApplyHeaderTableSizeSetting(max_header_table_size); } -bool Http2HpackDecoder::StartDecodingBlock() { - DVLOG(3) << "Http2HpackDecoder::StartDecodingBlock, error_detected=" +bool HpackDecoder::StartDecodingBlock() { + DVLOG(3) << "HpackDecoder::StartDecodingBlock, error_detected=" << (error_detected() ? "true" : "false"); if (error_detected()) { return false; @@ -56,8 +54,8 @@ bool Http2HpackDecoder::StartDecodingBlock() { return true; } -bool Http2HpackDecoder::DecodeFragment(DecodeBuffer* db) { - DVLOG(3) << "Http2HpackDecoder::DecodeFragment, error_detected=" +bool HpackDecoder::DecodeFragment(DecodeBuffer* db) { + DVLOG(3) << "HpackDecoder::DecodeFragment, error_detected=" << (error_detected() ? "true" : "false") << ", size=" << db->Remaining(); if (error_detected()) { @@ -83,8 +81,8 @@ bool Http2HpackDecoder::DecodeFragment(DecodeBuffer* db) { return true; } -bool Http2HpackDecoder::EndDecodingBlock() { - DVLOG(3) << "Http2HpackDecoder::EndDecodingBlock, error_detected=" +bool HpackDecoder::EndDecodingBlock() { + DVLOG(3) << "HpackDecoder::EndDecodingBlock, error_detected=" << (error_detected() ? "true" : "false"); if (error_detected()) { return false; @@ -102,25 +100,25 @@ bool Http2HpackDecoder::EndDecodingBlock() { return true; } -bool Http2HpackDecoder::error_detected() { +bool HpackDecoder::error_detected() { if (!error_detected_) { if (entry_buffer_.error_detected()) { - DVLOG(2) << "Http2HpackDecoder::error_detected in entry_buffer_"; + DVLOG(2) << "HpackDecoder::error_detected in entry_buffer_"; error_detected_ = true; } else if (decoder_state_.error_detected()) { - DVLOG(2) << "Http2HpackDecoder::error_detected in decoder_state_"; + DVLOG(2) << "HpackDecoder::error_detected in decoder_state_"; error_detected_ = true; } } return error_detected_; } -size_t Http2HpackDecoder::EstimateMemoryUsage() const { +size_t HpackDecoder::EstimateMemoryUsage() const { return base::trace_event::EstimateMemoryUsage(entry_buffer_); } -void Http2HpackDecoder::ReportError(Http2StringPiece error_message) { - DVLOG(3) << "Http2HpackDecoder::ReportError is new=" +void HpackDecoder::ReportError(Http2StringPiece error_message) { + DVLOG(3) << "HpackDecoder::ReportError is new=" << (!error_detected_ ? "true" : "false") << ", error_message: " << error_message; if (!error_detected_) { diff --git a/chromium/net/http2/hpack/decoder/http2_hpack_decoder.h b/chromium/net/http2/hpack/decoder/hpack_decoder.h index c9055cde05d..71f1ae6ae97 100644 --- a/chromium/net/http2/hpack/decoder/http2_hpack_decoder.h +++ b/chromium/net/http2/hpack/decoder/hpack_decoder.h @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef NET_HTTP2_HPACK_DECODER_HTTP2_HPACK_DECODER_H_ -#define NET_HTTP2_HPACK_DECODER_HTTP2_HPACK_DECODER_H_ +#ifndef NET_HTTP2_HPACK_DECODER_HPACK_DECODER_H_ +#define NET_HTTP2_HPACK_DECODER_HPACK_DECODER_H_ -// Decodes HPACK blocks, calls an Http2HpackDecoderListener with the decoded -// header entries. Also notifies the listener of errors and of the boundaries of -// the HPACK blocks. +// Decodes HPACK blocks, calls an HpackDecoderListener with the decoded header +// entries. Also notifies the listener of errors and of the boundaries of the +// HPACK blocks. // TODO(jamessynge): Add feature allowing an HpackEntryDecoderListener // sub-class (and possibly others) to be passed in for counting events, @@ -34,13 +34,13 @@ namespace net { namespace test { -class Http2HpackDecoderPeer; +class HpackDecoderPeer; } // namespace test -class HTTP2_EXPORT_PRIVATE Http2HpackDecoder { +class HTTP2_EXPORT_PRIVATE HpackDecoder { public: - Http2HpackDecoder(HpackDecoderListener* listener, size_t max_string_size); - virtual ~Http2HpackDecoder(); + HpackDecoder(HpackDecoderListener* listener, size_t max_string_size); + virtual ~HpackDecoder(); void set_listener(HpackDecoderListener* listener); HpackDecoderListener* listener() const; @@ -99,7 +99,7 @@ class HTTP2_EXPORT_PRIVATE Http2HpackDecoder { size_t EstimateMemoryUsage() const; private: - friend class test::Http2HpackDecoderPeer; + friend class test::HpackDecoderPeer; // Reports an error to the listener IF this is the first error detected. void ReportError(Http2StringPiece error_message); @@ -117,9 +117,9 @@ class HTTP2_EXPORT_PRIVATE Http2HpackDecoder { // Has an error been detected? bool error_detected_; - DISALLOW_COPY_AND_ASSIGN(Http2HpackDecoder); + DISALLOW_COPY_AND_ASSIGN(HpackDecoder); }; } // namespace net -#endif // NET_HTTP2_HPACK_DECODER_HTTP2_HPACK_DECODER_H_ +#endif // NET_HTTP2_HPACK_DECODER_HPACK_DECODER_H_ diff --git a/chromium/net/http2/hpack/decoder/hpack_decoder_string_buffer.h b/chromium/net/http2/hpack/decoder/hpack_decoder_string_buffer.h index 5136d945e53..efaedb70150 100644 --- a/chromium/net/http2/hpack/decoder/hpack_decoder_string_buffer.h +++ b/chromium/net/http2/hpack/decoder/hpack_decoder_string_buffer.h @@ -14,7 +14,7 @@ #include <ostream> #include "base/macros.h" -#include "net/http2/hpack/huffman/http2_hpack_huffman_decoder.h" +#include "net/http2/hpack/huffman/hpack_huffman_decoder.h" #include "net/http2/platform/api/http2_export.h" #include "net/http2/platform/api/http2_string.h" #include "net/http2/platform/api/http2_string_piece.h" diff --git a/chromium/net/http2/hpack/decoder/hpack_decoder_string_buffer_test.cc b/chromium/net/http2/hpack/decoder/hpack_decoder_string_buffer_test.cc index 72846adac95..1a5898feb77 100644 --- a/chromium/net/http2/hpack/decoder/hpack_decoder_string_buffer_test.cc +++ b/chromium/net/http2/hpack/decoder/hpack_decoder_string_buffer_test.cc @@ -9,8 +9,8 @@ #include <sstream> #include "base/logging.h" +#include "net/http2/platform/api/http2_string_utils.h" #include "net/http2/tools/failure.h" -#include "net/spdy/core/spdy_test_utils.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -152,7 +152,7 @@ TEST_F(HpackDecoderStringBufferTest, PlainSplit) { } TEST_F(HpackDecoderStringBufferTest, HuffmanWhole) { - Http2String encoded = a2b_hex("f1e3c2e5f23a6ba0ab90f4ff"); + Http2String encoded = Http2HexDecode("f1e3c2e5f23a6ba0ab90f4ff"); Http2StringPiece decoded("www.example.com"); EXPECT_EQ(state(), State::RESET); @@ -177,7 +177,7 @@ TEST_F(HpackDecoderStringBufferTest, HuffmanWhole) { } TEST_F(HpackDecoderStringBufferTest, HuffmanSplit) { - Http2String encoded = a2b_hex("f1e3c2e5f23a6ba0ab90f4ff"); + Http2String encoded = Http2HexDecode("f1e3c2e5f23a6ba0ab90f4ff"); Http2String part1 = encoded.substr(0, 5); Http2String part2 = encoded.substr(5); Http2StringPiece decoded("www.example.com"); @@ -216,7 +216,7 @@ TEST_F(HpackDecoderStringBufferTest, HuffmanSplit) { TEST_F(HpackDecoderStringBufferTest, InvalidHuffmanOnData) { // Explicitly encode the End-of-String symbol, a no-no. - Http2String encoded = a2b_hex("ffffffff"); + Http2String encoded = Http2HexDecode("ffffffff"); buf_.OnStart(/*huffman_encoded*/ true, encoded.size()); EXPECT_EQ(state(), State::COLLECTING); @@ -230,7 +230,7 @@ TEST_F(HpackDecoderStringBufferTest, InvalidHuffmanOnData) { TEST_F(HpackDecoderStringBufferTest, InvalidHuffmanOnEnd) { // Last byte of string doesn't end with prefix of End-of-String symbol. - Http2String encoded = a2b_hex("00"); + Http2String encoded = Http2HexDecode("00"); buf_.OnStart(/*huffman_encoded*/ true, encoded.size()); EXPECT_EQ(state(), State::COLLECTING); diff --git a/chromium/net/http2/hpack/decoder/http2_hpack_decoder_test.cc b/chromium/net/http2/hpack/decoder/hpack_decoder_test.cc index 2293fc77efa..9e1d5759c8f 100644 --- a/chromium/net/http2/hpack/decoder/http2_hpack_decoder_test.cc +++ b/chromium/net/http2/hpack/decoder/hpack_decoder_test.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/http2/hpack/decoder/http2_hpack_decoder.h" +#include "net/http2/hpack/decoder/hpack_decoder.h" -// Tests of Http2HpackDecoder. +// Tests of HpackDecoder. #include <tuple> #include <utility> @@ -41,12 +41,12 @@ class HpackDecoderStatePeer { return &state->decoder_tables_; } }; -class Http2HpackDecoderPeer { +class HpackDecoderPeer { public: - static HpackDecoderState* GetDecoderState(Http2HpackDecoder* decoder) { + static HpackDecoderState* GetDecoderState(HpackDecoder* decoder) { return &decoder->decoder_state_; } - static HpackDecoderTables* GetDecoderTables(Http2HpackDecoder* decoder) { + static HpackDecoderTables* GetDecoderTables(HpackDecoder* decoder) { return HpackDecoderStatePeer::GetDecoderTables(GetDecoderState(decoder)); } }; @@ -69,17 +69,17 @@ class MockHpackDecoderListener : public HpackDecoderListener { MOCK_METHOD1(OnHeaderErrorDetected, void(Http2StringPiece error_message)); }; -class Http2HpackDecoderTest : public ::testing::TestWithParam<bool>, - public HpackDecoderListener { +class HpackDecoderTest : public ::testing::TestWithParam<bool>, + public HpackDecoderListener { protected: // Note that we initialize the random number generator with the same seed // for each individual test, therefore the order in which the tests are // executed does not effect the sequence produced by the RNG within any // one test. - Http2HpackDecoderTest() : decoder_(this, 4096) { + HpackDecoderTest() : decoder_(this, 4096) { fragment_the_hpack_block_ = GetParam(); } - ~Http2HpackDecoderTest() override {} + ~HpackDecoderTest() override {} void OnHeaderListStart() override { ASSERT_FALSE(saw_start_); @@ -125,7 +125,7 @@ class Http2HpackDecoderTest : public ::testing::TestWithParam<bool>, } AssertionResult DecodeBlock(Http2StringPiece block) { - VLOG(1) << "Http2HpackDecoderTest::DecodeBlock"; + VLOG(1) << "HpackDecoderTest::DecodeBlock"; VERIFY_FALSE(decoder_.error_detected()); VERIFY_TRUE(error_messages_.empty()); @@ -168,7 +168,7 @@ class Http2HpackDecoderTest : public ::testing::TestWithParam<bool>, } const HpackDecoderTables& GetDecoderTables() { - return *Http2HpackDecoderPeer::GetDecoderTables(&decoder_); + return *HpackDecoderPeer::GetDecoderTables(&decoder_); } const HpackStringPair* Lookup(size_t index) { return GetDecoderTables().Lookup(index); @@ -180,8 +180,7 @@ class Http2HpackDecoderTest : public ::testing::TestWithParam<bool>, return GetDecoderTables().header_table_size_limit(); } void set_header_table_size_limit(size_t size) { - Http2HpackDecoderPeer::GetDecoderTables(&decoder_)->DynamicTableSizeUpdate( - size); + HpackDecoderPeer::GetDecoderTables(&decoder_)->DynamicTableSizeUpdate(size); } // dynamic_index is one-based, because that is the way RFC 7541 shows it. @@ -213,7 +212,7 @@ class Http2HpackDecoderTest : public ::testing::TestWithParam<bool>, } Http2Random random_; - Http2HpackDecoder decoder_; + HpackDecoder decoder_; testing::StrictMock<MockHpackDecoderListener> mock_listener_; HpackHeaderEntries header_entries_; std::vector<Http2String> error_messages_; @@ -221,13 +220,13 @@ class Http2HpackDecoderTest : public ::testing::TestWithParam<bool>, bool saw_start_ = false; bool saw_end_ = false; }; -INSTANTIATE_TEST_CASE_P(AllWays, Http2HpackDecoderTest, ::testing::Bool()); +INSTANTIATE_TEST_CASE_P(AllWays, HpackDecoderTest, ::testing::Bool()); // Test based on RFC 7541, section C.3: Request Examples without Huffman Coding. // This section shows several consecutive header lists, corresponding to HTTP // requests, on the same connection. // http://httpwg.org/specs/rfc7541.html#rfc.section.C.3 -TEST_P(Http2HpackDecoderTest, C3_RequestExamples) { +TEST_P(HpackDecoderTest, C3_RequestExamples) { // C.3.1 First Request Http2String hpack_block = HpackExampleToStringOrDie(R"( 82 | == Indexed - Add == @@ -362,7 +361,7 @@ TEST_P(Http2HpackDecoderTest, C3_RequestExamples) { // This section shows the same examples as the previous section but uses // Huffman encoding for the literal values. // http://httpwg.org/specs/rfc7541.html#rfc.section.C.4 -TEST_P(Http2HpackDecoderTest, C4_RequestExamplesWithHuffmanEncoding) { +TEST_P(HpackDecoderTest, C4_RequestExamplesWithHuffmanEncoding) { // C.4.1 First Request Http2String hpack_block = HpackExampleToStringOrDie(R"( 82 | == Indexed - Add == @@ -511,7 +510,7 @@ TEST_P(Http2HpackDecoderTest, C4_RequestExamplesWithHuffmanEncoding) { // SETTINGS_HEADER_TABLE_SIZE is set to the value of 256 octets, causing // some evictions to occur. // http://httpwg.org/specs/rfc7541.html#rfc.section.C.5 -TEST_P(Http2HpackDecoderTest, C5_ResponseExamples) { +TEST_P(HpackDecoderTest, C5_ResponseExamples) { set_header_table_size_limit(256); // C.5.1 First Response @@ -737,7 +736,7 @@ TEST_P(Http2HpackDecoderTest, C5_ResponseExamples) { // evictions to occur. The eviction mechanism uses the length of the decoded // literal values, so the same evictions occur as in the previous section. // http://httpwg.org/specs/rfc7541.html#rfc.section.C.6 -TEST_P(Http2HpackDecoderTest, C6_ResponseExamplesWithHuffmanEncoding) { +TEST_P(HpackDecoderTest, C6_ResponseExamplesWithHuffmanEncoding) { set_header_table_size_limit(256); // C.5.1 First Response @@ -954,7 +953,7 @@ TEST_P(Http2HpackDecoderTest, C6_ResponseExamplesWithHuffmanEncoding) { } // Confirm that the table size can be changed, but at most twice. -TEST_P(Http2HpackDecoderTest, ProcessesOptionalTableSizeUpdates) { +TEST_P(HpackDecoderTest, ProcessesOptionalTableSizeUpdates) { EXPECT_EQ(Http2SettingsInfo::DefaultHeaderTableSize(), header_table_size_limit()); // One update allowed. @@ -990,7 +989,7 @@ TEST_P(Http2HpackDecoderTest, ProcessesOptionalTableSizeUpdates) { EXPECT_EQ(0u, current_header_table_size()); EXPECT_TRUE(header_entries_.empty()); } - // An error has been detected, so calls to Http2HpackDecoder::DecodeFragment + // An error has been detected, so calls to HpackDecoder::DecodeFragment // should return immediately. DecodeBuffer db("\x80"); EXPECT_FALSE(decoder_.DecodeFragment(&db)); @@ -999,7 +998,7 @@ TEST_P(Http2HpackDecoderTest, ProcessesOptionalTableSizeUpdates) { } // Confirm that the table size can be changed when required, but at most twice. -TEST_P(Http2HpackDecoderTest, ProcessesRequiredTableSizeUpdate) { +TEST_P(HpackDecoderTest, ProcessesRequiredTableSizeUpdate) { // One update required, two allowed, one provided, followed by a header. decoder_.ApplyHeaderTableSizeSetting(1024); decoder_.ApplyHeaderTableSizeSetting(2048); @@ -1055,7 +1054,7 @@ TEST_P(Http2HpackDecoderTest, ProcessesRequiredTableSizeUpdate) { } // Confirm that required size updates are validated. -TEST_P(Http2HpackDecoderTest, InvalidRequiredSizeUpdate) { +TEST_P(HpackDecoderTest, InvalidRequiredSizeUpdate) { // Require a size update, but provide one that isn't small enough (must be // zero or one, in this case). decoder_.ApplyHeaderTableSizeSetting(1); @@ -1073,7 +1072,7 @@ TEST_P(Http2HpackDecoderTest, InvalidRequiredSizeUpdate) { } // Confirm that required size updates are indeed required before the end. -TEST_P(Http2HpackDecoderTest, RequiredTableSizeChangeBeforeEnd) { +TEST_P(HpackDecoderTest, RequiredTableSizeChangeBeforeEnd) { decoder_.ApplyHeaderTableSizeSetting(1024); EXPECT_FALSE(DecodeBlock("")); EXPECT_EQ(1u, error_messages_.size()); @@ -1084,7 +1083,7 @@ TEST_P(Http2HpackDecoderTest, RequiredTableSizeChangeBeforeEnd) { // Confirm that required size updates are indeed required before an // indexed header. -TEST_P(Http2HpackDecoderTest, RequiredTableSizeChangeBeforeIndexedHeader) { +TEST_P(HpackDecoderTest, RequiredTableSizeChangeBeforeIndexedHeader) { decoder_.ApplyHeaderTableSizeSetting(1024); HpackBlockBuilder hbb; hbb.AppendIndexedHeader(1); @@ -1099,7 +1098,7 @@ TEST_P(Http2HpackDecoderTest, RequiredTableSizeChangeBeforeIndexedHeader) { // Confirm that required size updates are indeed required before an indexed // header name. // TODO(jamessynge): Move some of these to hpack_decoder_state_test.cc. -TEST_P(Http2HpackDecoderTest, RequiredTableSizeChangeBeforeIndexedHeaderName) { +TEST_P(HpackDecoderTest, RequiredTableSizeChangeBeforeIndexedHeaderName) { decoder_.ApplyHeaderTableSizeSetting(1024); HpackBlockBuilder hbb; hbb.AppendNameIndexAndLiteralValue(HpackEntryType::kIndexedLiteralHeader, 2, @@ -1114,7 +1113,7 @@ TEST_P(Http2HpackDecoderTest, RequiredTableSizeChangeBeforeIndexedHeaderName) { // Confirm that required size updates are indeed required before a literal // header name. -TEST_P(Http2HpackDecoderTest, RequiredTableSizeChangeBeforeLiteralName) { +TEST_P(HpackDecoderTest, RequiredTableSizeChangeBeforeLiteralName) { decoder_.ApplyHeaderTableSizeSetting(1024); HpackBlockBuilder hbb; hbb.AppendLiteralNameAndValue(HpackEntryType::kNeverIndexedLiteralHeader, @@ -1130,7 +1129,7 @@ TEST_P(Http2HpackDecoderTest, RequiredTableSizeChangeBeforeLiteralName) { // Confirm that an excessively long varint is detected, in this case an // index of 127, but with lots of additional high-order 0 bits provided, // too many to be allowed. -TEST_P(Http2HpackDecoderTest, InvalidIndexedHeaderVarint) { +TEST_P(HpackDecoderTest, InvalidIndexedHeaderVarint) { EXPECT_TRUE(decoder_.StartDecodingBlock()); DecodeBuffer db("\xff\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x00"); EXPECT_FALSE(decoder_.DecodeFragment(&db)); @@ -1145,7 +1144,7 @@ TEST_P(Http2HpackDecoderTest, InvalidIndexedHeaderVarint) { // Confirm that an invalid index into the tables is detected, in this case an // index of 0. -TEST_P(Http2HpackDecoderTest, InvalidIndex) { +TEST_P(HpackDecoderTest, InvalidIndex) { EXPECT_TRUE(decoder_.StartDecodingBlock()); DecodeBuffer db("\x80"); EXPECT_FALSE(decoder_.DecodeFragment(&db)); @@ -1159,7 +1158,7 @@ TEST_P(Http2HpackDecoderTest, InvalidIndex) { } // Confirm that EndDecodingBlock detects a truncated HPACK block. -TEST_P(Http2HpackDecoderTest, TruncatedBlock) { +TEST_P(HpackDecoderTest, TruncatedBlock) { HpackBlockBuilder hbb; hbb.AppendDynamicTableSizeUpdate(3000); EXPECT_EQ(3u, hbb.size()); @@ -1183,7 +1182,7 @@ TEST_P(Http2HpackDecoderTest, TruncatedBlock) { } // Confirm that an oversized string is detected, ending decoding. -TEST_P(Http2HpackDecoderTest, OversizeStringDetected) { +TEST_P(HpackDecoderTest, OversizeStringDetected) { HpackBlockBuilder hbb; hbb.AppendLiteralNameAndValue(HpackEntryType::kNeverIndexedLiteralHeader, false, "name", false, "some data."); diff --git a/chromium/net/http2/hpack/decoder/hpack_entry_decoder_test.cc b/chromium/net/http2/hpack/decoder/hpack_entry_decoder_test.cc index 54c7ce8af82..4050fdf6f4b 100644 --- a/chromium/net/http2/hpack/decoder/hpack_entry_decoder_test.cc +++ b/chromium/net/http2/hpack/decoder/hpack_entry_decoder_test.cc @@ -4,6 +4,8 @@ #include "net/http2/hpack/decoder/hpack_entry_decoder.h" +#include <cstdint> + // Tests of HpackEntryDecoder. #include "net/http2/hpack/decoder/hpack_entry_collector.h" @@ -34,7 +36,7 @@ class HpackEntryDecoderTest : public RandomDecoderTest { } AssertionResult DecodeAndValidateSeveralWays(DecodeBuffer* db, - Validator validator) { + const Validator& validator) { // StartDecoding, above, requires the DecodeBuffer be non-empty so that it // can call Start with the prefix byte. bool return_non_zero_on_first = true; @@ -43,7 +45,7 @@ class HpackEntryDecoderTest : public RandomDecoderTest { } AssertionResult DecodeAndValidateSeveralWays(const HpackBlockBuilder& hbb, - Validator validator) { + const Validator& validator) { DecodeBuffer db(hbb.buffer()); return DecodeAndValidateSeveralWays(&db, validator); } diff --git a/chromium/net/http2/hpack/decoder/hpack_varint_decoder_test.cc b/chromium/net/http2/hpack/decoder/hpack_varint_decoder_test.cc index 6ca7994bd06..4c8e6bb248d 100644 --- a/chromium/net/http2/hpack/decoder/hpack_varint_decoder_test.cc +++ b/chromium/net/http2/hpack/decoder/hpack_varint_decoder_test.cc @@ -153,8 +153,8 @@ class HpackVarintDecoderTest : public RandomDecoderTest { std::stringstream ss; ss << "value=" << value << " (0x" << std::hex << value << "), prefix_length=" << std::dec << prefix_length - << ", expected_bytes=" << expected_bytes << std::endl - << HexEncode(buffer_); + << ", expected_bytes=" << expected_bytes << "\n" + << Http2HexDump(buffer_); Http2String msg(ss.str()); if (value == minimum) { @@ -204,7 +204,7 @@ class HpackVarintDecoderTest : public RandomDecoderTest { // Confirm the claim that beyond requires more bytes. Encode(beyond, prefix_length); - EXPECT_EQ(expected_bytes + 1, buffer_.size()) << HexEncode(buffer_); + EXPECT_EQ(expected_bytes + 1, buffer_.size()) << Http2HexDump(buffer_); std::set<uint32_t> values; if (range < 200) { @@ -266,9 +266,9 @@ TEST_F(HpackVarintDecoderTest, Encode) { for (uint32_t value : values) { EncodeNoRandom(value, prefix_length); - Http2String dump = HexEncode(buffer_); + Http2String dump = Http2HexDump(buffer_); LOG(INFO) << Http2StringPrintf("%10u %0#10x ", value, value) - << HexEncode(buffer_); + << Http2HexDump(buffer_).substr(7); } } } diff --git a/chromium/net/http2/hpack/huffman/http2_hpack_huffman_decoder.cc b/chromium/net/http2/hpack/huffman/hpack_huffman_decoder.cc index eda6ed38d18..3621ca13ca9 100644 --- a/chromium/net/http2/hpack/huffman/http2_hpack_huffman_decoder.cc +++ b/chromium/net/http2/hpack/huffman/hpack_huffman_decoder.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/http2/hpack/huffman/http2_hpack_huffman_decoder.h" +#include "net/http2/hpack/huffman/hpack_huffman_decoder.h" #include <bitset> #include <limits> diff --git a/chromium/net/http2/hpack/huffman/http2_hpack_huffman_decoder.h b/chromium/net/http2/hpack/huffman/hpack_huffman_decoder.h index 18f8ec5a045..fe2c445a97f 100644 --- a/chromium/net/http2/hpack/huffman/http2_hpack_huffman_decoder.h +++ b/chromium/net/http2/hpack/huffman/hpack_huffman_decoder.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef NET_HTTP2_HPACK_HUFFMAN_HTTP2_HPACK_HUFFMAN_DECODER_H_ -#define NET_HTTP2_HPACK_HUFFMAN_HTTP2_HPACK_HUFFMAN_DECODER_H_ +#ifndef NET_HTTP2_HPACK_HUFFMAN_HPACK_HUFFMAN_DECODER_H_ +#define NET_HTTP2_HPACK_HUFFMAN_HPACK_HUFFMAN_DECODER_H_ // HpackHuffmanDecoder is an incremental decoder of strings that have been // encoded using the Huffman table defined in the HPACK spec. @@ -146,4 +146,4 @@ inline std::ostream& operator<<(std::ostream& out, } // namespace net -#endif // NET_HTTP2_HPACK_HUFFMAN_HTTP2_HPACK_HUFFMAN_DECODER_H_ +#endif // NET_HTTP2_HPACK_HUFFMAN_HPACK_HUFFMAN_DECODER_H_ diff --git a/chromium/net/http2/hpack/huffman/http2_hpack_huffman_decoder_test.cc b/chromium/net/http2/hpack/huffman/hpack_huffman_decoder_test.cc index e607f0a0511..946691616bd 100644 --- a/chromium/net/http2/hpack/huffman/http2_hpack_huffman_decoder_test.cc +++ b/chromium/net/http2/hpack/huffman/hpack_huffman_decoder_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/http2/hpack/huffman/http2_hpack_huffman_decoder.h" +#include "net/http2/hpack/huffman/hpack_huffman_decoder.h" // Tests of HpackHuffmanDecoder and HuffmanBitBuffer. @@ -11,9 +11,9 @@ #include "base/macros.h" #include "net/http2/decoder/decode_buffer.h" #include "net/http2/decoder/decode_status.h" +#include "net/http2/platform/api/http2_string_utils.h" #include "net/http2/tools/failure.h" #include "net/http2/tools/random_decoder_test.h" -#include "net/spdy/core/spdy_test_utils.h" #include "testing/gtest/include/gtest/gtest.h" using ::testing::AssertionResult; @@ -224,13 +224,13 @@ INSTANTIATE_TEST_CASE_P(AllDecoders, TEST_P(HpackHuffmanDecoderTest, SpecRequestExamples) { HpackHuffmanDecoder decoder; Http2String test_table[] = { - a2b_hex("f1e3c2e5f23a6ba0ab90f4ff"), + Http2HexDecode("f1e3c2e5f23a6ba0ab90f4ff"), "www.example.com", - a2b_hex("a8eb10649cbf"), + Http2HexDecode("a8eb10649cbf"), "no-cache", - a2b_hex("25a849e95ba97d7f"), + Http2HexDecode("25a849e95ba97d7f"), "custom-key", - a2b_hex("25a849e95bb8e8b4bf"), + Http2HexDecode("25a849e95bb8e8b4bf"), "custom-value", }; for (size_t i = 0; i != arraysize(test_table); i += 2) { @@ -248,17 +248,17 @@ TEST_P(HpackHuffmanDecoderTest, SpecResponseExamples) { HpackHuffmanDecoder decoder; // clang-format off Http2String test_table[] = { - a2b_hex("6402"), + Http2HexDecode("6402"), "302", - a2b_hex("aec3771a4b"), + Http2HexDecode("aec3771a4b"), "private", - a2b_hex("d07abe941054d444a8200595040b8166" + Http2HexDecode("d07abe941054d444a8200595040b8166" "e082a62d1bff"), "Mon, 21 Oct 2013 20:13:21 GMT", - a2b_hex("9d29ad171863c78f0b97c8e9ae82ae43" + Http2HexDecode("9d29ad171863c78f0b97c8e9ae82ae43" "d3"), "https://www.example.com", - a2b_hex("94e7821dd7f2e6c7b335dfdfcd5b3960" + Http2HexDecode("94e7821dd7f2e6c7b335dfdfcd5b3960" "d5af27087f3672c1ab270fb5291f9587" "316065c003ed4ee5b1063d5007"), "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1", diff --git a/chromium/net/http2/hpack/tools/hpack_block_builder_test.cc b/chromium/net/http2/hpack/tools/hpack_block_builder_test.cc index f5251bf4a76..19f2c1596c5 100644 --- a/chromium/net/http2/hpack/tools/hpack_block_builder_test.cc +++ b/chromium/net/http2/hpack/tools/hpack_block_builder_test.cc @@ -4,7 +4,7 @@ #include "net/http2/hpack/tools/hpack_block_builder.h" -#include "net/spdy/core/spdy_test_utils.h" +#include "net/http2/platform/api/http2_string_utils.h" #include "testing/gtest/include/gtest/gtest.h" namespace net { @@ -97,7 +97,7 @@ TEST(HpackBlockBuilderTest, ExamplesFromSpecC3) { // 0x0010: 2e63 6f6d .com const Http2String expected = - a2b_hex("828684410f7777772e6578616d706c652e636f6d"); + Http2HexDecode("828684410f7777772e6578616d706c652e636f6d"); EXPECT_EQ(expected, b.buffer()); } } @@ -127,7 +127,8 @@ TEST(HpackBlockBuilderTest, ExamplesFromSpecC4) { // 0x0000: 8286 8441 8cf1 e3c2 e5f2 3a6b a0ab 90f4 ...A......:k.... // 0x0010: ff . - const Http2String expected = a2b_hex("828684418cf1e3c2e5f23a6ba0ab90f4ff"); + const Http2String expected = + Http2HexDecode("828684418cf1e3c2e5f23a6ba0ab90f4ff"); EXPECT_EQ(expected, b.buffer()); } } diff --git a/chromium/net/http2/hpack/tools/hpack_example.cc b/chromium/net/http2/hpack/tools/hpack_example.cc index 0d0ba114ac4..ced2fe05d0a 100644 --- a/chromium/net/http2/hpack/tools/hpack_example.cc +++ b/chromium/net/http2/hpack/tools/hpack_example.cc @@ -7,7 +7,7 @@ #include <ctype.h> #include "base/logging.h" -#include "net/spdy/core/spdy_test_utils.h" +#include "net/http2/platform/api/http2_string_utils.h" namespace net { namespace test { @@ -20,7 +20,7 @@ void HpackExampleToStringOrDie(Http2StringPiece example, Http2String* output) { CHECK_GT(example.size(), 1u) << "Truncated hex byte?"; const char c1 = example[1]; CHECK(isxdigit(c1)) << "Found half a byte?"; - *output += a2b_hex(example.substr(0, 2).as_string().c_str()); + *output += Http2HexDecode(example.substr(0, 2)); example.remove_prefix(2); continue; } diff --git a/chromium/net/http2/http2_constants.h b/chromium/net/http2/http2_constants.h index bf04992c2a1..a6149f5db6b 100644 --- a/chromium/net/http2/http2_constants.h +++ b/chromium/net/http2/http2_constants.h @@ -66,8 +66,6 @@ HTTP2_EXPORT_PRIVATE inline std::ostream& operator<<(std::ostream& out, // Flags that appear in supported frame types. These are treated as bit masks. // The comments indicate for which frame types the flag is valid. -// TODO(bnc): Remove FLAG_ prefix once enum SpdyFrameType is removed -// (both enums have a PRIORITY member). enum Http2FrameFlag { END_STREAM = 0x01, // DATA, HEADERS ACK = 0x01, // SETTINGS, PING diff --git a/chromium/net/http2/http2_structures.cc b/chromium/net/http2/http2_structures.cc index f840559342f..0ed23bf8e49 100644 --- a/chromium/net/http2/http2_structures.cc +++ b/chromium/net/http2/http2_structures.cc @@ -7,8 +7,6 @@ #include <cstring> // For std::memcmp #include <sstream> -#include "base/strings/string_number_conversions.h" -#include "base/strings/string_util.h" #include "net/http2/platform/api/http2_string_utils.h" namespace net { @@ -97,9 +95,8 @@ bool operator==(const Http2PingFields& a, const Http2PingFields& b) { } std::ostream& operator<<(std::ostream& out, const Http2PingFields& v) { - Http2String s = base::HexEncode(v.opaque_data, sizeof v.opaque_data); - base::CollapseWhitespaceASCII(s, /*trim_sequences_with_line_breaks=*/false); - return out << "opaque_data=[" << s << "]"; + return out << "opaque_data=0x" + << Http2HexEncode(v.opaque_data, sizeof v.opaque_data); } // Http2GoAwayFields: diff --git a/chromium/net/http2/http2_structures_test.cc b/chromium/net/http2/http2_structures_test.cc index 0121a678cfa..c52794fbfd6 100644 --- a/chromium/net/http2/http2_structures_test.cc +++ b/chromium/net/http2/http2_structures_test.cc @@ -413,6 +413,13 @@ TEST(Http2PushPromiseTest, Misc) { EXPECT_EQ(v, w); } +TEST(Http2PingFieldsTest, Misc) { + Http2PingFields v{{'8', ' ', 'b', 'y', 't', 'e', 's', '\0'}}; + std::stringstream s; + s << v; + EXPECT_EQ("opaque_data=0x3820627974657300", s.str()); +} + TEST(Http2GoAwayFieldsTest, Misc) { Http2Random random; uint32_t last_stream_id = random.Rand32() & StreamIdMask(); diff --git a/chromium/net/http2/platform/api/http2_string_utils.h b/chromium/net/http2/platform/api/http2_string_utils.h index b03e69b57dc..2766caef42f 100644 --- a/chromium/net/http2/platform/api/http2_string_utils.h +++ b/chromium/net/http2/platform/api/http2_string_utils.h @@ -8,6 +8,7 @@ #include <utility> #include "net/http2/platform/api/http2_string.h" +#include "net/http2/platform/api/http2_string_piece.h" #include "net/http2/platform/impl/http2_string_utils_impl.h" namespace net { @@ -27,6 +28,18 @@ inline Http2String Http2StringPrintf(const Args&... args) { return Http2StringPrintfImpl(std::forward<const Args&>(args)...); } +inline Http2String Http2HexEncode(const void* bytes, size_t size) { + return Http2HexEncodeImpl(bytes, size); +} + +inline Http2String Http2HexDecode(Http2StringPiece data) { + return Http2HexDecodeImpl(data); +} + +inline Http2String Http2HexDump(Http2StringPiece data) { + return Http2HexDumpImpl(data); +} + } // namespace net #endif // NET_HTTP2_PLATFORM_API_HTTP2_STRING_UTILS_H_ diff --git a/chromium/net/http2/platform/impl/http2_string_utils_impl.h b/chromium/net/http2/platform/impl/http2_string_utils_impl.h index 8d0ff0898b5..89145fb3356 100644 --- a/chromium/net/http2/platform/impl/http2_string_utils_impl.h +++ b/chromium/net/http2/platform/impl/http2_string_utils_impl.h @@ -8,9 +8,13 @@ #include <sstream> #include <utility> +#include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" +#include "net/base/hex_utils.h" +#include "net/http2/platform/api/http2_export.h" #include "net/http2/platform/api/http2_string.h" +#include "net/http2/platform/api/http2_string_piece.h" namespace net { @@ -32,6 +36,18 @@ inline Http2String Http2StringPrintfImpl(const Args&... args) { return base::StringPrintf(std::forward<const Args&>(args)...); } +inline Http2String Http2HexEncodeImpl(const void* bytes, size_t size) { + return base::HexEncode(bytes, size); +} + +inline Http2String Http2HexDecodeImpl(Http2StringPiece data) { + return HexDecode(data); +} + +inline Http2String Http2HexDumpImpl(Http2StringPiece data) { + return HexDump(data); +} + } // namespace net #endif // NET_HTTP2_PLATFORM_IMPL_HTTP2_STRING_UTILS_IMPL_H_ diff --git a/chromium/net/http2/tools/random_decoder_test.cc b/chromium/net/http2/tools/random_decoder_test.cc index 84201a85c88..47769fc3d3b 100644 --- a/chromium/net/http2/tools/random_decoder_test.cc +++ b/chromium/net/http2/tools/random_decoder_test.cc @@ -28,10 +28,6 @@ using ::testing::AssertionSuccess; namespace net { namespace test { -Http2String HexEncode(Http2StringPiece s) { - return base::HexEncode(s.data(), s.size()); -} - RandomDecoderTest::RandomDecoderTest() {} bool RandomDecoderTest::StopDecodeOnDone() { diff --git a/chromium/net/http2/tools/random_decoder_test.h b/chromium/net/http2/tools/random_decoder_test.h index 36adf9fc6f9..2557144bfe4 100644 --- a/chromium/net/http2/tools/random_decoder_test.h +++ b/chromium/net/http2/tools/random_decoder_test.h @@ -35,9 +35,6 @@ Http2StringPiece ToStringPiece(T (&data)[N]) { return Http2StringPiece(reinterpret_cast<const char*>(data), N * sizeof(T)); } -// strings/hex_ascii_dump.h doesn't support Http2StringPiece args for this case. -Http2String HexEncode(Http2StringPiece s); - // Overwrite the enum with some random value, probably not a valid value for // the enum type, but which fits into its storage. template <typename T, |