| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 } | 79 } |
| 80 | 80 |
| 81 if (protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) | 81 if (protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) |
| 82 return; | 82 return; |
| 83 | 83 |
| 84 HostPortPair host_port(http_host_port_pair); | 84 HostPortPair host_port(http_host_port_pair); |
| 85 const HostMappingRules* mapping_rules = GetHostMappingRules(); | 85 const HostMappingRules* mapping_rules = GetHostMappingRules(); |
| 86 if (mapping_rules) | 86 if (mapping_rules) |
| 87 mapping_rules->RewriteHost(&host_port); | 87 mapping_rules->RewriteHost(&host_port); |
| 88 | 88 |
| 89 if (http_server_properties->HasAlternateProtocol(host_port)) { | |
| 90 const AlternateProtocolInfo existing_alternate = | |
| 91 http_server_properties->GetAlternateProtocol(host_port); | |
| 92 // If we think the alternate protocol is broken, don't change it. | |
| 93 if (existing_alternate.is_broken) | |
| 94 return; | |
| 95 } | |
| 96 | |
| 97 http_server_properties->SetAlternateProtocol( | 89 http_server_properties->SetAlternateProtocol( |
| 98 host_port, static_cast<uint16>(port), protocol, probability); | 90 host_port, static_cast<uint16>(port), protocol, probability); |
| 99 } | 91 } |
| 100 | 92 |
| 101 GURL HttpStreamFactory::ApplyHostMappingRules(const GURL& url, | 93 GURL HttpStreamFactory::ApplyHostMappingRules(const GURL& url, |
| 102 HostPortPair* endpoint) { | 94 HostPortPair* endpoint) { |
| 103 const HostMappingRules* mapping_rules = GetHostMappingRules(); | 95 const HostMappingRules* mapping_rules = GetHostMappingRules(); |
| 104 if (mapping_rules && mapping_rules->RewriteHost(endpoint)) { | 96 if (mapping_rules && mapping_rules->RewriteHost(endpoint)) { |
| 105 url::Replacements<char> replacements; | 97 url::Replacements<char> replacements; |
| 106 const std::string port_str = base::IntToString(endpoint->port()); | 98 const std::string port_str = base::IntToString(endpoint->port()); |
| 107 replacements.SetPort(port_str.c_str(), url::Component(0, port_str.size())); | 99 replacements.SetPort(port_str.c_str(), url::Component(0, port_str.size())); |
| 108 replacements.SetHost(endpoint->host().c_str(), | 100 replacements.SetHost(endpoint->host().c_str(), |
| 109 url::Component(0, endpoint->host().size())); | 101 url::Component(0, endpoint->host().size())); |
| 110 return url.ReplaceComponents(replacements); | 102 return url.ReplaceComponents(replacements); |
| 111 } | 103 } |
| 112 return url; | 104 return url; |
| 113 } | 105 } |
| 114 | 106 |
| 115 HttpStreamFactory::HttpStreamFactory() {} | 107 HttpStreamFactory::HttpStreamFactory() {} |
| 116 | 108 |
| 117 } // namespace net | 109 } // namespace net |
| OLD | NEW |