Chromium Code Reviews| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 } | 83 } |
| 84 | 84 |
| 85 if (protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) | 85 if (protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) |
| 86 return; | 86 return; |
| 87 | 87 |
| 88 HostPortPair host_port(http_host_port_pair); | 88 HostPortPair host_port(http_host_port_pair); |
| 89 const HostMappingRules* mapping_rules = GetHostMappingRules(); | 89 const HostMappingRules* mapping_rules = GetHostMappingRules(); |
| 90 if (mapping_rules) | 90 if (mapping_rules) |
| 91 mapping_rules->RewriteHost(&host_port); | 91 mapping_rules->RewriteHost(&host_port); |
| 92 | 92 |
| 93 if (http_server_properties->HasAlternateProtocol(host_port)) { | 93 http_server_properties->AddAlternateProtocol( |
| 94 const AlternateProtocolInfo existing_alternate = | 94 host_port, port, protocol, probability); |
|
Ryan Hamilton
2014/11/03 19:00:30
Does this need to Clear() first? Otherwise it seem
Bence
2014/11/03 22:32:26
Previous behavior is that if an alternate protocol
Ryan Hamilton
2014/11/04 18:56:22
In the case of non-broken, the old code overwrite
Bence
2014/11/04 21:55:50
Done. FYI I had to create a new method in HttpSer
| |
| 95 http_server_properties->GetAlternateProtocol(host_port); | |
| 96 // If we think the alternate protocol is broken, don't change it. | |
| 97 if (existing_alternate.protocol == ALTERNATE_PROTOCOL_BROKEN) | |
| 98 return; | |
| 99 } | |
| 100 | |
| 101 http_server_properties->SetAlternateProtocol(host_port, port, protocol, | |
| 102 probability); | |
| 103 } | 95 } |
| 104 | 96 |
| 105 GURL HttpStreamFactory::ApplyHostMappingRules(const GURL& url, | 97 GURL HttpStreamFactory::ApplyHostMappingRules(const GURL& url, |
| 106 HostPortPair* endpoint) { | 98 HostPortPair* endpoint) { |
| 107 const HostMappingRules* mapping_rules = GetHostMappingRules(); | 99 const HostMappingRules* mapping_rules = GetHostMappingRules(); |
| 108 if (mapping_rules && mapping_rules->RewriteHost(endpoint)) { | 100 if (mapping_rules && mapping_rules->RewriteHost(endpoint)) { |
| 109 url::Replacements<char> replacements; | 101 url::Replacements<char> replacements; |
| 110 const std::string port_str = base::IntToString(endpoint->port()); | 102 const std::string port_str = base::IntToString(endpoint->port()); |
| 111 replacements.SetPort(port_str.c_str(), url::Component(0, port_str.size())); | 103 replacements.SetPort(port_str.c_str(), url::Component(0, port_str.size())); |
| 112 replacements.SetHost(endpoint->host().c_str(), | 104 replacements.SetHost(endpoint->host().c_str(), |
| 113 url::Component(0, endpoint->host().size())); | 105 url::Component(0, endpoint->host().size())); |
| 114 return url.ReplaceComponents(replacements); | 106 return url.ReplaceComponents(replacements); |
| 115 } | 107 } |
| 116 return url; | 108 return url; |
| 117 } | 109 } |
| 118 | 110 |
| 119 HttpStreamFactory::HttpStreamFactory() {} | 111 HttpStreamFactory::HttpStreamFactory() {} |
| 120 | 112 |
| 121 } // namespace net | 113 } // namespace net |
| OLD | NEW |