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

Unified Diff: net/http/http_network_transaction_unittest.cc

Issue 665083009: ABANDONED Handle multiple AlternateProtocols for each HostPortPair. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Re: 18. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/net_log_util.cc ('k') | net/http/http_server_properties.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_network_transaction_unittest.cc
diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc
index 6e1ad43b13812b1f304ae82825c28efcc4559bb4..5335b9e10ebb085b1721f431bbe99a269ad6c5a4 100644
--- a/net/http/http_network_transaction_unittest.cc
+++ b/net/http/http_network_transaction_unittest.cc
@@ -7614,7 +7614,7 @@ scoped_refptr<HttpNetworkSession> SetupSessionForGroupNameTests(
base::WeakPtr<HttpServerProperties> http_server_properties =
session->http_server_properties();
- http_server_properties->SetAlternateProtocol(
+ http_server_properties->AddAlternateProtocol(
HostPortPair("host.with.alternate", 80), 443,
AlternateProtocolFromNextProto(next_proto), 1.0);
@@ -8508,9 +8508,9 @@ TEST_P(HttpNetworkTransactionTest, HonorAlternateProtocolHeader) {
HostPortPair http_host_port_pair("www.google.com", 80);
HttpServerProperties& http_server_properties =
*session->http_server_properties();
- AlternateProtocolInfo alternate =
- http_server_properties.GetAlternateProtocol(http_host_port_pair);
- EXPECT_EQ(alternate.protocol, UNINITIALIZED_ALTERNATE_PROTOCOL);
+ AlternateProtocols alternates =
+ http_server_properties.GetAlternateProtocols(http_host_port_pair);
+ EXPECT_EQ(0u, alternates.size());
EXPECT_EQ(OK, callback.WaitForResult());
@@ -8525,10 +8525,12 @@ TEST_P(HttpNetworkTransactionTest, HonorAlternateProtocolHeader) {
ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
EXPECT_EQ("hello world", response_data);
- alternate = http_server_properties.GetAlternateProtocol(http_host_port_pair);
- EXPECT_EQ(443, alternate.port);
- EXPECT_EQ(AlternateProtocolFromNextProto(GetParam()), alternate.protocol);
- EXPECT_EQ(1.0, alternate.probability);
+ alternates =
+ http_server_properties.GetAlternateProtocols(http_host_port_pair);
+ ASSERT_EQ(1u, alternates.size());
+ EXPECT_EQ(443, alternates[0].port);
+ EXPECT_EQ(AlternateProtocolFromNextProto(GetParam()), alternates[0].protocol);
+ EXPECT_EQ(1.0, alternates[0].probability);
}
TEST_P(HttpNetworkTransactionTest,
@@ -8560,9 +8562,9 @@ TEST_P(HttpNetworkTransactionTest,
session->http_server_properties();
// Port must be < 1024, or the header will be ignored (since initial port was
// port 80 (another restricted port).
- http_server_properties->SetAlternateProtocol(
- HostPortPair::FromURL(request.url),
- 666 /* port is ignored by MockConnect anyway */,
+ const HostPortPair http_host_port_pair = HostPortPair::FromURL(request.url);
+ http_server_properties->AddAlternateProtocol(
+ http_host_port_pair, 666 /* port is ignored by MockConnect anyway */,
AlternateProtocolFromNextProto(GetParam()), 1.0);
scoped_ptr<HttpTransaction> trans(
@@ -8582,11 +8584,13 @@ TEST_P(HttpNetworkTransactionTest,
ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
EXPECT_EQ("hello world", response_data);
- const AlternateProtocolInfo alternate =
- http_server_properties->GetAlternateProtocol(
- HostPortPair::FromURL(request.url));
- EXPECT_NE(UNINITIALIZED_ALTERNATE_PROTOCOL, alternate.protocol);
- EXPECT_TRUE(alternate.is_broken);
+ const AlternateProtocols alternate_protocols =
+ http_server_properties->GetAlternateProtocols(http_host_port_pair);
+ ASSERT_EQ(1u, alternate_protocols.size());
+ AlternateProtocolInfo expected_alternate(
+ 666, AlternateProtocolFromNextProto(GetParam()), 1.0);
+ EXPECT_TRUE(expected_alternate.Equals(alternate_protocols[0]));
+ EXPECT_TRUE(alternate_protocols[0].is_broken);
}
TEST_P(HttpNetworkTransactionTest,
@@ -8621,7 +8625,7 @@ TEST_P(HttpNetworkTransactionTest,
base::WeakPtr<HttpServerProperties> http_server_properties =
session->http_server_properties();
const int kUnrestrictedAlternatePort = 1024;
- http_server_properties->SetAlternateProtocol(
+ http_server_properties->AddAlternateProtocol(
HostPortPair::FromURL(restricted_port_request.url),
kUnrestrictedAlternatePort, AlternateProtocolFromNextProto(GetParam()),
1.0);
@@ -8672,7 +8676,7 @@ TEST_P(HttpNetworkTransactionTest,
base::WeakPtr<HttpServerProperties> http_server_properties =
session->http_server_properties();
const int kUnrestrictedAlternatePort = 1024;
- http_server_properties->SetAlternateProtocol(
+ http_server_properties->AddAlternateProtocol(
HostPortPair::FromURL(restricted_port_request.url),
kUnrestrictedAlternatePort, AlternateProtocolFromNextProto(GetParam()),
1.0);
@@ -8720,7 +8724,7 @@ TEST_P(HttpNetworkTransactionTest,
base::WeakPtr<HttpServerProperties> http_server_properties =
session->http_server_properties();
const int kRestrictedAlternatePort = 80;
- http_server_properties->SetAlternateProtocol(
+ http_server_properties->AddAlternateProtocol(
HostPortPair::FromURL(restricted_port_request.url),
kRestrictedAlternatePort, AlternateProtocolFromNextProto(GetParam()),
1.0);
@@ -8769,7 +8773,7 @@ TEST_P(HttpNetworkTransactionTest,
base::WeakPtr<HttpServerProperties> http_server_properties =
session->http_server_properties();
const int kRestrictedAlternatePort = 80;
- http_server_properties->SetAlternateProtocol(
+ http_server_properties->AddAlternateProtocol(
HostPortPair::FromURL(unrestricted_port_request.url),
kRestrictedAlternatePort, AlternateProtocolFromNextProto(GetParam()),
1.0);
@@ -8817,7 +8821,7 @@ TEST_P(HttpNetworkTransactionTest,
base::WeakPtr<HttpServerProperties> http_server_properties =
session->http_server_properties();
const int kUnrestrictedAlternatePort = 1024;
- http_server_properties->SetAlternateProtocol(
+ http_server_properties->AddAlternateProtocol(
HostPortPair::FromURL(unrestricted_port_request.url),
kUnrestrictedAlternatePort, AlternateProtocolFromNextProto(GetParam()),
1.0);
@@ -8860,7 +8864,7 @@ TEST_P(HttpNetworkTransactionTest, AlternateProtocolUnsafeBlocked) {
base::WeakPtr<HttpServerProperties> http_server_properties =
session->http_server_properties();
const int kUnsafePort = 7;
- http_server_properties->SetAlternateProtocol(
+ http_server_properties->AddAlternateProtocol(
HostPortPair::FromURL(request.url), kUnsafePort,
AlternateProtocolFromNextProto(GetParam()), 1.0);
« no previous file with comments | « net/base/net_log_util.cc ('k') | net/http/http_server_properties.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698