| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/http/http_stream_factory.h" | 5 #include "net/http/http_stream_factory.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 base::TimeDelta::FromSeconds(alternative_service_entry.max_age); | 88 base::TimeDelta::FromSeconds(alternative_service_entry.max_age); |
| 89 AlternativeServiceInfo alternative_service_info(alternative_service, | 89 AlternativeServiceInfo alternative_service_info(alternative_service, |
| 90 expiration); | 90 expiration); |
| 91 alternative_service_info_vector.push_back(alternative_service_info); | 91 alternative_service_info_vector.push_back(alternative_service_info); |
| 92 } | 92 } |
| 93 | 93 |
| 94 session->http_server_properties()->SetAlternativeServices( | 94 session->http_server_properties()->SetAlternativeServices( |
| 95 RewriteHost(http_server), alternative_service_info_vector); | 95 RewriteHost(http_server), alternative_service_info_vector); |
| 96 } | 96 } |
| 97 | 97 |
| 98 GURL HttpStreamFactory::ApplyHostMappingRules(const GURL& url, |
| 99 HostPortPair* endpoint) { |
| 100 const HostMappingRules* mapping_rules = GetHostMappingRules(); |
| 101 if (mapping_rules && mapping_rules->RewriteHost(endpoint)) { |
| 102 url::Replacements<char> replacements; |
| 103 const std::string port_str = base::UintToString(endpoint->port()); |
| 104 replacements.SetPort(port_str.c_str(), url::Component(0, port_str.size())); |
| 105 replacements.SetHost(endpoint->host().c_str(), |
| 106 url::Component(0, endpoint->host().size())); |
| 107 return url.ReplaceComponents(replacements); |
| 108 } |
| 109 return url; |
| 110 } |
| 111 |
| 98 HttpStreamFactory::HttpStreamFactory() {} | 112 HttpStreamFactory::HttpStreamFactory() {} |
| 99 | 113 |
| 100 url::SchemeHostPort HttpStreamFactory::RewriteHost( | 114 url::SchemeHostPort HttpStreamFactory::RewriteHost( |
| 101 const url::SchemeHostPort& server) { | 115 const url::SchemeHostPort& server) { |
| 102 HostPortPair host_port_pair(server.host(), server.port()); | 116 HostPortPair host_port_pair(server.host(), server.port()); |
| 103 const HostMappingRules* mapping_rules = GetHostMappingRules(); | 117 const HostMappingRules* mapping_rules = GetHostMappingRules(); |
| 104 if (mapping_rules) | 118 if (mapping_rules) |
| 105 mapping_rules->RewriteHost(&host_port_pair); | 119 mapping_rules->RewriteHost(&host_port_pair); |
| 106 return url::SchemeHostPort(server.scheme(), host_port_pair.host(), | 120 return url::SchemeHostPort(server.scheme(), host_port_pair.host(), |
| 107 host_port_pair.port()); | 121 host_port_pair.port()); |
| 108 } | 122 } |
| 109 | 123 |
| 110 } // namespace net | 124 } // namespace net |
| OLD | NEW |