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)) { | 89 http_server_properties->ClearNonBrokenAlternateProtocols(host_port); |
90 const AlternateProtocolInfo existing_alternate = | 90 http_server_properties->AddAlternateProtocol(host_port, port, protocol, |
91 http_server_properties->GetAlternateProtocol(host_port); | 91 probability); |
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( | |
98 host_port, static_cast<uint16>(port), protocol, probability); | |
99 } | 92 } |
100 | 93 |
101 GURL HttpStreamFactory::ApplyHostMappingRules(const GURL& url, | 94 GURL HttpStreamFactory::ApplyHostMappingRules(const GURL& url, |
102 HostPortPair* endpoint) { | 95 HostPortPair* endpoint) { |
103 const HostMappingRules* mapping_rules = GetHostMappingRules(); | 96 const HostMappingRules* mapping_rules = GetHostMappingRules(); |
104 if (mapping_rules && mapping_rules->RewriteHost(endpoint)) { | 97 if (mapping_rules && mapping_rules->RewriteHost(endpoint)) { |
105 url::Replacements<char> replacements; | 98 url::Replacements<char> replacements; |
106 const std::string port_str = base::IntToString(endpoint->port()); | 99 const std::string port_str = base::IntToString(endpoint->port()); |
107 replacements.SetPort(port_str.c_str(), url::Component(0, port_str.size())); | 100 replacements.SetPort(port_str.c_str(), url::Component(0, port_str.size())); |
108 replacements.SetHost(endpoint->host().c_str(), | 101 replacements.SetHost(endpoint->host().c_str(), |
109 url::Component(0, endpoint->host().size())); | 102 url::Component(0, endpoint->host().size())); |
110 return url.ReplaceComponents(replacements); | 103 return url.ReplaceComponents(replacements); |
111 } | 104 } |
112 return url; | 105 return url; |
113 } | 106 } |
114 | 107 |
115 HttpStreamFactory::HttpStreamFactory() {} | 108 HttpStreamFactory::HttpStreamFactory() {} |
116 | 109 |
117 } // namespace net | 110 } // namespace net |
OLD | NEW |