diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-11-18 16:35:47 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-11-18 15:45:54 +0000 |
commit | 32f5a1c56531e4210bc4cf8d8c7825d66e081888 (patch) | |
tree | eeeec6822f4d738d8454525233fd0e2e3a659e6d /chromium/net/spdy | |
parent | 99677208ff3b216fdfec551fbe548da5520cd6fb (diff) | |
download | qtwebengine-chromium-32f5a1c56531e4210bc4cf8d8c7825d66e081888.tar.gz |
BASELINE: Update Chromium to 87.0.4280.67
Change-Id: Ib157360be8c2ffb2c73125751a89f60e049c1d54
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/net/spdy')
-rw-r--r-- | chromium/net/spdy/buffered_spdy_framer.cc | 16 | ||||
-rw-r--r-- | chromium/net/spdy/buffered_spdy_framer.h | 7 | ||||
-rw-r--r-- | chromium/net/spdy/header_coalescer.cc | 9 | ||||
-rw-r--r-- | chromium/net/spdy/header_coalescer.h | 2 | ||||
-rw-r--r-- | chromium/net/spdy/header_coalescer_test.cc | 11 | ||||
-rw-r--r-- | chromium/net/spdy/multiplexed_http_stream.cc | 4 | ||||
-rw-r--r-- | chromium/net/spdy/platform/impl/spdy_string_utils_impl.h | 16 | ||||
-rw-r--r-- | chromium/net/spdy/spdy_http_utils.cc | 26 | ||||
-rw-r--r-- | chromium/net/spdy/spdy_log_util.cc | 5 | ||||
-rw-r--r-- | chromium/net/spdy/spdy_network_transaction_unittest.cc | 182 | ||||
-rw-r--r-- | chromium/net/spdy/spdy_session.cc | 6 | ||||
-rw-r--r-- | chromium/net/spdy/spdy_session_unittest.cc | 35 | ||||
-rw-r--r-- | chromium/net/spdy/spdy_stream.cc | 4 | ||||
-rw-r--r-- | chromium/net/spdy/spdy_stream_test_util.cc | 2 | ||||
-rw-r--r-- | chromium/net/spdy/spdy_test_util_common.cc | 19 |
15 files changed, 139 insertions, 205 deletions
diff --git a/chromium/net/spdy/buffered_spdy_framer.cc b/chromium/net/spdy/buffered_spdy_framer.cc index fd673aef1e1..2962dfae533 100644 --- a/chromium/net/spdy/buffered_spdy_framer.cc +++ b/chromium/net/spdy/buffered_spdy_framer.cc @@ -8,6 +8,7 @@ #include <utility> #include "base/check.h" +#include "base/strings/abseil_string_conversions.h" #include "base/strings/string_util.h" #include "base/trace_event/memory_usage_estimator.h" @@ -209,9 +210,10 @@ void BufferedSpdyFramer::OnPushPromise(spdy::SpdyStreamId stream_id, void BufferedSpdyFramer::OnAltSvc( spdy::SpdyStreamId stream_id, - base::StringPiece origin, + absl::string_view origin, const spdy::SpdyAltSvcWireFormat::AlternativeServiceVector& altsvc_vector) { - visitor_->OnAltSvc(stream_id, origin, altsvc_vector); + visitor_->OnAltSvc(stream_id, base::StringViewToStringPiece(origin), + altsvc_vector); } void BufferedSpdyFramer::OnContinuation(spdy::SpdyStreamId stream_id, @@ -299,7 +301,7 @@ std::unique_ptr<spdy::SpdySerializedFrame> BufferedSpdyFramer::CreateDataFrame( const char* data, uint32_t len, spdy::SpdyDataFlags flags) { - spdy::SpdyDataIR data_ir(stream_id, base::StringPiece(data, len)); + spdy::SpdyDataIR data_ir(stream_id, absl::string_view(data, len)); data_ir.set_fin((flags & spdy::DATA_FLAG_FIN) != 0); return std::make_unique<spdy::SpdySerializedFrame>( spdy_framer_.SerializeData(data_ir)); @@ -317,6 +319,14 @@ std::unique_ptr<spdy::SpdySerializedFrame> BufferedSpdyFramer::CreatePriority( spdy_framer_.SerializePriority(priority_ir)); } +void BufferedSpdyFramer::UpdateHeaderEncoderTableSize(uint32_t value) { + spdy_framer_.UpdateHeaderEncoderTableSize(value); +} + +uint32_t BufferedSpdyFramer::header_encoder_table_size() const { + return spdy_framer_.header_encoder_table_size(); +} + size_t BufferedSpdyFramer::EstimateMemoryUsage() const { return base::trace_event::EstimateMemoryUsage(spdy_framer_) + base::trace_event::EstimateMemoryUsage(deframer_) + diff --git a/chromium/net/spdy/buffered_spdy_framer.h b/chromium/net/spdy/buffered_spdy_framer.h index d43ddf751da..0bfb5e6aa65 100644 --- a/chromium/net/spdy/buffered_spdy_framer.h +++ b/chromium/net/spdy/buffered_spdy_framer.h @@ -181,7 +181,7 @@ class NET_EXPORT_PRIVATE BufferedSpdyFramer spdy::SpdyStreamId promised_stream_id, bool end) override; void OnAltSvc(spdy::SpdyStreamId stream_id, - base::StringPiece origin, + absl::string_view origin, const spdy::SpdyAltSvcWireFormat::AlternativeServiceVector& altsvc_vector) override; void OnDataFrameHeader(spdy::SpdyStreamId stream_id, @@ -232,6 +232,11 @@ class NET_EXPORT_PRIVATE BufferedSpdyFramer int frames_received() const { return frames_received_; } + // Updates the maximum size of the header encoder compression table. + void UpdateHeaderEncoderTableSize(uint32_t value); + // Returns the maximum size of the header encoder compression table. + uint32_t header_encoder_table_size() const; + // Returns the estimate of dynamically allocated memory in bytes. size_t EstimateMemoryUsage() const; diff --git a/chromium/net/spdy/header_coalescer.cc b/chromium/net/spdy/header_coalescer.cc index a77c1b8840d..c4719625f52 100644 --- a/chromium/net/spdy/header_coalescer.cc +++ b/chromium/net/spdy/header_coalescer.cc @@ -8,6 +8,7 @@ #include <string> #include <utility> +#include "base/strings/abseil_string_conversions.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" #include "base/trace_event/memory_usage_estimator.h" @@ -46,10 +47,11 @@ HeaderCoalescer::HeaderCoalescer(uint32_t max_header_list_size, const NetLogWithSource& net_log) : max_header_list_size_(max_header_list_size), net_log_(net_log) {} -void HeaderCoalescer::OnHeader(base::StringPiece key, base::StringPiece value) { +void HeaderCoalescer::OnHeader(absl::string_view key, absl::string_view value) { if (error_seen_) return; - if (!AddHeader(key, value)) + if (!AddHeader(base::StringViewToStringPiece(key), + base::StringViewToStringPiece(value))) error_seen_ = true; } @@ -122,7 +124,8 @@ bool HeaderCoalescer::AddHeader(base::StringPiece key, } } - headers_.AppendValueOrAddHeader(key, value); + headers_.AppendValueOrAddHeader(base::StringPieceToStringView(key), + base::StringPieceToStringView(value)); return true; } diff --git a/chromium/net/spdy/header_coalescer.h b/chromium/net/spdy/header_coalescer.h index 2adde8c6f70..e07490bbfdc 100644 --- a/chromium/net/spdy/header_coalescer.h +++ b/chromium/net/spdy/header_coalescer.h @@ -21,7 +21,7 @@ class NET_EXPORT_PRIVATE HeaderCoalescer void OnHeaderBlockStart() override {} - void OnHeader(base::StringPiece key, base::StringPiece value) override; + void OnHeader(absl::string_view key, absl::string_view value) override; void OnHeaderBlockEnd(size_t uncompressed_header_bytes, size_t compressed_header_bytes) override {} diff --git a/chromium/net/spdy/header_coalescer_test.cc b/chromium/net/spdy/header_coalescer_test.cc index 30a44e3d7f7..c7c1c8ee333 100644 --- a/chromium/net/spdy/header_coalescer_test.cc +++ b/chromium/net/spdy/header_coalescer_test.cc @@ -70,8 +70,7 @@ TEST_F(HeaderCoalescerTest, HeaderBlockTooLarge) { EXPECT_FALSE(header_coalescer_.error_seen()); // Another 3 + 4 + 32 bytes: too large. - base::StringPiece header_value("abcd"); - header_coalescer_.OnHeader("bar", header_value); + header_coalescer_.OnHeader("bar", "abcd"); EXPECT_TRUE(header_coalescer_.error_seen()); ExpectEntry("bar", "abcd", "Header list too large."); } @@ -93,12 +92,12 @@ TEST_F(HeaderCoalescerTest, Append) { spdy::SpdyHeaderBlock header_block = header_coalescer_.release_headers(); EXPECT_THAT(header_block, - ElementsAre(Pair("foo", base::StringPiece("bar\0quux", 8)), + ElementsAre(Pair("foo", absl::string_view("bar\0quux", 8)), Pair("cookie", "baz; qux"))); } TEST_F(HeaderCoalescerTest, HeaderNameNotValid) { - base::StringPiece header_name("\x1\x7F\x80\xFF"); + absl::string_view header_name("\x1\x7F\x80\xFF"); header_coalescer_.OnHeader(header_name, "foo"); EXPECT_TRUE(header_coalescer_.error_seen()); ExpectEntry("%ESCAPED:\xE2\x80\x8B \x1\x7F%80%FF", "foo", @@ -107,7 +106,7 @@ TEST_F(HeaderCoalescerTest, HeaderNameNotValid) { // RFC 7540 Section 8.1.2.6. Uppercase in header name is invalid. TEST_F(HeaderCoalescerTest, HeaderNameHasUppercase) { - base::StringPiece header_name("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + absl::string_view header_name("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); header_coalescer_.OnHeader(header_name, "foo"); EXPECT_TRUE(header_coalescer_.error_seen()); ExpectEntry("ABCDEFGHIJKLMNOPQRSTUVWXYZ", "foo", @@ -121,7 +120,7 @@ TEST_F(HeaderCoalescerTest, HeaderNameHasUppercase) { // "^" / "_" / "`" / "|" / "~" / DIGIT / ALPHA TEST_F(HeaderCoalescerTest, HeaderNameValid) { // Due to RFC 7540 Section 8.1.2.6. Uppercase characters are not included. - base::StringPiece header_name( + absl::string_view header_name( "abcdefghijklmnopqrstuvwxyz0123456789!#$%&'*+-." "^_`|~"); header_coalescer_.OnHeader(header_name, "foo"); diff --git a/chromium/net/spdy/multiplexed_http_stream.cc b/chromium/net/spdy/multiplexed_http_stream.cc index 9d89e6e59de..ac902b0ffb3 100644 --- a/chromium/net/spdy/multiplexed_http_stream.cc +++ b/chromium/net/spdy/multiplexed_http_stream.cc @@ -7,6 +7,7 @@ #include <utility> #include "base/notreached.h" +#include "base/strings/abseil_string_conversions.h" #include "net/http/http_raw_request_headers.h" #include "net/third_party/quiche/src/spdy/core/spdy_header_block.h" @@ -65,7 +66,8 @@ void MultiplexedHttpStream::DispatchRequestHeadersCallback( return; HttpRawRequestHeaders raw_headers; for (const auto& entry : spdy_headers) - raw_headers.Add(entry.first, entry.second); + raw_headers.Add(base::StringViewToStringPiece(entry.first), + base::StringViewToStringPiece(entry.second)); request_headers_callback_.Run(std::move(raw_headers)); } diff --git a/chromium/net/spdy/platform/impl/spdy_string_utils_impl.h b/chromium/net/spdy/platform/impl/spdy_string_utils_impl.h index d5afc9065ba..534b169d5b8 100644 --- a/chromium/net/spdy/platform/impl/spdy_string_utils_impl.h +++ b/chromium/net/spdy/platform/impl/spdy_string_utils_impl.h @@ -13,6 +13,7 @@ #include "base/strings/stringprintf.h" #include "net/base/hex_utils.h" #include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" namespace spdy { @@ -34,10 +35,7 @@ inline char SpdyHexDigitToIntImpl(char c) { } inline std::string SpdyHexDecodeImpl(quiche::QuicheStringPiece data) { - std::string result; - if (!base::HexStringToString(data, &result)) - result.clear(); - return result; + return quiche::QuicheTextUtils::HexDecode(data); } NET_EXPORT_PRIVATE bool SpdyHexDecodeToUInt32Impl( @@ -45,7 +43,7 @@ NET_EXPORT_PRIVATE bool SpdyHexDecodeToUInt32Impl( uint32_t* out); inline std::string SpdyHexEncodeImpl(const char* bytes, size_t size) { - return base::ToLowerASCII(base::HexEncode(bytes, size)); + return quiche::QuicheTextUtils::HexEncode(bytes, size); } inline std::string SpdyHexEncodeUInt32AndTrimImpl(uint32_t data) { @@ -53,13 +51,13 @@ inline std::string SpdyHexEncodeUInt32AndTrimImpl(uint32_t data) { } inline std::string SpdyHexDumpImpl(quiche::QuicheStringPiece data) { - return net::HexDump(data); + return quiche::QuicheTextUtils::HexDump(data); } struct SpdyStringPieceCaseHashImpl { size_t operator()(quiche::QuicheStringPiece data) const { - std::string lower = ToLowerASCII(data); - base::StringPieceHash hasher; + std::string lower = absl::AsciiStrToLower(data); + absl::Hash<absl::string_view> hasher; return hasher(lower); } }; @@ -67,7 +65,7 @@ struct SpdyStringPieceCaseHashImpl { struct SpdyStringPieceCaseEqImpl { bool operator()(quiche::QuicheStringPiece piece1, quiche::QuicheStringPiece piece2) const { - return base::EqualsCaseInsensitiveASCII(piece1, piece2); + return absl::EqualsIgnoreCase(piece1, piece2); } }; diff --git a/chromium/net/spdy/spdy_http_utils.cc b/chromium/net/spdy/spdy_http_utils.cc index 5ad2d4acf6f..c74decbaa36 100644 --- a/chromium/net/spdy/spdy_http_utils.cc +++ b/chromium/net/spdy/spdy_http_utils.cc @@ -47,11 +47,18 @@ bool SpdyHeadersToHttpResponse(const spdy::SpdyHeaderBlock& headers, headers.find(spdy::kHttp2StatusHeader); if (it == headers.end()) return false; - std::string status = it->second.as_string(); + auto status = std::string(it->second); std::string raw_headers("HTTP/1.1 "); raw_headers.append(status); raw_headers.push_back('\0'); for (it = headers.begin(); it != headers.end(); ++it) { + auto name = std::string(it->first); + DCHECK_GT(name.size(), 0u); + if (name[0] == ':') { + // https://tools.ietf.org/html/rfc7540#section-8.1.2.4 + // Skip pseudo headers. + continue; + } // For each value, if the server sends a NUL-separated // list of values, we separate that back out into // individual headers for each value in the list. @@ -60,21 +67,19 @@ bool SpdyHeadersToHttpResponse(const spdy::SpdyHeaderBlock& headers, // becomes // Set-Cookie: foo\0 // Set-Cookie: bar\0 - std::string value = it->second.as_string(); + auto value = std::string(it->second); size_t start = 0; size_t end = 0; do { + raw_headers.append(name); + raw_headers.push_back(':'); + end = value.find('\0', start); std::string tval; if (end != value.npos) tval = value.substr(start, (end - start)); else tval = value.substr(start); - if (it->first[0] == ':') - raw_headers.append(it->first.as_string().substr(1)); - else - raw_headers.append(it->first.as_string()); - raw_headers.push_back(':'); raw_headers.append(tval); raw_headers.push_back('\0'); start = end + 1; @@ -157,12 +162,13 @@ NET_EXPORT_PRIVATE void ConvertHeaderBlockToHttpRequestHeaders( const spdy::SpdyHeaderBlock& spdy_headers, HttpRequestHeaders* http_headers) { for (const auto& it : spdy_headers) { - base::StringPiece key = it.first; + base::StringPiece key = base::StringViewToStringPiece(it.first); if (key[0] == ':') { key.remove_prefix(1); } - std::vector<base::StringPiece> values = base::SplitStringPiece( - it.second, "\0", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); + std::vector<base::StringPiece> values = + base::SplitStringPiece(base::StringViewToStringPiece(it.second), "\0", + base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); for (const auto& value : values) { http_headers->SetHeader(key, value); } diff --git a/chromium/net/spdy/spdy_log_util.cc b/chromium/net/spdy/spdy_log_util.cc index 833d0f469ad..d0d55c1cf58 100644 --- a/chromium/net/spdy/spdy_log_util.cc +++ b/chromium/net/spdy/spdy_log_util.cc @@ -6,6 +6,7 @@ #include <utility> +#include "base/strings/abseil_string_conversions.h" #include "base/strings/strcat.h" #include "base/strings/string_number_conversions.h" #include "base/values.h" @@ -28,8 +29,8 @@ base::ListValue ElideSpdyHeaderBlockForNetLog( NetLogCaptureMode capture_mode) { base::ListValue headers_list; for (const auto& header : headers) { - base::StringPiece key = header.first; - base::StringPiece value = header.second; + base::StringPiece key = base::StringViewToStringPiece(header.first); + base::StringPiece value = base::StringViewToStringPiece(header.second); headers_list.Append(NetLogStringValue( base::StrCat({key, ": ", ElideHeaderValueForNetLog(capture_mode, key.as_string(), diff --git a/chromium/net/spdy/spdy_network_transaction_unittest.cc b/chromium/net/spdy/spdy_network_transaction_unittest.cc index d0dd6d8299e..4136de0e6b4 100644 --- a/chromium/net/spdy/spdy_network_transaction_unittest.cc +++ b/chromium/net/spdy/spdy_network_transaction_unittest.cc @@ -4323,12 +4323,12 @@ TEST_F(SpdyNetworkTransactionTest, ResponseHeaders) { base::StringPiece expected_headers[8]; } test_cases[] = { // No extra headers. - {0, {}, 2, {"status", "200", "hello", "bye"}}, + {0, {}, 1, {"hello", "bye"}}, // Comma-separated header value. {1, {"cookie", "val1, val2"}, - 3, - {"status", "200", "hello", "bye", "cookie", "val1, val2"}}, + 2, + {"hello", "bye", "cookie", "val1, val2"}}, // Multiple headers are preserved: they are joined with \0 separator in // spdy::SpdyHeaderBlock.AppendValueOrAddHeader(), then split up in // HpackEncoder, then joined with \0 separator when @@ -4337,16 +4337,17 @@ TEST_F(SpdyNetworkTransactionTest, ResponseHeaders) { // HttpResponseHeaders. {2, {"content-encoding", "val1", "content-encoding", "val2"}, - 4, - {"status", "200", "hello", "bye", "content-encoding", "val1", - "content-encoding", "val2"}}, + 3, + {"hello", "bye", "content-encoding", "val1", "content-encoding", + "val2"}}, // Cookie header is not split up by HttpResponseHeaders. {2, {"cookie", "val1", "cookie", "val2"}, - 3, - {"status", "200", "hello", "bye", "cookie", "val1; val2"}}}; + 2, + {"hello", "bye", "cookie", "val1; val2"}}}; for (size_t i = 0; i < base::size(test_cases); ++i) { + SCOPED_TRACE(i); SpdyTestUtil spdy_test_util; spdy::SpdySerializedFrame req( spdy_test_util.ConstructSpdyGet(nullptr, 0, 1, LOWEST)); @@ -4372,140 +4373,20 @@ TEST_F(SpdyNetworkTransactionTest, ResponseHeaders) { EXPECT_EQ("hello!", out.response_data); scoped_refptr<HttpResponseHeaders> headers = out.response_info.headers; - EXPECT_TRUE(headers); + ASSERT_TRUE(headers); + EXPECT_EQ("HTTP/1.1 200", headers->GetStatusLine()); size_t iter = 0; std::string name, value; size_t expected_header_index = 0; while (headers->EnumerateHeaderLines(&iter, &name, &value)) { - ASSERT_LT(expected_header_index, test_cases[i].expected_header_count) - << i; - EXPECT_EQ(name, test_cases[i].expected_headers[2 * expected_header_index]) - << i; + ASSERT_LT(expected_header_index, test_cases[i].expected_header_count); + EXPECT_EQ(name, + test_cases[i].expected_headers[2 * expected_header_index]); EXPECT_EQ(value, - test_cases[i].expected_headers[2 * expected_header_index + 1]) - << i; + test_cases[i].expected_headers[2 * expected_header_index + 1]); ++expected_header_index; } - EXPECT_EQ(expected_header_index, test_cases[i].expected_header_count) << i; - } -} - -// Verify that various response headers parse vary fields correctly through the -// HTTP layer, and the response matches the request. -TEST_F(SpdyNetworkTransactionTest, ResponseHeadersVary) { - // Modify the following data to change/add test cases: - struct ResponseTests { - bool vary_matches; - int num_headers[2]; - const char* extra_headers[2][16]; - } test_cases[] = { - // Test the case of a multi-valued cookie. When the value is delimited - // with NUL characters, it needs to be unfolded into multiple headers. - {true, - {1, 3}, - {{"cookie", "val1,val2", nullptr}, - {spdy::kHttp2StatusHeader, "200", spdy::kHttp2PathHeader, "/index.php", - "vary", "cookie", nullptr}}}, - {// Multiple vary fields. - true, - {2, 4}, - {{"friend", "barney", "enemy", "snaggletooth", nullptr}, - {spdy::kHttp2StatusHeader, "200", spdy::kHttp2PathHeader, "/index.php", - "vary", "friend", "vary", "enemy", nullptr}}}, - {// Test a '*' vary field. - true, - {1, 3}, - {{"cookie", "val1,val2", nullptr}, - {spdy::kHttp2StatusHeader, "200", spdy::kHttp2PathHeader, "/index.php", - "vary", "*", nullptr}}}, - {// Test w/o a vary field. - false, - {1, 2}, - {{"cookie", "val1,val2", nullptr}, - {spdy::kHttp2StatusHeader, "200", spdy::kHttp2PathHeader, "/index.php", - nullptr}}}, - - {// Multiple comma-separated vary fields. - true, - {2, 3}, - {{"friend", "barney", "enemy", "snaggletooth", nullptr}, - {spdy::kHttp2StatusHeader, "200", spdy::kHttp2PathHeader, "/index.php", - "vary", "friend,enemy", nullptr}}}}; - - for (size_t i = 0; i < base::size(test_cases); ++i) { - SpdyTestUtil spdy_test_util; - - // Construct the request. - spdy::SpdySerializedFrame frame_req(spdy_test_util.ConstructSpdyGet( - test_cases[i].extra_headers[0], test_cases[i].num_headers[0], 1, - LOWEST)); - - MockWrite writes[] = { - CreateMockWrite(frame_req, 0), - }; - - // Construct the reply. - spdy::SpdyHeaderBlock reply_headers; - AppendToHeaderBlock(test_cases[i].extra_headers[1], - test_cases[i].num_headers[1], - &reply_headers); - // Construct the expected header reply string before moving |reply_headers|. - std::string expected_reply = - spdy_test_util.ConstructSpdyReplyString(reply_headers); - - spdy::SpdySerializedFrame frame_reply( - spdy_test_util.ConstructSpdyReply(1, std::move(reply_headers))); - - spdy::SpdySerializedFrame body( - spdy_test_util.ConstructSpdyDataFrame(1, true)); - MockRead reads[] = { - CreateMockRead(frame_reply, 1), CreateMockRead(body, 2), - MockRead(ASYNC, 0, 3) // EOF - }; - - // Attach the headers to the request. - int header_count = test_cases[i].num_headers[0]; - - HttpRequestInfo request; - request.method = "GET"; - request.url = GURL(kDefaultUrl); - request.traffic_annotation = - net::MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS); - for (int ct = 0; ct < header_count; ct++) { - const char* header_key = test_cases[i].extra_headers[0][ct * 2]; - const char* header_value = test_cases[i].extra_headers[0][ct * 2 + 1]; - request.extra_headers.SetHeader(header_key, header_value); - } - - SequencedSocketData data(reads, writes); - - NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, log_, - nullptr); - - helper.RunToCompletion(&data); - TransactionHelperResult out = helper.output(); - - EXPECT_EQ(OK, out.rv) << i; - EXPECT_EQ("HTTP/1.1 200", out.status_line) << i; - EXPECT_EQ("hello!", out.response_data) << i; - - // Test the response information. - EXPECT_EQ(out.response_info.vary_data.is_valid(), - test_cases[i].vary_matches) << i; - - // Check the headers. - scoped_refptr<HttpResponseHeaders> headers = out.response_info.headers; - ASSERT_TRUE(headers) << i; - size_t iter = 0; - std::string name, value, lines; - while (headers->EnumerateHeaderLines(&iter, &name, &value)) { - lines.append(name); - lines.append(": "); - lines.append(value); - lines.append("\n"); - } - - EXPECT_EQ(expected_reply, lines) << i; + EXPECT_EQ(expected_header_index, test_cases[i].expected_header_count); } } @@ -4514,24 +4395,13 @@ TEST_F(SpdyNetworkTransactionTest, InvalidResponseHeaders) { struct InvalidResponseHeadersTests { int num_headers; const char* headers[10]; - } test_cases[] = { - // Response headers missing status header - { - 3, - {spdy::kHttp2PathHeader, "/index.php", "cookie", "val1", "cookie", - "val2", nullptr}, - }, - // Response headers missing version header - { - 1, {spdy::kHttp2PathHeader, "/index.php", "status", "200", nullptr}, - }, - // Response headers with no headers - { - 0, {nullptr}, - }, - }; + } test_cases[] = {// Response headers missing status header + {2, {"cookie", "val1", "cookie", "val2", nullptr}}, + // Response headers with no headers + {0, {nullptr}}}; for (size_t i = 0; i < base::size(test_cases); ++i) { + SCOPED_TRACE(i); SpdyTestUtil spdy_test_util; spdy::SpdySerializedFrame req( @@ -6123,13 +5993,11 @@ TEST_F(SpdyNetworkTransactionTest, SpdyBasicAuth) { } struct PushHeaderTestParams { - std::vector<std::pair<base::StringPiece, base::StringPiece>> - extra_request_headers; - std::vector<std::pair<base::StringPiece, base::StringPiece>> - extra_pushed_request_headers; - std::vector<std::pair<base::StringPiece, base::StringPiece>> + std::vector<std::pair<std::string, std::string>> extra_request_headers; + std::vector<std::pair<std::string, std::string>> extra_pushed_request_headers; + std::vector<std::pair<std::string, std::string>> extra_pushed_response_headers; - base::StringPiece pushed_status_code; + std::string pushed_status_code; bool push_accepted; SpdyPushedStreamFate expected_fate; } push_header_test_cases[] = { diff --git a/chromium/net/spdy/spdy_session.cc b/chromium/net/spdy/spdy_session.cc index f7b2b6e69bc..c197413eb88 100644 --- a/chromium/net/spdy/spdy_session.cc +++ b/chromium/net/spdy/spdy_session.cc @@ -17,6 +17,7 @@ #include "base/metrics/histogram_macros.h" #include "base/single_thread_task_runner.h" #include "base/stl_util.h" +#include "base/strings/abseil_string_conversions.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_split.h" #include "base/strings/string_util.h" @@ -132,7 +133,7 @@ enum PushedStreamVaryResponseHeaderValues ParseVaryInPushedResponse( spdy::SpdyHeaderBlock::iterator it = headers.find(kVary); if (it == headers.end()) return kNoVaryHeader; - base::StringPiece value(it->second); + base::StringPiece value = base::StringViewToStringPiece(it->second); if (value.empty()) return kVaryIsEmpty; if (value == kStar) @@ -2621,6 +2622,9 @@ void SpdySession::SendInitialData() { void SpdySession::HandleSetting(uint32_t id, uint32_t value) { switch (id) { + case spdy::SETTINGS_HEADER_TABLE_SIZE: + buffered_spdy_framer_->UpdateHeaderEncoderTableSize(value); + break; case spdy::SETTINGS_MAX_CONCURRENT_STREAMS: max_concurrent_streams_ = std::min(static_cast<size_t>(value), kMaxConcurrentStreamLimit); diff --git a/chromium/net/spdy/spdy_session_unittest.cc b/chromium/net/spdy/spdy_session_unittest.cc index 3b8a20b31aa..997d6c50e11 100644 --- a/chromium/net/spdy/spdy_session_unittest.cc +++ b/chromium/net/spdy/spdy_session_unittest.cc @@ -364,6 +364,10 @@ class SpdySessionTest : public PlatformTest, public WithTaskEnvironment { url, session_.get()) != kNoPushedStreamFound; } + uint32_t header_encoder_table_size() const { + return session_->buffered_spdy_framer_->header_encoder_table_size(); + } + RecordingBoundTestNetLog log_; // Original socket limits. Some tests set these. Safest to always restore @@ -7210,4 +7214,35 @@ TEST(RecordPushedStreamHistogramTest, VaryResponseHeader) { } } +// Regression test for https://crbug.com/1115492. +TEST_F(SpdySessionTest, UpdateHeaderTableSize) { + spdy::SettingsMap settings; + settings[spdy::SETTINGS_HEADER_TABLE_SIZE] = 12345; + spdy::SpdySerializedFrame settings_frame( + spdy_util_.ConstructSpdySettings(settings)); + MockRead reads[] = {CreateMockRead(settings_frame, 0), + MockRead(ASYNC, ERR_IO_PENDING, 2), + MockRead(ASYNC, 0, 3)}; + + spdy::SpdySerializedFrame settings_ack(spdy_util_.ConstructSpdySettingsAck()); + MockWrite writes[] = {CreateMockWrite(settings_ack, 1)}; + + SequencedSocketData data(reads, writes); + session_deps_.socket_factory->AddSocketDataProvider(&data); + + AddSSLSocketData(); + + CreateNetworkSession(); + CreateSpdySession(); + + EXPECT_EQ(spdy::kDefaultHeaderTableSizeSetting, header_encoder_table_size()); + base::RunLoop().RunUntilIdle(); + EXPECT_EQ(12345u, header_encoder_table_size()); + + data.Resume(); + base::RunLoop().RunUntilIdle(); + EXPECT_TRUE(data.AllWriteDataConsumed()); + EXPECT_TRUE(data.AllReadDataConsumed()); +} + } // namespace net diff --git a/chromium/net/spdy/spdy_stream.cc b/chromium/net/spdy/spdy_stream.cc index 0d7f2140981..1d92a0b0821 100644 --- a/chromium/net/spdy/spdy_stream.cc +++ b/chromium/net/spdy/spdy_stream.cc @@ -16,6 +16,7 @@ #include "base/metrics/histogram_macros.h" #include "base/notreached.h" #include "base/single_thread_task_runner.h" +#include "base/strings/abseil_string_conversions.h" #include "base/strings/string_number_conversions.h" #include "base/strings/stringprintf.h" #include "base/threading/thread_task_runner_handle.h" @@ -401,7 +402,8 @@ void SpdyStream::OnHeadersReceived( } int status; - if (!StringToInt(it->second, &status)) { + if (!base::StringToInt(base::StringViewToStringPiece(it->second), + &status)) { const std::string error("Cannot parse :status."); LogStreamError(ERR_HTTP2_PROTOCOL_ERROR, error); session_->ResetStream(stream_id_, ERR_HTTP2_PROTOCOL_ERROR, error); diff --git a/chromium/net/spdy/spdy_stream_test_util.cc b/chromium/net/spdy/spdy_stream_test_util.cc index b8309626edb..ac023567031 100644 --- a/chromium/net/spdy/spdy_stream_test_util.cc +++ b/chromium/net/spdy/spdy_stream_test_util.cc @@ -116,7 +116,7 @@ std::string StreamDelegateBase::GetResponseHeaderValue( const std::string& name) const { spdy::SpdyHeaderBlock::const_iterator it = response_headers_.find(name); return (it == response_headers_.end()) ? std::string() - : it->second.as_string(); + : std::string(it->second); } const LoadTimingInfo& StreamDelegateBase::GetLoadTimingInfo() { diff --git a/chromium/net/spdy/spdy_test_util_common.cc b/chromium/net/spdy/spdy_test_util_common.cc index 253a23f43c6..07395292f90 100644 --- a/chromium/net/spdy/spdy_test_util_common.cc +++ b/chromium/net/spdy/spdy_test_util_common.cc @@ -42,7 +42,7 @@ #include "net/third_party/quiche/src/spdy/core/spdy_alt_svc_wire_format.h" #include "net/third_party/quiche/src/spdy/core/spdy_framer.h" #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" -#include "net/url_request/url_request_job_factory_impl.h" +#include "net/url_request/url_request_job_factory.h" #include "testing/gmock/include/gmock/gmock.h" using net::test::IsError; @@ -106,8 +106,8 @@ void AppendToHeaderBlock(const char* const extra_headers[], // Copy in the headers. for (int i = 0; i < extra_header_count; i++) { - base::StringPiece key(extra_headers[i * 2]); - base::StringPiece value(extra_headers[i * 2 + 1]); + absl::string_view key(extra_headers[i * 2]); + absl::string_view value(extra_headers[i * 2 + 1]); DCHECK(!key.empty()) << "Header key must not be empty."; headers->AppendValueOrAddHeader(key, value); } @@ -455,7 +455,7 @@ SpdyURLRequestContext::SpdyURLRequestContext() : storage_(this) { HttpAuthHandlerFactory::CreateDefault()); storage_.set_http_server_properties(std::make_unique<HttpServerProperties>()); storage_.set_quic_context(std::make_unique<QuicContext>()); - storage_.set_job_factory(std::make_unique<URLRequestJobFactoryImpl>()); + storage_.set_job_factory(std::make_unique<URLRequestJobFactory>()); HttpNetworkSession::Params session_params; session_params.enable_spdy_ping_based_connection_checking = false; @@ -718,13 +718,14 @@ std::string SpdyTestUtil::ConstructSpdyReplyString( std::string reply_string; for (spdy::SpdyHeaderBlock::const_iterator it = headers.begin(); it != headers.end(); ++it) { - std::string key = it->first.as_string(); + auto key = std::string(it->first); // Remove leading colon from pseudo headers. if (key[0] == ':') key = key.substr(1); for (const std::string& value : - base::SplitString(it->second, base::StringPiece("\0", 1), - base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) { + base::SplitString(base::StringViewToStringPiece(it->second), + base::StringPiece("\0", 1), base::TRIM_WHITESPACE, + base::SPLIT_WANT_ALL)) { reply_string += key + ": " + value + "\n"; } } @@ -1032,7 +1033,7 @@ spdy::SpdySerializedFrame SpdyTestUtil::ConstructSpdyDataFrame( int stream_id, base::StringPiece data, bool fin) { - spdy::SpdyDataIR data_ir(stream_id, data); + spdy::SpdyDataIR data_ir(stream_id, base::StringPieceToStringView(data)); data_ir.set_fin(fin); return spdy::SpdySerializedFrame( headerless_spdy_framer_.SerializeData(data_ir)); @@ -1043,7 +1044,7 @@ spdy::SpdySerializedFrame SpdyTestUtil::ConstructSpdyDataFrame( base::StringPiece data, bool fin, int padding_length) { - spdy::SpdyDataIR data_ir(stream_id, data); + spdy::SpdyDataIR data_ir(stream_id, base::StringPieceToStringView(data)); data_ir.set_fin(fin); data_ir.set_padding_len(padding_length); return spdy::SpdySerializedFrame( |