Chromium Code Reviews| Index: net/http/http_stream_factory_impl.cc |
| diff --git a/net/http/http_stream_factory_impl.cc b/net/http/http_stream_factory_impl.cc |
| index 235122d2e834ae363f77203bc88277c5ad2c96e5..353834cc04961b09658df3b9e26e43f9b68be789 100644 |
| --- a/net/http/http_stream_factory_impl.cc |
| +++ b/net/http/http_stream_factory_impl.cc |
| @@ -185,54 +185,54 @@ AlternateProtocolInfo HttpStreamFactoryImpl::GetAlternateProtocolRequestFor( |
| HostPortPair origin = HostPortPair::FromURL(original_url); |
| HttpServerProperties& http_server_properties = |
| *session_->http_server_properties(); |
| - const AlternateProtocolInfo alternate = |
| - http_server_properties.GetAlternateProtocol(origin); |
| - |
| - if (alternate.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) |
| - return kNoAlternateProtocol; |
| - if (alternate.is_broken) { |
| - HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_BROKEN); |
| - return kNoAlternateProtocol; |
| - } |
| - if (!IsAlternateProtocolValid(alternate.protocol)) { |
| - NOTREACHED(); |
| - return kNoAlternateProtocol; |
| - } |
| - |
| - // Some shared unix systems may have user home directories (like |
| - // http://foo.com/~mike) which allow users to emit headers. This is a bad |
| - // idea already, but with Alternate-Protocol, it provides the ability for a |
| - // single user on a multi-user system to hijack the alternate protocol. |
| - // These systems also enforce ports <1024 as restricted ports. So don't |
| - // allow protocol upgrades to user-controllable ports. |
| - const int kUnrestrictedPort = 1024; |
| - if (!session_->params().enable_user_alternate_protocol_ports && |
| - (alternate.port >= kUnrestrictedPort && |
| - origin.port() < kUnrestrictedPort)) |
| + AlternateProtocols alternate_protocols = |
| + http_server_properties.GetAlternateProtocols(origin); |
| + if (alternate_protocols.empty()) |
| return kNoAlternateProtocol; |
| + for (AlternateProtocols::iterator alternate = alternate_protocols.begin(); |
| + alternate != alternate_protocols.end(); ++alternate) { |
|
Ryan Hamilton
2015/02/27 18:20:48
Can you use a C++ range based for loop here?
Bence
2015/02/27 19:31:41
Done.
|
| + if (alternate->is_broken) { |
| + HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_BROKEN); |
| + continue; |
| + } |
| - origin.set_port(alternate.port); |
| - if (alternate.protocol >= NPN_SPDY_MINIMUM_VERSION && |
| - alternate.protocol <= NPN_SPDY_MAXIMUM_VERSION) { |
| - if (!HttpStreamFactory::spdy_enabled()) |
| - return kNoAlternateProtocol; |
| - |
| - if (session_->HasSpdyExclusion(origin)) |
| - return kNoAlternateProtocol; |
| - |
| - *alternate_url = UpgradeUrlToHttps(original_url, alternate.port); |
| - } else { |
| - DCHECK_EQ(QUIC, alternate.protocol); |
| - if (!session_->params().enable_quic) |
| - return kNoAlternateProtocol; |
| - |
| - // TODO(rch): Figure out how to make QUIC iteract with PAC |
| - // scripts. By not re-writing the URL, we will query the PAC script |
| - // for the proxy to use to reach the original URL via TCP. But |
| - // the alternate request will be going via UDP to a different port. |
| - *alternate_url = original_url; |
| + // Some shared unix systems may have user home directories (like |
| + // http://foo.com/~mike) which allow users to emit headers. This is a bad |
| + // idea already, but with Alternate-Protocol, it provides the ability for a |
| + // single user on a multi-user system to hijack the alternate protocol. |
| + // These systems also enforce ports <1024 as restricted ports. So don't |
| + // allow protocol upgrades to user-controllable ports. |
| + const int kUnrestrictedPort = 1024; |
| + if (!session_->params().enable_user_alternate_protocol_ports && |
| + (alternate->port >= kUnrestrictedPort && |
| + origin.port() < kUnrestrictedPort)) |
| + continue; |
| + |
| + origin.set_port(alternate->port); |
| + if (alternate->protocol >= NPN_SPDY_MINIMUM_VERSION && |
| + alternate->protocol <= NPN_SPDY_MAXIMUM_VERSION) { |
| + if (!HttpStreamFactory::spdy_enabled()) |
| + continue; |
| + |
| + if (session_->HasSpdyExclusion(origin)) |
| + continue; |
| + |
| + *alternate_url = UpgradeUrlToHttps(original_url, alternate->port); |
| + return *alternate; |
| + } else { |
| + DCHECK_EQ(QUIC, alternate->protocol); |
| + if (!session_->params().enable_quic) |
| + continue; |
| + |
| + // TODO(rch): Figure out how to make QUIC iteract with PAC |
| + // scripts. By not re-writing the URL, we will query the PAC script |
| + // for the proxy to use to reach the original URL via TCP. But |
| + // the alternate request will be going via UDP to a different port. |
| + *alternate_url = original_url; |
| + return *alternate; |
| + } |
| } |
| - return alternate; |
| + return kNoAlternateProtocol; |
| } |
| void HttpStreamFactoryImpl::OrphanJob(Job* job, const Request* request) { |