Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(798)

Unified Diff: net/http/http_stream_factory_impl.cc

Issue 665083009: ABANDONED Handle multiple AlternateProtocols for each HostPortPair. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Re: 18. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/http_stream_factory.cc ('k') | net/http/http_stream_factory_impl_job.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..819acee946d1a53bec24a28bd666639a0b642b96 100644
--- a/net/http/http_stream_factory_impl.cc
+++ b/net/http/http_stream_factory_impl.cc
@@ -185,54 +185,53 @@ 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 (const AlternateProtocol& alternate : alternate_protocols) {
+ 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) {
« no previous file with comments | « net/http/http_stream_factory.cc ('k') | net/http/http_stream_factory_impl_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698