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, |