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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 !session.IsProtocolEnabled(protocol)) { | 77 !session.IsProtocolEnabled(protocol)) { |
78 DVLOG(1) << kAlternateProtocolHeader | 78 DVLOG(1) << kAlternateProtocolHeader |
79 << " header has unrecognized protocol: " | 79 << " header has unrecognized protocol: " |
80 << port_protocol_vector[1]; | 80 << port_protocol_vector[1]; |
81 is_valid = false; | 81 is_valid = false; |
82 break; | 82 break; |
83 } | 83 } |
84 } | 84 } |
85 | 85 |
86 if (!is_valid || protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) { | 86 if (!is_valid || protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) { |
87 http_server_properties->ClearAlternativeService(http_host_port_pair); | 87 http_server_properties->ClearAlternativeServices(http_host_port_pair); |
88 return; | 88 return; |
89 } | 89 } |
90 | 90 |
91 HostPortPair host_port(http_host_port_pair); | 91 HostPortPair host_port(http_host_port_pair); |
92 const HostMappingRules* mapping_rules = GetHostMappingRules(); | 92 const HostMappingRules* mapping_rules = GetHostMappingRules(); |
93 if (mapping_rules) | 93 if (mapping_rules) |
94 mapping_rules->RewriteHost(&host_port); | 94 mapping_rules->RewriteHost(&host_port); |
95 | 95 |
96 http_server_properties->SetAlternativeService( | 96 http_server_properties->ClearAlternativeServices(host_port); |
| 97 http_server_properties->AddAlternativeService( |
97 host_port, AlternativeService(protocol, "", static_cast<uint16>(port)), | 98 host_port, AlternativeService(protocol, "", static_cast<uint16>(port)), |
98 probability); | 99 probability); |
99 } | 100 } |
100 | 101 |
101 GURL HttpStreamFactory::ApplyHostMappingRules(const GURL& url, | 102 GURL HttpStreamFactory::ApplyHostMappingRules(const GURL& url, |
102 HostPortPair* endpoint) { | 103 HostPortPair* endpoint) { |
103 const HostMappingRules* mapping_rules = GetHostMappingRules(); | 104 const HostMappingRules* mapping_rules = GetHostMappingRules(); |
104 if (mapping_rules && mapping_rules->RewriteHost(endpoint)) { | 105 if (mapping_rules && mapping_rules->RewriteHost(endpoint)) { |
105 url::Replacements<char> replacements; | 106 url::Replacements<char> replacements; |
106 const std::string port_str = base::IntToString(endpoint->port()); | 107 const std::string port_str = base::IntToString(endpoint->port()); |
107 replacements.SetPort(port_str.c_str(), url::Component(0, port_str.size())); | 108 replacements.SetPort(port_str.c_str(), url::Component(0, port_str.size())); |
108 replacements.SetHost(endpoint->host().c_str(), | 109 replacements.SetHost(endpoint->host().c_str(), |
109 url::Component(0, endpoint->host().size())); | 110 url::Component(0, endpoint->host().size())); |
110 return url.ReplaceComponents(replacements); | 111 return url.ReplaceComponents(replacements); |
111 } | 112 } |
112 return url; | 113 return url; |
113 } | 114 } |
114 | 115 |
115 HttpStreamFactory::HttpStreamFactory() {} | 116 HttpStreamFactory::HttpStreamFactory() {} |
116 | 117 |
117 } // namespace net | 118 } // namespace net |
OLD | NEW |