Chromium Code Reviews| 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..edaa4105db8831aba4d253fe2978fd26e55f9582 100644 |
| --- a/net/http/http_stream_factory.cc |
| +++ b/net/http/http_stream_factory.cc |
| @@ -13,6 +13,7 @@ |
| #include "net/base/host_port_pair.h" |
| #include "net/base/port_util.h" |
| #include "net/http/http_network_session.h" |
| +#include "net/http/http_response_headers.h" |
| #include "net/quic/quic_protocol.h" |
| #include "net/spdy/spdy_alt_svc_wire_format.h" |
| #include "url/gurl.h" |
| @@ -32,6 +33,59 @@ void HttpStreamFactory::ResetStaticSettingsToInit() { |
| spdy_enabled_ = true; |
| } |
| +void HttpStreamFactory::ProcessAlternativeServices( |
| + HttpNetworkSession* session, |
| + const HttpResponseHeaders* headers, |
| + const HostPortPair& http_host_port_pair) { |
| + if (session->params().parse_alternative_services) { |
| + if (headers->HasHeader(kAlternativeServiceHeader)) { |
| + std::string alternative_service_str; |
| + headers->GetNormalizedHeader(kAlternativeServiceHeader, |
| + &alternative_service_str); |
| + ProcessAlternativeService(session->http_server_properties(), |
| + alternative_service_str, http_host_port_pair, |
| + *session); |
| + } |
| + // If "Alt-Svc" is enabled, then ignore "Alternate-Protocol". |
| + return; |
| + } |
| + |
| + if (!headers->HasHeader(kAlternateProtocolHeader)) |
| + return; |
| + |
| + std::vector<std::string> alternate_protocol_values; |
| + size_t iter = 0; |
| + std::string alternate_protocol_str; |
| + while (headers->EnumerateHeader(&iter, kAlternateProtocolHeader, |
| + &alternate_protocol_str)) { |
| + base::TrimWhitespaceASCII(alternate_protocol_str, base::TRIM_ALL, |
| + &alternate_protocol_str); |
| + if (!alternate_protocol_str.empty()) { |
| + alternate_protocol_values.push_back(alternate_protocol_str); |
| + } |
| + } |
| + |
| + ProcessAlternateProtocol(session->http_server_properties(), |
| + alternate_protocol_values, http_host_port_pair, |
| + *session); |
| +} |
| + |
| +GURL HttpStreamFactory::ApplyHostMappingRules(const GURL& url, |
|
Ryan Hamilton
2016/03/18 20:54:58
Does this method need to move as part of this CL?
xunjieli
2016/03/18 21:01:27
I was tricked too! The diffing tool is being weird
|
| + HostPortPair* endpoint) { |
| + const HostMappingRules* mapping_rules = GetHostMappingRules(); |
| + if (mapping_rules && mapping_rules->RewriteHost(endpoint)) { |
| + url::Replacements<char> replacements; |
| + const std::string port_str = base::UintToString(endpoint->port()); |
| + replacements.SetPort(port_str.c_str(), url::Component(0, port_str.size())); |
| + replacements.SetHost(endpoint->host().c_str(), |
| + url::Component(0, endpoint->host().size())); |
| + return url.ReplaceComponents(replacements); |
| + } |
| + return url; |
| +} |
| + |
| +HttpStreamFactory::HttpStreamFactory() {} |
| + |
| void HttpStreamFactory::ProcessAlternativeService( |
| const base::WeakPtr<HttpServerProperties>& http_server_properties, |
| base::StringPiece alternative_service_str, |
| @@ -141,22 +195,6 @@ void HttpStreamFactory::ProcessAlternateProtocol( |
| base::Time::Now() + base::TimeDelta::FromDays(30)); |
| } |
| -GURL HttpStreamFactory::ApplyHostMappingRules(const GURL& url, |
| - HostPortPair* endpoint) { |
| - const HostMappingRules* mapping_rules = GetHostMappingRules(); |
| - if (mapping_rules && mapping_rules->RewriteHost(endpoint)) { |
| - url::Replacements<char> replacements; |
| - const std::string port_str = base::UintToString(endpoint->port()); |
| - replacements.SetPort(port_str.c_str(), url::Component(0, port_str.size())); |
| - replacements.SetHost(endpoint->host().c_str(), |
| - url::Component(0, endpoint->host().size())); |
| - return url.ReplaceComponents(replacements); |
| - } |
| - return url; |
| -} |
| - |
| -HttpStreamFactory::HttpStreamFactory() {} |
| - |
| HostPortPair HttpStreamFactory::RewriteHost(HostPortPair host_port_pair) { |
| const HostMappingRules* mapping_rules = GetHostMappingRules(); |
| if (mapping_rules) |