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

Unified Diff: net/http/http_stream_factory_impl_job.cc

Issue 10581020: Prevent requests for http://host:port/ from being sent over an existing spdy session to https://hos… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Actually rebase correctly Created 8 years, 6 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_impl_job.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_stream_factory_impl_job.cc
diff --git a/net/http/http_stream_factory_impl_job.cc b/net/http/http_stream_factory_impl_job.cc
index b88b622c19d76bac4a487c1ebeb5ede011019841..5ef3379151bcaa00d2e3d708dd102d2d56845f5e 100644
--- a/net/http/http_stream_factory_impl_job.cc
+++ b/net/http/http_stream_factory_impl_job.cc
@@ -241,6 +241,9 @@ void HttpStreamFactoryImpl::Job::GetSSLInfo() {
}
HostPortProxyPair HttpStreamFactoryImpl::Job::GetSpdySessionKey() const {
+ // In the case that we're using an HTTPS proxy for an HTTP url,
+ // we look for a SPDY session *to* the proxy, instead of to the
+ // origin server.
if (IsHttpsProxyAndHttpUrl()) {
return HostPortProxyPair(proxy_info_.proxy_server().host_port_pair(),
ProxyServer::Direct());
@@ -249,6 +252,17 @@ HostPortProxyPair HttpStreamFactoryImpl::Job::GetSpdySessionKey() const {
}
}
+bool HttpStreamFactoryImpl::Job::CanUseExistingSpdySession() const {
+ // We need to make sure that if a spdy session was created for
+ // https://somehost/ that we don't use that session for http://somehost:443/.
+ // The only time we can use an existing session is if the request URL is
+ // https (the normal case) or if we're connection to a SPDY proxy, or
+ // if we're running with force_spdy_always_. crbug.com/133176
+ return request_info_.url.SchemeIs("https") ||
+ proxy_info_.proxy_server().is_https() ||
+ force_spdy_always_;
+}
+
void HttpStreamFactoryImpl::Job::OnStreamReadyCallback() {
DCHECK(stream_.get());
DCHECK(!IsPreconnecting());
@@ -651,7 +665,7 @@ int HttpStreamFactoryImpl::Job::DoInitConnection() {
HostPortProxyPair spdy_session_key = GetSpdySessionKey();
scoped_refptr<SpdySession> spdy_session =
session_->spdy_session_pool()->GetIfExists(spdy_session_key, net_log_);
- if (spdy_session) {
+ if (spdy_session && CanUseExistingSpdySession()) {
// If we're preconnecting, but we already have a SpdySession, we don't
// actually need to preconnect any sockets, so we're done.
if (IsPreconnecting())
@@ -724,15 +738,17 @@ int HttpStreamFactoryImpl::Job::DoInitConnection() {
net_log_,
num_streams_);
} else {
+ // If we can't use a SPDY session, don't both checking for one after
+ // the hostname is resolved.
+ OnHostResolutionCallback resolution_callback = CanUseExistingSpdySession() ?
+ base::Bind(&Job::OnHostResolution, session_->spdy_session_pool(),
+ GetSpdySessionKey()) :
+ OnHostResolutionCallback();
return InitSocketHandleForHttpRequest(
origin_url_, request_info_.extra_headers, request_info_.load_flags,
request_info_.priority, session_, proxy_info_, ShouldForceSpdySSL(),
want_spdy_over_npn, server_ssl_config_, proxy_ssl_config_, net_log_,
- connection_.get(),
- //OnHostResolutionCallback(),
- base::Bind(&Job::OnHostResolution, session_->spdy_session_pool(),
- GetSpdySessionKey()),
- io_callback_);
+ connection_.get(), resolution_callback, io_callback_);
}
}
« no previous file with comments | « net/http/http_stream_factory_impl_job.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698