| 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_impl.h" | 5 #include "net/http/http_stream_factory_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 | 176 |
| 177 AlternativeService HttpStreamFactoryImpl::GetAlternativeServiceFor( | 177 AlternativeService HttpStreamFactoryImpl::GetAlternativeServiceFor( |
| 178 const HttpRequestInfo& request_info, | 178 const HttpRequestInfo& request_info, |
| 179 HttpStreamRequest::Delegate* delegate, | 179 HttpStreamRequest::Delegate* delegate, |
| 180 HttpStreamRequest::StreamType stream_type) { | 180 HttpStreamRequest::StreamType stream_type) { |
| 181 GURL original_url = request_info.url; | 181 GURL original_url = request_info.url; |
| 182 | 182 |
| 183 if (original_url.SchemeIs("ftp")) | 183 if (original_url.SchemeIs("ftp")) |
| 184 return AlternativeService(); | 184 return AlternativeService(); |
| 185 | 185 |
| 186 HostPortPair origin = HostPortPair::FromURL(original_url); | 186 url::SchemeHostPort origin(original_url); |
| 187 HttpServerProperties& http_server_properties = | 187 HttpServerProperties& http_server_properties = |
| 188 *session_->http_server_properties(); | 188 *session_->http_server_properties(); |
| 189 const AlternativeServiceVector alternative_service_vector = | 189 const AlternativeServiceVector alternative_service_vector = |
| 190 http_server_properties.GetAlternativeServices(origin); | 190 http_server_properties.GetAlternativeServices(origin); |
| 191 if (alternative_service_vector.empty()) | 191 if (alternative_service_vector.empty()) |
| 192 return AlternativeService(); | 192 return AlternativeService(); |
| 193 | 193 |
| 194 bool quic_advertised = false; | 194 bool quic_advertised = false; |
| 195 bool quic_all_broken = true; | 195 bool quic_all_broken = true; |
| 196 | 196 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 219 // idea already, but with Alternate-Protocol, it provides the ability for a | 219 // idea already, but with Alternate-Protocol, it provides the ability for a |
| 220 // single user on a multi-user system to hijack the alternate protocol. | 220 // single user on a multi-user system to hijack the alternate protocol. |
| 221 // These systems also enforce ports <1024 as restricted ports. So don't | 221 // These systems also enforce ports <1024 as restricted ports. So don't |
| 222 // allow protocol upgrades to user-controllable ports. | 222 // allow protocol upgrades to user-controllable ports. |
| 223 const int kUnrestrictedPort = 1024; | 223 const int kUnrestrictedPort = 1024; |
| 224 if (!session_->params().enable_user_alternate_protocol_ports && | 224 if (!session_->params().enable_user_alternate_protocol_ports && |
| 225 (alternative_service.port >= kUnrestrictedPort && | 225 (alternative_service.port >= kUnrestrictedPort && |
| 226 origin.port() < kUnrestrictedPort)) | 226 origin.port() < kUnrestrictedPort)) |
| 227 continue; | 227 continue; |
| 228 | 228 |
| 229 origin.set_port(alternative_service.port); | |
| 230 if (alternative_service.protocol >= NPN_SPDY_MINIMUM_VERSION && | 229 if (alternative_service.protocol >= NPN_SPDY_MINIMUM_VERSION && |
| 231 alternative_service.protocol <= NPN_SPDY_MAXIMUM_VERSION) { | 230 alternative_service.protocol <= NPN_SPDY_MAXIMUM_VERSION) { |
| 232 if (!HttpStreamFactory::spdy_enabled()) | 231 if (!HttpStreamFactory::spdy_enabled()) |
| 233 continue; | 232 continue; |
| 234 | 233 |
| 235 // Cache this entry if we don't have a non-broken Alt-Svc yet. | 234 // Cache this entry if we don't have a non-broken Alt-Svc yet. |
| 236 if (first_alternative_service.protocol == | 235 if (first_alternative_service.protocol == |
| 237 UNINITIALIZED_ALTERNATE_PROTOCOL) | 236 UNINITIALIZED_ALTERNATE_PROTOCOL) |
| 238 first_alternative_service = alternative_service; | 237 first_alternative_service = alternative_service; |
| 239 continue; | 238 continue; |
| 240 } | 239 } |
| 241 | 240 |
| 242 DCHECK_EQ(QUIC, alternative_service.protocol); | 241 DCHECK_EQ(QUIC, alternative_service.protocol); |
| 243 quic_all_broken = false; | 242 quic_all_broken = false; |
| 244 if (!session_->params().enable_quic) | 243 if (!session_->params().enable_quic) |
| 245 continue; | 244 continue; |
| 246 | 245 |
| 247 if (!IsQuicWhitelistedForHost(origin.host())) | 246 if (!IsQuicWhitelistedForHost(origin.host())) |
| 248 continue; | 247 continue; |
| 249 | 248 |
| 250 if (stream_type == HttpStreamRequest::BIDIRECTIONAL_STREAM && | 249 if (stream_type == HttpStreamRequest::BIDIRECTIONAL_STREAM && |
| 251 session_->params().quic_disable_bidirectional_streams) { | 250 session_->params().quic_disable_bidirectional_streams) { |
| 252 continue; | 251 continue; |
| 253 } | 252 } |
| 254 | 253 |
| 255 if (session_->quic_stream_factory()->IsQuicDisabled(origin.port())) | 254 if (session_->quic_stream_factory()->IsQuicDisabled( |
| 255 alternative_service.port)) |
| 256 continue; | 256 continue; |
| 257 | 257 |
| 258 if (!original_url.SchemeIs("https")) | 258 if (!original_url.SchemeIs("https")) |
| 259 continue; | 259 continue; |
| 260 | 260 |
| 261 // Check whether there's an existing session to use for this QUIC Alt-Svc. | 261 // Check whether there's an existing session to use for this QUIC Alt-Svc. |
| 262 HostPortPair destination = alternative_service.host_port_pair(); | 262 HostPortPair destination = alternative_service.host_port_pair(); |
| 263 std::string origin_host = | 263 std::string origin_host = |
| 264 ApplyHostMappingRules(request_info.url, &destination).host(); | 264 ApplyHostMappingRules(request_info.url, &destination).host(); |
| 265 QuicServerId server_id(destination, request_info.privacy_mode); | 265 QuicServerId server_id(destination, request_info.privacy_mode); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 return true; | 358 return true; |
| 359 | 359 |
| 360 if (session_->params().transport_security_state->IsGooglePinnedHost(host)) | 360 if (session_->params().transport_security_state->IsGooglePinnedHost(host)) |
| 361 return true; | 361 return true; |
| 362 | 362 |
| 363 return ContainsKey(session_->params().quic_host_whitelist, | 363 return ContainsKey(session_->params().quic_host_whitelist, |
| 364 base::ToLowerASCII(host)); | 364 base::ToLowerASCII(host)); |
| 365 } | 365 } |
| 366 | 366 |
| 367 } // namespace net | 367 } // namespace net |
| OLD | NEW |