Index: net/http/http_stream_factory.cc |
diff --git a/net/http/http_stream_factory.cc b/net/http/http_stream_factory.cc |
index e86d8f89b071a9216854512694d174aaa85475a2..b60df85ed7ecbe8961b6ace2bb087bfbe8784df8 100644 |
--- a/net/http/http_stream_factory.cc |
+++ b/net/http/http_stream_factory.cc |
@@ -7,7 +7,6 @@ |
#include "base/logging.h" |
#include "base/strings/string_number_conversions.h" |
#include "base/strings/string_split.h" |
-#include "base/strings/string_util.h" |
#include "net/base/host_mapping_rules.h" |
#include "net/base/host_port_pair.h" |
#include "net/http/http_network_session.h" |
@@ -30,60 +29,40 @@ |
void HttpStreamFactory::ProcessAlternateProtocol( |
const base::WeakPtr<HttpServerProperties>& http_server_properties, |
- const std::vector<std::string>& alternate_protocol_values, |
+ const std::string& alternate_protocol_str, |
const HostPortPair& http_host_port_pair, |
const HttpNetworkSession& session) { |
- AlternateProtocol protocol = UNINITIALIZED_ALTERNATE_PROTOCOL; |
- int port = 0; |
- double probability = 1; |
- for (size_t i = 0; i < alternate_protocol_values.size(); ++i) { |
- const std::string& alternate_protocol_str = alternate_protocol_values[i]; |
- if (StartsWithASCII(alternate_protocol_str, "p=", true)) { |
- if (!base::StringToDouble(alternate_protocol_str.substr(2), |
- &probability) || |
- probability < 0 || probability > 1) { |
- DVLOG(1) << kAlternateProtocolHeader |
- << " header has unrecognizable probability: " |
- << alternate_protocol_values[i]; |
- return; |
- } |
- continue; |
- } |
- |
- std::vector<std::string> port_protocol_vector; |
- base::SplitString(alternate_protocol_str, ':', &port_protocol_vector); |
- if (port_protocol_vector.size() != 2) { |
- DVLOG(1) << kAlternateProtocolHeader |
- << " header has too many tokens: " |
- << alternate_protocol_str; |
- return; |
- } |
- |
- if (!base::StringToInt(port_protocol_vector[0], &port) || |
- port <= 0 || port >= 1 << 16) { |
- DVLOG(1) << kAlternateProtocolHeader |
- << " header has unrecognizable port: " |
- << port_protocol_vector[0]; |
- return; |
- } |
- |
- protocol = |
- AlternateProtocolFromString(port_protocol_vector[1]); |
- if (IsAlternateProtocolValid(protocol) && |
- !session.IsProtocolEnabled(protocol)) { |
- protocol = ALTERNATE_PROTOCOL_BROKEN; |
- } |
- |
- if (protocol == ALTERNATE_PROTOCOL_BROKEN) { |
- DVLOG(1) << kAlternateProtocolHeader |
- << " header has unrecognized protocol: " |
- << port_protocol_vector[1]; |
- return; |
- } |
+ std::vector<std::string> port_protocol_vector; |
+ base::SplitString(alternate_protocol_str, ':', &port_protocol_vector); |
+ if (port_protocol_vector.size() != 2) { |
+ DVLOG(1) << kAlternateProtocolHeader |
+ << " header has too many tokens: " |
+ << alternate_protocol_str; |
+ return; |
} |
- if (protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) |
+ int port; |
+ if (!base::StringToInt(port_protocol_vector[0], &port) || |
+ port <= 0 || port >= 1 << 16) { |
+ DVLOG(1) << kAlternateProtocolHeader |
+ << " header has unrecognizable port: " |
+ << port_protocol_vector[0]; |
return; |
+ } |
+ |
+ AlternateProtocol protocol = |
+ AlternateProtocolFromString(port_protocol_vector[1]); |
+ if (IsAlternateProtocolValid(protocol) && |
+ !session.IsProtocolEnabled(protocol)) { |
+ protocol = ALTERNATE_PROTOCOL_BROKEN; |
+ } |
+ |
+ if (protocol == ALTERNATE_PROTOCOL_BROKEN) { |
+ DVLOG(1) << kAlternateProtocolHeader |
+ << " header has unrecognized protocol: " |
+ << port_protocol_vector[1]; |
+ return; |
+ } |
HostPortPair host_port(http_host_port_pair); |
const HostMappingRules* mapping_rules = GetHostMappingRules(); |
@@ -91,15 +70,14 @@ |
mapping_rules->RewriteHost(&host_port); |
if (http_server_properties->HasAlternateProtocol(host_port)) { |
- const AlternateProtocolInfo existing_alternate = |
+ const PortAlternateProtocolPair existing_alternate = |
http_server_properties->GetAlternateProtocol(host_port); |
// If we think the alternate protocol is broken, don't change it. |
if (existing_alternate.protocol == ALTERNATE_PROTOCOL_BROKEN) |
return; |
} |
- http_server_properties->SetAlternateProtocol(host_port, port, protocol, |
- probability); |
+ http_server_properties->SetAlternateProtocol(host_port, port, protocol); |
} |
GURL HttpStreamFactory::ApplyHostMappingRules(const GURL& url, |