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

Unified Diff: net/http/http_stream_factory.cc

Issue 1802893002: Revert of Remove support for Alt-Svc/Alternate Protocol Probability (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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/http/http_server_properties_manager_unittest.cc ('k') | net/http/http_stream_factory_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_stream_factory.cc
diff --git a/net/http/http_stream_factory.cc b/net/http/http_stream_factory.cc
index bc0212b381e8ae295bc2366d8c5cf43ae36ce475..d6d76b453c8e82d124d474ad7c844d3f5a1f5ade 100644
--- a/net/http/http_stream_factory.cc
+++ b/net/http/http_stream_factory.cc
@@ -79,8 +79,8 @@
base::Time expiration =
base::Time::Now() +
base::TimeDelta::FromSeconds(alternative_service_entry.max_age);
- AlternativeServiceInfo alternative_service_info(alternative_service,
- expiration);
+ AlternativeServiceInfo alternative_service_info(
+ alternative_service, alternative_service_entry.probability, expiration);
alternative_service_info_vector.push_back(alternative_service_info);
}
@@ -95,9 +95,24 @@
const HttpNetworkSession& session) {
AlternateProtocol protocol = UNINITIALIZED_ALTERNATE_PROTOCOL;
int port = 0;
+ double probability = 1;
bool is_valid = true;
for (size_t i = 0; i < alternate_protocol_values.size(); ++i) {
base::StringPiece alternate_protocol_str = alternate_protocol_values[i];
+ if (base::StartsWith(alternate_protocol_str, "p=",
+ base::CompareCase::SENSITIVE)) {
+ if (!base::StringToDouble(alternate_protocol_str.substr(2).as_string(),
+ &probability) ||
+ probability < 0 || probability > 1) {
+ DVLOG(1) << kAlternateProtocolHeader
+ << " header has unrecognizable probability: "
+ << alternate_protocol_values[i];
+ is_valid = false;
+ break;
+ }
+ continue;
+ }
+
std::vector<base::StringPiece> port_protocol_vector =
base::SplitStringPiece(alternate_protocol_str, ":",
base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
@@ -138,7 +153,7 @@
http_server_properties->SetAlternativeService(
RewriteHost(http_host_port_pair),
AlternativeService(protocol, "", static_cast<uint16_t>(port)),
- base::Time::Now() + base::TimeDelta::FromDays(30));
+ probability, base::Time::Now() + base::TimeDelta::FromDays(30));
}
GURL HttpStreamFactory::ApplyHostMappingRules(const GURL& url,
« no previous file with comments | « net/http/http_server_properties_manager_unittest.cc ('k') | net/http/http_stream_factory_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698