#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include <cmath>
#include <string_view>
#include <utility>
#include <vector>
#include "base/containers/span.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/numerics/safe_conversions.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/test_file_util.h"
#include "build/build_config.h"
#include "net/base/auth.h"
#include "net/base/chunked_upload_data_stream.h"
#include "net/base/completion_once_callback.h"
#include "net/base/elements_upload_data_stream.h"
#include "net/base/features.h"
#include "net/base/hex_utils.h"
#include "net/base/ip_endpoint.h"
#include "net/base/network_anonymization_key.h"
#include "net/base/proxy_delegate.h"
#include "net/base/proxy_server.h"
#include "net/base/proxy_string_util.h"
#include "net/base/request_priority.h"
#include "net/base/schemeful_site.h"
#include "net/base/session_usage.h"
#include "net/base/test_proxy_delegate.h"
#include "net/base/upload_bytes_element_reader.h"
#include "net/base/upload_file_element_reader.h"
#include "net/dns/mock_host_resolver.h"
#include "net/dns/public/secure_dns_policy.h"
#include "net/http/http_auth_scheme.h"
#include "net/http/http_connection_info.h"
#include "net/http/http_network_session.h"
#include "net/http/http_network_session_peer.h"
#include "net/http/http_network_transaction.h"
#include "net/http/http_proxy_connect_job.h"
#include "net/http/http_response_info.h"
#include "net/http/http_server_properties.h"
#include "net/http/http_transaction_test_util.h"
#include "net/http/test_upload_data_stream_not_allow_http1.h"
#include "net/http/transport_security_state.h"
#include "net/log/net_log_event_type.h"
#include "net/log/net_log_with_source.h"
#include "net/log/test_net_log.h"
#include "net/log/test_net_log_util.h"
#include "net/proxy_resolution/configured_proxy_resolution_service.h"
#include "net/socket/next_proto.h"
#include "net/socket/socket_tag.h"
#include "net/spdy/alps_decoder.h"
#include "net/spdy/buffered_spdy_framer.h"
#include "net/spdy/spdy_http_stream.h"
#include "net/spdy/spdy_http_utils.h"
#include "net/spdy/spdy_session.h"
#include "net/spdy/spdy_session_pool.h"
#include "net/spdy/spdy_test_util_common.h"
#include "net/ssl/ssl_connection_status_flags.h"
#include "net/test/cert_test_util.h"
#include "net/test/gtest_util.h"
#include "net/test/test_data_directory.h"
#include "net/test/test_with_task_environment.h"
#include "net/third_party/quiche/src/quiche/common/http/http_header_block.h"
#include "net/third_party/quiche/src/quiche/http2/test_tools/spdy_test_utils.h"
#include "net/third_party/quiche/src/quiche/spdy/core/spdy_protocol.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_builder.h"
#include "net/url_request/url_request_test_util.h"
#include "net/websockets/websocket_test_util.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/platform_test.h"
#include "url/gurl.h"
#include "url/url_constants.h"
IsError;
IsOk;
namespace net {
namespace {
Each;
Eq;
const int32_t kBufferSize = …;
}
const char kPushedUrl[] = …;
class SpdyNetworkTransactionTest : public TestWithTaskEnvironment,
public ::testing::WithParamInterface<bool> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(SpdyNetworkTransactionTest, Constructor) { … }
TEST_P(SpdyNetworkTransactionTest, Get) { … }
TEST_P(SpdyNetworkTransactionTest, SetPriority) { … }
TEST_P(SpdyNetworkTransactionTest, SetPriorityOnExistingStream) { … }
TEST_P(SpdyNetworkTransactionTest, RequestsOrderedByPriority) { … }
TEST_P(SpdyNetworkTransactionTest, QueuedFramesReorderedOnPriorityChange) { … }
TEST_P(SpdyNetworkTransactionTest, GetAtEachPriority) { … }
TEST_P(SpdyNetworkTransactionTest, ThreeGets) { … }
TEST_P(SpdyNetworkTransactionTest, TwoGetsLateBinding) { … }
TEST_P(SpdyNetworkTransactionTest, TwoGetsLateBindingFromPreconnect) { … }
TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrent) { … }
TEST_P(SpdyNetworkTransactionTest, FourGetsWithMaxConcurrentPriority) { … }
TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrentDelete) { … }
namespace {
class KillerCallback : public TestCompletionCallbackBase { … };
}
TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrentSocketClose) { … }
TEST_P(SpdyNetworkTransactionTest, Put) { … }
TEST_P(SpdyNetworkTransactionTest, Head) { … }
TEST_P(SpdyNetworkTransactionTest, Post) { … }
TEST_P(SpdyNetworkTransactionTest, FilePost) { … }
TEST_P(SpdyNetworkTransactionTest, UnreadableFilePost) { … }
TEST_P(SpdyNetworkTransactionTest, ComplexPost) { … }
TEST_P(SpdyNetworkTransactionTest, ChunkedPost) { … }
TEST_P(SpdyNetworkTransactionTest, DelayedChunkedPost) { … }
TEST_P(SpdyNetworkTransactionTest, NullPost) { … }
TEST_P(SpdyNetworkTransactionTest, EmptyPost) { … }
TEST_P(SpdyNetworkTransactionTest, ResponseBeforePostCompletes) { … }
TEST_P(SpdyNetworkTransactionTest, SocketWriteReturnsZero) { … }
TEST_P(SpdyNetworkTransactionTest, ResponseWithoutHeaders) { … }
TEST_P(SpdyNetworkTransactionTest, ResponseWithTwoSynReplies) { … }
TEST_P(SpdyNetworkTransactionTest, ResetReplyWithTransferEncoding) { … }
TEST_P(SpdyNetworkTransactionTest, CancelledTransaction) { … }
TEST_P(SpdyNetworkTransactionTest, CancelledTransactionSendRst) { … }
TEST_P(SpdyNetworkTransactionTest, StartTransactionOnReadCallback) { … }
TEST_P(SpdyNetworkTransactionTest, DeleteSessionOnReadCallback) { … }
TEST_P(SpdyNetworkTransactionTest, RedirectGetRequest) { … }
TEST_P(SpdyNetworkTransactionTest, RedirectMultipleLocations) { … }
TEST_P(SpdyNetworkTransactionTest, NoConnectionPoolingOverTunnel) { … }
TEST_P(SpdyNetworkTransactionTest, ConnectionPoolingSessionClosedBeforeUse) { … }
TEST_P(SpdyNetworkTransactionTest,
ConnectionPoolingDisableCertVerificationNetworkFetches) { … }
#if BUILDFLAG(IS_ANDROID)
TEST_P(SpdyNetworkTransactionTest, ConnectionPoolingMultipleSocketTags) {
const SocketTag kSocketTag1(SocketTag::UNSET_UID, 1);
const SocketTag kSocketTag2(SocketTag::UNSET_UID, 2);
const SocketTag kSocketTag3(SocketTag::UNSET_UID, 3);
NormalSpdyTransactionHelper helper(request_, DEFAULT_PRIORITY, log_, nullptr);
spdy::SpdySerializedFrame req1(
spdy_util_.ConstructSpdyGet("https://www.example.org", 1, LOWEST));
spdy_util_.UpdateWithStreamDestruction(1);
spdy::SpdySerializedFrame req3(
spdy_util_.ConstructSpdyGet("https://example.test/request3", 3, LOWEST));
MockWrite writes1[] = {
CreateMockWrite(req1, 0),
CreateMockWrite(req3, 3),
};
spdy::SpdySerializedFrame resp1(
spdy_util_.ConstructSpdyGetReply(nullptr, 0, 1));
spdy::SpdySerializedFrame body1(spdy_util_.ConstructSpdyDataFrame(1, true));
spdy::SpdySerializedFrame resp3(
spdy_util_.ConstructSpdyGetReply(nullptr, 0, 3));
spdy::SpdySerializedFrame body3(spdy_util_.ConstructSpdyDataFrame(3, true));
MockRead reads1[] = {CreateMockRead(resp1, 1), CreateMockRead(body1, 2),
CreateMockRead(resp3, 4), CreateMockRead(body3, 5),
MockRead(SYNCHRONOUS, ERR_IO_PENDING, 6)};
SequencedSocketData data1(MockConnect(ASYNC, OK), reads1, writes1);
helper.AddData(&data1);
SequencedSocketData data2(MockConnect(SYNCHRONOUS, ERR_IO_PENDING),
base::span<const MockRead>(),
base::span<const MockWrite>());
helper.AddData(&data2);
SpdyTestUtil spdy_util2(true);
spdy::SpdySerializedFrame req2(
spdy_util2.ConstructSpdyGet("https://example.test/request2", 1, LOWEST));
MockWrite writes2[] = {
CreateMockWrite(req2, 0),
};
spdy::SpdySerializedFrame resp2(
spdy_util2.ConstructSpdyGetReply(nullptr, 0, 1));
spdy::SpdySerializedFrame body2(spdy_util2.ConstructSpdyDataFrame(1, true));
MockRead reads2[] = {CreateMockRead(resp2, 1), CreateMockRead(body2, 2),
MockRead(SYNCHRONOUS, ERR_IO_PENDING, 3)};
SequencedSocketData data3(MockConnect(ASYNC, OK), reads2, writes2);
helper.AddData(&data3);
helper.RunPreTestSetup();
helper.RunDefaultTest();
TransactionHelperResult out = helper.output();
EXPECT_THAT(out.rv, IsOk());
EXPECT_EQ("HTTP/1.1 200", out.status_line);
EXPECT_EQ("hello!", out.response_data);
SpdySessionKey key1(HostPortPair("www.example.org", 443),
PRIVACY_MODE_DISABLED, ProxyChain::Direct(),
SessionUsage::kDestination, SocketTag(),
NetworkAnonymizationKey(), SecureDnsPolicy::kAllow,
false);
EXPECT_TRUE(helper.session()->spdy_session_pool()->FindAvailableSession(
key1, true , false ,
NetLogWithSource()));
helper.session_deps()->host_resolver->set_ondemand_mode(true);
HttpRequestInfo request2;
request2.socket_tag = kSocketTag2;
request2.method = "GET";
request2.url = GURL("https://example.test/request2");
request2.load_flags = 0;
request2.traffic_annotation =
net::MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
auto trans2 = std::make_unique<HttpNetworkTransaction>(DEFAULT_PRIORITY,
helper.session());
TestCompletionCallback callback2;
EXPECT_THAT(
trans2->Start(&request2, callback2.callback(), NetLogWithSource()),
IsError(ERR_IO_PENDING));
HttpRequestInfo request3;
request3.socket_tag = kSocketTag3;
request3.method = "GET";
request3.url = GURL("https://example.test/request3");
request3.load_flags = 0;
request3.traffic_annotation =
net::MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
auto trans3 = std::make_unique<HttpNetworkTransaction>(DEFAULT_PRIORITY,
helper.session());
TestCompletionCallback callback3;
EXPECT_THAT(
trans3->Start(&request3, callback3.callback(), NetLogWithSource()),
IsError(ERR_IO_PENDING));
base::RunLoop().RunUntilIdle();
ASSERT_TRUE(helper.session_deps()->host_resolver->has_pending_requests());
helper.session_deps()->host_resolver->ResolveNow(2);
SpdySessionKey key2(HostPortPair("example.test", 443), PRIVACY_MODE_DISABLED,
ProxyChain::Direct(), SessionUsage::kDestination,
kSocketTag2, NetworkAnonymizationKey(),
SecureDnsPolicy::kAllow,
false);
helper.session_deps()->host_resolver->ResolveNow(3);
SpdySessionKey key3(HostPortPair("example.test", 443), PRIVACY_MODE_DISABLED,
ProxyChain::Direct(), SessionUsage::kDestination,
kSocketTag3, NetworkAnonymizationKey(),
SecureDnsPolicy::kAllow,
false);
EXPECT_THAT(callback2.WaitForResult(), IsOk());
const HttpResponseInfo* response = trans2->GetResponseInfo();
ASSERT_TRUE(response);
ASSERT_TRUE(response->headers);
EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine());
EXPECT_TRUE(response->was_fetched_via_spdy);
EXPECT_TRUE(response->was_alpn_negotiated);
std::string response_data;
ASSERT_THAT(ReadTransaction(trans2.get(), &response_data), IsOk());
EXPECT_EQ("hello!", response_data);
EXPECT_THAT(callback3.WaitForResult(), IsOk());
response = trans3->GetResponseInfo();
ASSERT_TRUE(response);
ASSERT_TRUE(response->headers);
EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine());
EXPECT_TRUE(response->was_fetched_via_spdy);
EXPECT_TRUE(response->was_alpn_negotiated);
ASSERT_THAT(ReadTransaction(trans3.get(), &response_data), IsOk());
EXPECT_EQ("hello!", response_data);
helper.VerifyDataConsumed();
}
TEST_P(SpdyNetworkTransactionTest, SocketTagChangeSessionTagWithDnsAliases) {
SocketTag socket_tag_1(SocketTag::UNSET_UID, 1);
SocketTag socket_tag_2(SocketTag::UNSET_UID, 2);
request_.socket_tag = socket_tag_1;
std::unique_ptr<SpdySessionDependencies> session_deps =
std::make_unique<SpdySessionDependencies>();
std::unique_ptr<MockCachingHostResolver> host_resolver =
std::make_unique<MockCachingHostResolver>(2 );
session_deps->host_resolver = std::move(host_resolver);
NormalSpdyTransactionHelper helper(request_, DEFAULT_PRIORITY, log_,
std::move(session_deps));
GURL url = request_.url;
std::set<std::string> dns_aliases({"alias1", "alias2", "alias3"});
helper.session_deps()->host_resolver->rules()->AddIPLiteralRuleWithDnsAliases(
url.host(), "127.0.0.1", dns_aliases);
spdy::SpdySerializedFrame req1(
spdy_util_.ConstructSpdyGet(url.spec().c_str(), 1, DEFAULT_PRIORITY));
spdy_util_.UpdateWithStreamDestruction(1);
spdy::SpdySerializedFrame req2(
spdy_util_.ConstructSpdyGet(url.spec().c_str(), 3, DEFAULT_PRIORITY));
MockWrite writes[] = {
CreateMockWrite(req1, 0),
CreateMockWrite(req2, 3),
};
spdy::SpdySerializedFrame resp1(
spdy_util_.ConstructSpdyGetReply(nullptr, 0, 1));
spdy::SpdySerializedFrame body1(spdy_util_.ConstructSpdyDataFrame(1, true));
spdy::SpdySerializedFrame resp2(
spdy_util_.ConstructSpdyGetReply(nullptr, 0, 3));
spdy::SpdySerializedFrame body2(spdy_util_.ConstructSpdyDataFrame(3, true));
MockRead reads[] = {CreateMockRead(resp1, 1), CreateMockRead(body1, 2),
CreateMockRead(resp2, 4), CreateMockRead(body2, 5),
MockRead(SYNCHRONOUS, ERR_IO_PENDING, 6)};
SequencedSocketData data(MockConnect(ASYNC, OK), reads, writes);
helper.AddData(&data);
helper.RunPreTestSetup();
helper.RunDefaultTest();
TransactionHelperResult out = helper.output();
EXPECT_THAT(out.rv, IsOk());
EXPECT_EQ("HTTP/1.1 200", out.status_line);
EXPECT_EQ("hello!", out.response_data);
EXPECT_EQ(1u, helper.GetSpdySessionCount());
SpdySessionKey key1(HostPortPair(url.host(), 443), PRIVACY_MODE_DISABLED,
ProxyChain::Direct(), SessionUsage::kDestination,
socket_tag_1, NetworkAnonymizationKey(),
SecureDnsPolicy::kAllow,
false);
EXPECT_TRUE(helper.session()->spdy_session_pool()->FindAvailableSession(
key1, true , false ,
NetLogWithSource()));
EXPECT_EQ(
dns_aliases,
helper.session()->spdy_session_pool()->GetDnsAliasesForSessionKey(key1));
helper.session_deps()->host_resolver->rules()->ClearRules();
HttpRequestInfo request2;
request2.socket_tag = socket_tag_2;
request2.method = "GET";
request2.url = url;
request2.load_flags = 0;
request2.traffic_annotation =
net::MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
SpdySessionKey key2(HostPortPair(url.host(), 443), PRIVACY_MODE_DISABLED,
ProxyChain::Direct(), SessionUsage::kDestination,
socket_tag_2, NetworkAnonymizationKey(),
SecureDnsPolicy::kAllow,
false);
auto trans2 = std::make_unique<HttpNetworkTransaction>(DEFAULT_PRIORITY,
helper.session());
TestCompletionCallback callback2;
EXPECT_THAT(
trans2->Start(&request2, callback2.callback(), NetLogWithSource()),
IsError(ERR_IO_PENDING));
EXPECT_THAT(callback2.WaitForResult(), IsOk());
EXPECT_EQ(1u, helper.GetSpdySessionCount());
EXPECT_FALSE(helper.session()->spdy_session_pool()->FindAvailableSession(
key1, true , false ,
NetLogWithSource()));
EXPECT_TRUE(helper.session()
->spdy_session_pool()
->GetDnsAliasesForSessionKey(key1)
.empty());
EXPECT_TRUE(helper.session()->spdy_session_pool()->FindAvailableSession(
key2, true , false ,
NetLogWithSource()));
EXPECT_EQ(
dns_aliases,
helper.session()->spdy_session_pool()->GetDnsAliasesForSessionKey(key2));
const HttpResponseInfo* response = trans2->GetResponseInfo();
ASSERT_TRUE(response);
ASSERT_TRUE(response->headers);
EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine());
EXPECT_TRUE(response->was_fetched_via_spdy);
EXPECT_TRUE(response->was_alpn_negotiated);
std::string response_data;
ASSERT_THAT(ReadTransaction(trans2.get(), &response_data), IsOk());
EXPECT_EQ("hello!", response_data);
helper.VerifyDataConsumed();
}
TEST_P(SpdyNetworkTransactionTest,
SocketTagChangeFromIPAliasedSessionWithDnsAliases) {
SocketTag socket_tag_1(SocketTag::UNSET_UID, 1);
SocketTag socket_tag_2(SocketTag::UNSET_UID, 2);
request_.socket_tag = socket_tag_1;
std::unique_ptr<SpdySessionDependencies> session_deps =
std::make_unique<SpdySessionDependencies>();
std::unique_ptr<MockCachingHostResolver> host_resolver =
std::make_unique<MockCachingHostResolver>(2 );
session_deps->host_resolver = std::move(host_resolver);
NormalSpdyTransactionHelper helper(request_, DEFAULT_PRIORITY, log_,
std::move(session_deps));
GURL url1 = request_.url;
std::set<std::string> dns_aliases1({"alias1", "alias2", "alias3"});
GURL url2("https://example.test/");
std::set<std::string> dns_aliases2({"example.net", "example.com"});
helper.session_deps()->host_resolver->rules()->AddIPLiteralRuleWithDnsAliases(
url1.host(), "127.0.0.1", dns_aliases1);
helper.session_deps()->host_resolver->rules()->AddIPLiteralRuleWithDnsAliases(
url2.host(), "127.0.0.1", dns_aliases2);
spdy::SpdySerializedFrame req1(
spdy_util_.ConstructSpdyGet(url1.spec().c_str(), 1, DEFAULT_PRIORITY));
spdy_util_.UpdateWithStreamDestruction(1);
spdy::SpdySerializedFrame req2(
spdy_util_.ConstructSpdyGet(url2.spec().c_str(), 3, DEFAULT_PRIORITY));
spdy_util_.UpdateWithStreamDestruction(3);
spdy::SpdySerializedFrame req3(
spdy_util_.ConstructSpdyGet(url2.spec().c_str(), 5, DEFAULT_PRIORITY));
spdy_util_.UpdateWithStreamDestruction(5);
spdy::SpdySerializedFrame req4(
spdy_util_.ConstructSpdyGet(url1.spec().c_str(), 7, DEFAULT_PRIORITY));
MockWrite writes[] = {
CreateMockWrite(req1, 0),
CreateMockWrite(req2, 3),
CreateMockWrite(req3, 6),
CreateMockWrite(req4, 9),
};
spdy::SpdySerializedFrame resp1(
spdy_util_.ConstructSpdyGetReply(nullptr, 0, 1));
spdy::SpdySerializedFrame body1(spdy_util_.ConstructSpdyDataFrame(1, true));
spdy::SpdySerializedFrame resp2(
spdy_util_.ConstructSpdyGetReply(nullptr, 0, 3));
spdy::SpdySerializedFrame body2(spdy_util_.ConstructSpdyDataFrame(3, true));
spdy::SpdySerializedFrame resp3(
spdy_util_.ConstructSpdyGetReply(nullptr, 0, 5));
spdy::SpdySerializedFrame body3(spdy_util_.ConstructSpdyDataFrame(5, true));
spdy::SpdySerializedFrame resp4(
spdy_util_.ConstructSpdyGetReply(nullptr, 0, 7));
spdy::SpdySerializedFrame body4(spdy_util_.ConstructSpdyDataFrame(7, true));
MockRead reads[] = {CreateMockRead(resp1, 1),
CreateMockRead(body1, 2),
CreateMockRead(resp2, 4),
CreateMockRead(body2, 5),
CreateMockRead(resp3, 7),
CreateMockRead(body3, 8),
CreateMockRead(resp4, 10),
CreateMockRead(body4, 11),
MockRead(SYNCHRONOUS, ERR_IO_PENDING, 12)};
SequencedSocketData data(MockConnect(ASYNC, OK), reads, writes);
helper.AddData(&data);
helper.RunPreTestSetup();
helper.RunDefaultTest();
TransactionHelperResult out = helper.output();
EXPECT_THAT(out.rv, IsOk());
EXPECT_EQ("HTTP/1.1 200", out.status_line);
EXPECT_EQ("hello!", out.response_data);
EXPECT_EQ(1u, helper.GetSpdySessionCount());
SpdySessionKey key1(HostPortPair(url1.host(), 443), PRIVACY_MODE_DISABLED,
ProxyChain::Direct(), SessionUsage::kDestination,
socket_tag_1, NetworkAnonymizationKey(),
SecureDnsPolicy::kAllow,
false);
EXPECT_TRUE(helper.session()->spdy_session_pool()->FindAvailableSession(
key1, true , false ,
NetLogWithSource()));
EXPECT_EQ(
dns_aliases1,
helper.session()->spdy_session_pool()->GetDnsAliasesForSessionKey(key1));
HttpRequestInfo request2;
request2.socket_tag = socket_tag_1;
request2.method = "GET";
request2.url = url2;
request2.load_flags = 0;
request2.traffic_annotation =
net::MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
SpdySessionKey key2(HostPortPair(url2.host(), 443), PRIVACY_MODE_DISABLED,
ProxyChain::Direct(), SessionUsage::kDestination,
socket_tag_1, NetworkAnonymizationKey(),
SecureDnsPolicy::kAllow,
false);
auto trans2 = std::make_unique<HttpNetworkTransaction>(DEFAULT_PRIORITY,
helper.session());
TestCompletionCallback callback2;
EXPECT_THAT(
trans2->Start(&request2, callback2.callback(), NetLogWithSource()),
IsError(ERR_IO_PENDING));
EXPECT_THAT(callback2.WaitForResult(), IsOk());
EXPECT_EQ(1u, helper.GetSpdySessionCount());
EXPECT_TRUE(helper.session()->spdy_session_pool()->FindAvailableSession(
key2, true , false ,
NetLogWithSource()));
EXPECT_EQ(
dns_aliases2,
helper.session()->spdy_session_pool()->GetDnsAliasesForSessionKey(key2));
const HttpResponseInfo* response = trans2->GetResponseInfo();
ASSERT_TRUE(response);
ASSERT_TRUE(response->headers);
EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine());
EXPECT_TRUE(response->was_fetched_via_spdy);
EXPECT_TRUE(response->was_alpn_negotiated);
std::string response_data;
ASSERT_THAT(ReadTransaction(trans2.get(), &response_data), IsOk());
EXPECT_EQ("hello!", response_data);
helper.session_deps()->host_resolver->rules()->ClearRules();
trans2.reset();
HttpRequestInfo request3;
request3.socket_tag = socket_tag_2;
request3.method = "GET";
request3.url = url2;
request3.load_flags = 0;
request3.traffic_annotation =
net::MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
SpdySessionKey key3(HostPortPair(url2.host(), 443), PRIVACY_MODE_DISABLED,
ProxyChain::Direct(), SessionUsage::kDestination,
socket_tag_2, NetworkAnonymizationKey(),
SecureDnsPolicy::kAllow,
false);
auto trans3 = std::make_unique<HttpNetworkTransaction>(DEFAULT_PRIORITY,
helper.session());
TestCompletionCallback callback3;
EXPECT_THAT(
trans3->Start(&request3, callback3.callback(), NetLogWithSource()),
IsError(ERR_IO_PENDING));
EXPECT_THAT(callback3.WaitForResult(), IsOk());
EXPECT_EQ(1u, helper.GetSpdySessionCount());
EXPECT_FALSE(helper.session()->spdy_session_pool()->FindAvailableSession(
key2, true , false ,
NetLogWithSource()));
EXPECT_TRUE(helper.session()
->spdy_session_pool()
->GetDnsAliasesForSessionKey(key2)
.empty());
EXPECT_TRUE(helper.session()->spdy_session_pool()->FindAvailableSession(
key3, true , false ,
NetLogWithSource()));
EXPECT_EQ(
dns_aliases2,
helper.session()->spdy_session_pool()->GetDnsAliasesForSessionKey(key3));
response = trans3->GetResponseInfo();
ASSERT_TRUE(response);
ASSERT_TRUE(response->headers);
EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine());
EXPECT_TRUE(response->was_fetched_via_spdy);
EXPECT_TRUE(response->was_alpn_negotiated);
ASSERT_THAT(ReadTransaction(trans3.get(), &response_data), IsOk());
EXPECT_EQ("hello!", response_data);
trans3.reset();
HttpRequestInfo request4;
request4.socket_tag = socket_tag_2;
request4.method = "GET";
request4.url = url1;
request4.load_flags = 0;
request4.traffic_annotation =
net::MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
SpdySessionKey key4(HostPortPair(url1.host(), 443), PRIVACY_MODE_DISABLED,
ProxyChain::Direct(), SessionUsage::kDestination,
socket_tag_2, NetworkAnonymizationKey(),
SecureDnsPolicy::kAllow,
false);
auto trans4 = std::make_unique<HttpNetworkTransaction>(DEFAULT_PRIORITY,
helper.session());
TestCompletionCallback callback4;
EXPECT_THAT(
trans4->Start(&request4, callback4.callback(), NetLogWithSource()),
IsError(ERR_IO_PENDING));
EXPECT_THAT(callback4.WaitForResult(), IsOk());
EXPECT_EQ(1u, helper.GetSpdySessionCount());
EXPECT_FALSE(helper.session()->spdy_session_pool()->FindAvailableSession(
key1, true , false ,
NetLogWithSource()));
EXPECT_TRUE(helper.session()
->spdy_session_pool()
->GetDnsAliasesForSessionKey(key1)
.empty());
EXPECT_TRUE(helper.session()->spdy_session_pool()->FindAvailableSession(
key4, true , false ,
NetLogWithSource()));
EXPECT_EQ(
dns_aliases1,
helper.session()->spdy_session_pool()->GetDnsAliasesForSessionKey(key4));
response = trans4->GetResponseInfo();
ASSERT_TRUE(response);
ASSERT_TRUE(response->headers);
EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine());
EXPECT_TRUE(response->was_fetched_via_spdy);
EXPECT_TRUE(response->was_alpn_negotiated);
ASSERT_THAT(ReadTransaction(trans4.get(), &response_data), IsOk());
EXPECT_EQ("hello!", response_data);
helper.VerifyDataConsumed();
}
#endif
TEST_P(SpdyNetworkTransactionTest, ResponseHeaders) { … }
TEST_P(SpdyNetworkTransactionTest, InvalidResponseHeaders) { … }
TEST_P(SpdyNetworkTransactionTest, CorruptFrameSessionError) { … }
TEST_P(SpdyNetworkTransactionTest, GoAwayOnDecompressionFailure) { … }
TEST_P(SpdyNetworkTransactionTest, GoAwayOnFrameSizeError) { … }
TEST_P(SpdyNetworkTransactionTest, WriteError) { … }
TEST_P(SpdyNetworkTransactionTest, PartialWrite) { … }
TEST_P(SpdyNetworkTransactionTest, NetLog) { … }
TEST_P(SpdyNetworkTransactionTest, NetLogForResponseWithNoBody) { … }
TEST_P(SpdyNetworkTransactionTest, BufferFull) { … }
TEST_P(SpdyNetworkTransactionTest, Buffering) { … }
TEST_P(SpdyNetworkTransactionTest, BufferedAll) { … }
TEST_P(SpdyNetworkTransactionTest, BufferedClosed) { … }
TEST_P(SpdyNetworkTransactionTest, BufferedCancelled) { … }
TEST_P(SpdyNetworkTransactionTest, FailOnGoAway) { … }
TEST_P(SpdyNetworkTransactionTest, RetryOnGoAway) { … }
TEST_P(SpdyNetworkTransactionTest, GracefulGoaway) { … }
TEST_P(SpdyNetworkTransactionTest, ActiveStreamWhileGoingAway) { … }
TEST_P(SpdyNetworkTransactionTest, CloseWithActiveStream) { … }
TEST_P(SpdyNetworkTransactionTest, GoAwayImmediately) { … }
TEST_P(SpdyNetworkTransactionTest, HTTP11RequiredRetry) { … }
TEST_P(SpdyNetworkTransactionTest,
HTTP11RequiredRetryWithNetworkAnonymizationKey) { … }
TEST_P(SpdyNetworkTransactionTest, HTTP11RequiredProxyRetry) { … }
TEST_P(SpdyNetworkTransactionTest,
HTTP11RequiredProxyRetryWithNetworkAnonymizationKey) { … }
TEST_P(SpdyNetworkTransactionTest, HTTP11RequiredNestedProxyFirstProxyRetry) { … }
TEST_P(SpdyNetworkTransactionTest, HTTP11RequiredNestedProxySecondProxyRetry) { … }
TEST_P(SpdyNetworkTransactionTest, ProxyConnect) { … }
TEST_P(SpdyNetworkTransactionTest, DirectConnectProxyReconnect) { … }
TEST_P(SpdyNetworkTransactionTest, VerifyRetryOnConnectionReset) { … }
TEST_P(SpdyNetworkTransactionTest, SpdyBasicAuth) { … }
TEST_P(SpdyNetworkTransactionTest, ResponseHeadersTwice) { … }
TEST_P(SpdyNetworkTransactionTest, SyncReplyDataAfterTrailers) { … }
TEST_P(SpdyNetworkTransactionTest, RetryAfterRefused) { … }
TEST_P(SpdyNetworkTransactionTest, OutOfOrderHeaders) { … }
TEST_P(SpdyNetworkTransactionTest, WindowUpdateReceived) { … }
TEST_P(SpdyNetworkTransactionTest, WindowUpdateSent) { … }
TEST_P(SpdyNetworkTransactionTest, WindowUpdateOverflow) { … }
TEST_P(SpdyNetworkTransactionTest, InitialWindowSizeOverflow) { … }
TEST_P(SpdyNetworkTransactionTest, SessionMaxQueuedCappedFramesExceeded) { … }
TEST_P(SpdyNetworkTransactionTest, FlowControlStallResume) { … }
TEST_P(SpdyNetworkTransactionTest, FlowControlStallResumeAfterSettings) { … }
TEST_P(SpdyNetworkTransactionTest, FlowControlNegativeSendWindowSize) { … }
TEST_P(SpdyNetworkTransactionTest, ReceivingPushIsConnectionError) { … }
TEST_P(SpdyNetworkTransactionTest,
ReceivingPushWithOddStreamIdIsConnectionError) { … }
TEST_P(SpdyNetworkTransactionTest, LargeRequest) { … }
TEST_P(SpdyNetworkTransactionTest, LargeResponseHeader) { … }
TEST_P(SpdyNetworkTransactionTest, CRLFInHeaderValue) { … }
TEST_P(SpdyNetworkTransactionTest, RstStreamNoError) { … }
TEST_P(SpdyNetworkTransactionTest, RstStreamNoErrorAfterResponse) { … }
TEST_P(SpdyNetworkTransactionTest, 100Continue) { … }
TEST_P(SpdyNetworkTransactionTest, ResponseBeforePostDataSent) { … }
TEST_P(SpdyNetworkTransactionTest, ResponseAndRstStreamBeforePostDataSent) { … }
TEST_P(SpdyNetworkTransactionTest, IgnoreUnsupportedOriginFrame) { … }
class SpdyNetworkTransactionTLSUsageCheckTest
: public SpdyNetworkTransactionTest { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSVersionTooOld) { … }
TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { … }
TEST_P(SpdyNetworkTransactionTest, InsecureUrlCreatesSecureSpdySession) { … }
TEST_P(SpdyNetworkTransactionTest, RequestHeadersCallback) { … }
#if BUILDFLAG(ENABLE_WEBSOCKETS)
TEST_P(SpdyNetworkTransactionTest, WebSocketOpensNewConnection) { … }
TEST_P(SpdyNetworkTransactionTest,
WebSocketDoesUseNewH2SessionWithoutWebSocketSupport) { … }
TEST_P(SpdyNetworkTransactionTest, WebSocketOverHTTP2) { … }
TEST_P(SpdyNetworkTransactionTest,
WebSocketDoesNotUseNewH2SessionWithoutWebSocketSupportOverHttpsProxy) { … }
TEST_P(SpdyNetworkTransactionTest,
WebSocketOverHTTP2DetectsNewSessionWithAliasing) { … }
TEST_P(SpdyNetworkTransactionTest,
WebSocketOverDetectsNewSessionWithAliasingButClosedBeforeUse) { … }
TEST_P(SpdyNetworkTransactionTest, WebSocketNegotiatesHttp2) { … }
TEST_P(SpdyNetworkTransactionTest, WebSocketHttp11Required) { … }
TEST_P(SpdyNetworkTransactionTest, PlaintextWebSocketOverHttp2Proxy) { … }
TEST_P(SpdyNetworkTransactionTest, SecureWebSocketOverH2OverH2Proxy) { … }
TEST_P(SpdyNetworkTransactionTest, SecureWebSocketOverHttp2Proxy) { … }
TEST_P(SpdyNetworkTransactionTest,
SecureWebSocketOverHttp2ProxyNegotiatesHttp2) { … }
#endif
TEST_P(SpdyNetworkTransactionTest, ZeroRTTDoesntConfirm) { … }
TEST_P(SpdyNetworkTransactionTest, ZeroRTTNoConfirmMultipleStreams) { … }
TEST_P(SpdyNetworkTransactionTest, ZeroRTTConfirmMultipleStreams) { … }
TEST_P(SpdyNetworkTransactionTest, ZeroRTTConfirmNoConfirmStreams) { … }
TEST_P(SpdyNetworkTransactionTest, ZeroRTTNoConfirmConfirmStreams) { … }
TEST_P(SpdyNetworkTransactionTest, ZeroRTTSyncConfirmSyncWrite) { … }
TEST_P(SpdyNetworkTransactionTest, ZeroRTTSyncConfirmAsyncWrite) { … }
TEST_P(SpdyNetworkTransactionTest, ZeroRTTAsyncConfirmSyncWrite) { … }
TEST_P(SpdyNetworkTransactionTest, ZeroRTTAsyncConfirmAsyncWrite) { … }
TEST_P(SpdyNetworkTransactionTest, ZeroRTTConfirmErrorSync) { … }
TEST_P(SpdyNetworkTransactionTest, ZeroRTTConfirmErrorAsync) { … }
TEST_P(SpdyNetworkTransactionTest, GreaseSettings) { … }
TEST_P(SpdyNetworkTransactionTest,
DoNotGreaseFrameTypeWithGetRequestIfHeadersFrameClosesStream) { … }
TEST_P(SpdyNetworkTransactionTest, GreaseFrameTypeWithGetRequest) { … }
TEST_P(SpdyNetworkTransactionTest,
GreaseFrameTypeWithPostRequestWhenHeadersFrameClosesStream) { … }
TEST_P(SpdyNetworkTransactionTest,
GreaseFrameTypeWithPostRequestWhenEmptyDataFrameClosesStream) { … }
TEST_P(SpdyNetworkTransactionTest, DoNotGreaseFrameTypeWithConnect) { … }
TEST_P(SpdyNetworkTransactionTest, OnDataSentDoesNotCrashWithGreasedFrameType) { … }
TEST_P(SpdyNetworkTransactionTest, NotAllowHTTP1NotBlockH2Post) { … }
TEST_P(SpdyNetworkTransactionTest, AlpsFramingError) { … }
}