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