summaryrefslogtreecommitdiffstats
path: root/net/http
diff options
context:
space:
mode:
authorrtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-03 00:43:03 +0000
committerrtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-03 00:43:03 +0000
commitecf96e55e70451701e8ae39cd0a84565b6859f61 (patch)
tree4254054b0e27560a80c09fecf11efc34c723ffa9 /net/http
parent8005968c3e685f3960646d0f7b84f799c0acdbfa (diff)
downloadchromium_src-ecf96e55e70451701e8ae39cd0a84565b6859f61.zip
chromium_src-ecf96e55e70451701e8ae39cd0a84565b6859f61.tar.gz
chromium_src-ecf96e55e70451701e8ae39cd0a84565b6859f61.tar.bz2
SPDY - by default disable spdy/2.1 (flow control). It
can be enabled with command line flag --flow-control R=willchan TEST=network unittests BUG=116167 Review URL: http://codereview.chromium.org/9516009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124794 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http')
-rw-r--r--net/http/http_network_layer.cc11
-rw-r--r--net/http/http_network_transaction_unittest.cc44
-rw-r--r--net/http/http_stream_factory.cc36
-rw-r--r--net/http/http_stream_factory.h11
4 files changed, 64 insertions, 38 deletions
diff --git a/net/http/http_network_layer.cc b/net/http/http_network_layer.cc
index 672700f..0894af7 100644
--- a/net/http/http_network_layer.cc
+++ b/net/http/http_network_layer.cc
@@ -101,8 +101,7 @@ void HttpNetworkLayer::EnableSpdy(const std::string& mode) {
std::vector<std::string> next_protos;
next_protos.push_back("http/1.1");
next_protos.push_back("spdy/2");
- next_protos.push_back("spdy/2.1");
- HttpStreamFactory::set_next_protos(next_protos);
+ HttpStreamFactory::SetNextProtos(next_protos);
} else if (option == kEnableNpnHttpOnly) {
// Avoid alternate protocol in this case. Otherwise, browser will try SSL
// and then fallback to http. This introduces extra load.
@@ -110,14 +109,14 @@ void HttpNetworkLayer::EnableSpdy(const std::string& mode) {
std::vector<std::string> next_protos;
next_protos.push_back("http/1.1");
next_protos.push_back("http1.1");
- HttpStreamFactory::set_next_protos(next_protos);
+ HttpStreamFactory::SetNextProtos(next_protos);
} else if (option == kEnableVersionOne) {
spdy::SpdyFramer::set_protocol_version(1);
std::vector<std::string> next_protos;
// This is a temporary hack to pretend we support version 1.
next_protos.push_back("http/1.1");
next_protos.push_back("spdy/1");
- HttpStreamFactory::set_next_protos(next_protos);
+ HttpStreamFactory::SetNextProtos(next_protos);
} else if (option == kDisableAltProtocols) {
use_alt_protocols = false;
HttpStreamFactory::set_use_alternate_protocols(false);
@@ -126,11 +125,11 @@ void HttpNetworkLayer::EnableSpdy(const std::string& mode) {
next_protos.push_back("http/1.1");
next_protos.push_back("spdy/2");
next_protos.push_back("spdy/2.1");
- HttpStreamFactory::set_next_protos(next_protos);
+ HttpStreamFactory::SetNextProtos(next_protos);
} else if (option == kForceAltProtocols) {
PortAlternateProtocolPair pair;
pair.port = 443;
- pair.protocol = NPN_SPDY_21;
+ pair.protocol = NPN_SPDY_2;
HttpServerPropertiesImpl::ForceAlternateProtocol(pair);
} else if (option == kSingleDomain) {
SpdySessionPool::ForceSingleDomain();
diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc
index eb38f9c..45efec7 100644
--- a/net/http/http_network_transaction_unittest.cc
+++ b/net/http/http_network_transaction_unittest.cc
@@ -6494,8 +6494,8 @@ TEST_F(HttpNetworkTransactionTest, ChangeAuthRealms) {
}
TEST_F(HttpNetworkTransactionTest, HonorAlternateProtocolHeader) {
- HttpStreamFactory::set_next_protos(MakeNextProtos("foo", "bar", NULL));
HttpStreamFactory::set_use_alternate_protocols(true);
+ HttpStreamFactory::SetNextProtos(SpdyNextProtos());
SessionDependencies session_deps;
@@ -6551,7 +6551,7 @@ TEST_F(HttpNetworkTransactionTest, HonorAlternateProtocolHeader) {
EXPECT_TRUE(expected_alternate.Equals(alternate));
HttpStreamFactory::set_use_alternate_protocols(false);
- HttpStreamFactory::set_next_protos(std::vector<std::string>());
+ HttpStreamFactory::SetNextProtos(std::vector<std::string>());
}
TEST_F(HttpNetworkTransactionTest, MarkBrokenAlternateProtocolAndFallback) {
@@ -6865,7 +6865,7 @@ TEST_F(HttpNetworkTransactionTest, AlternateProtocolUnsafeBlocked) {
TEST_F(HttpNetworkTransactionTest, UseAlternateProtocolForNpnSpdy) {
HttpStreamFactory::set_use_alternate_protocols(true);
- HttpStreamFactory::set_next_protos(SpdyNextProtos());
+ HttpStreamFactory::SetNextProtos(SpdyNextProtos());
SessionDependencies session_deps;
HttpRequestInfo request;
@@ -6948,13 +6948,13 @@ TEST_F(HttpNetworkTransactionTest, UseAlternateProtocolForNpnSpdy) {
ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
EXPECT_EQ("hello!", response_data);
- HttpStreamFactory::set_next_protos(std::vector<std::string>());
+ HttpStreamFactory::SetNextProtos(std::vector<std::string>());
HttpStreamFactory::set_use_alternate_protocols(false);
}
TEST_F(HttpNetworkTransactionTest, AlternateProtocolWithSpdyLateBinding) {
HttpStreamFactory::set_use_alternate_protocols(true);
- HttpStreamFactory::set_next_protos(SpdyNextProtos());
+ HttpStreamFactory::SetNextProtos(SpdyNextProtos());
SessionDependencies session_deps;
HttpRequestInfo request;
@@ -7064,13 +7064,13 @@ TEST_F(HttpNetworkTransactionTest, AlternateProtocolWithSpdyLateBinding) {
ASSERT_EQ(OK, ReadTransaction(&trans3, &response_data));
EXPECT_EQ("hello!", response_data);
- HttpStreamFactory::set_next_protos(std::vector<std::string>());
+ HttpStreamFactory::SetNextProtos(std::vector<std::string>());
HttpStreamFactory::set_use_alternate_protocols(false);
}
TEST_F(HttpNetworkTransactionTest, StallAlternateProtocolForNpnSpdy) {
HttpStreamFactory::set_use_alternate_protocols(true);
- HttpStreamFactory::set_next_protos(SpdyNextProtos());
+ HttpStreamFactory::SetNextProtos(SpdyNextProtos());
SessionDependencies session_deps;
HttpRequestInfo request;
@@ -7138,7 +7138,7 @@ TEST_F(HttpNetworkTransactionTest, StallAlternateProtocolForNpnSpdy) {
ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
EXPECT_EQ("hello world", response_data);
- HttpStreamFactory::set_next_protos(std::vector<std::string>());
+ HttpStreamFactory::SetNextProtos(std::vector<std::string>());
HttpStreamFactory::set_use_alternate_protocols(false);
}
@@ -7193,7 +7193,7 @@ class CapturingProxyResolver : public ProxyResolver {
TEST_F(HttpNetworkTransactionTest, UseAlternateProtocolForTunneledNpnSpdy) {
HttpStreamFactory::set_use_alternate_protocols(true);
- HttpStreamFactory::set_next_protos(SpdyNextProtos());
+ HttpStreamFactory::SetNextProtos(SpdyNextProtos());
ProxyConfig proxy_config;
proxy_config.set_auto_detect(true);
@@ -7299,14 +7299,14 @@ TEST_F(HttpNetworkTransactionTest, UseAlternateProtocolForTunneledNpnSpdy) {
EXPECT_EQ("https://www.google.com/",
capturing_proxy_resolver->resolved()[1].spec());
- HttpStreamFactory::set_next_protos(std::vector<std::string>());
+ HttpStreamFactory::SetNextProtos(std::vector<std::string>());
HttpStreamFactory::set_use_alternate_protocols(false);
}
TEST_F(HttpNetworkTransactionTest,
UseAlternateProtocolForNpnSpdyWithExistingSpdySession) {
HttpStreamFactory::set_use_alternate_protocols(true);
- HttpStreamFactory::set_next_protos(SpdyNextProtos());
+ HttpStreamFactory::SetNextProtos(SpdyNextProtos());
SessionDependencies session_deps;
HttpRequestInfo request;
@@ -7417,7 +7417,7 @@ TEST_F(HttpNetworkTransactionTest,
ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
EXPECT_EQ("hello!", response_data);
- HttpStreamFactory::set_next_protos(std::vector<std::string>());
+ HttpStreamFactory::SetNextProtos(std::vector<std::string>());
HttpStreamFactory::set_use_alternate_protocols(false);
}
@@ -8138,7 +8138,7 @@ TEST_F(HttpNetworkTransactionTest,
// npn is negotiated.
TEST_F(HttpNetworkTransactionTest, NpnWithHttpOverSSL) {
HttpStreamFactory::set_use_alternate_protocols(true);
- HttpStreamFactory::set_next_protos(
+ HttpStreamFactory::SetNextProtos(
MakeNextProtos("http/1.1", "http1.1", NULL));
SessionDependencies session_deps;
HttpRequestInfo request;
@@ -8192,7 +8192,7 @@ TEST_F(HttpNetworkTransactionTest, NpnWithHttpOverSSL) {
EXPECT_FALSE(response->was_fetched_via_spdy);
EXPECT_TRUE(response->was_npn_negotiated);
- HttpStreamFactory::set_next_protos(std::vector<std::string>());
+ HttpStreamFactory::SetNextProtos(std::vector<std::string>());
HttpStreamFactory::set_use_alternate_protocols(false);
}
@@ -8201,7 +8201,7 @@ TEST_F(HttpNetworkTransactionTest, SpdyPostNPNServerHangup) {
// followed by an immediate server closing of the socket.
// Fix crash: http://crbug.com/46369
HttpStreamFactory::set_use_alternate_protocols(true);
- HttpStreamFactory::set_next_protos(SpdyNextProtos());
+ HttpStreamFactory::SetNextProtos(SpdyNextProtos());
SessionDependencies session_deps;
HttpRequestInfo request;
@@ -8236,7 +8236,7 @@ TEST_F(HttpNetworkTransactionTest, SpdyPostNPNServerHangup) {
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_EQ(ERR_CONNECTION_CLOSED, callback.WaitForResult());
- HttpStreamFactory::set_next_protos(std::vector<std::string>());
+ HttpStreamFactory::SetNextProtos(std::vector<std::string>());
HttpStreamFactory::set_use_alternate_protocols(false);
}
@@ -8244,7 +8244,7 @@ TEST_F(HttpNetworkTransactionTest, SpdyAlternateProtocolThroughProxy) {
// This test ensures that the URL passed into the proxy is upgraded
// to https when doing an Alternate Protocol upgrade.
HttpStreamFactory::set_use_alternate_protocols(true);
- HttpStreamFactory::set_next_protos(
+ HttpStreamFactory::SetNextProtos(
MakeNextProtos(
"http/1.1", "http1.1", "spdy/2.1", "spdy/2", "spdy", NULL));
@@ -8386,7 +8386,7 @@ TEST_F(HttpNetworkTransactionTest, SpdyAlternateProtocolThroughProxy) {
EXPECT_EQ("https", request_url.scheme());
EXPECT_EQ("www.google.com", request_url.host());
- HttpStreamFactory::set_next_protos(std::vector<std::string>());
+ HttpStreamFactory::SetNextProtos(std::vector<std::string>());
HttpStreamFactory::set_use_alternate_protocols(false);
}
@@ -9029,7 +9029,7 @@ void IPPoolingAddAlias(MockCachingHostResolver* host_resolver,
TEST_F(HttpNetworkTransactionTest, UseIPConnectionPooling) {
HttpStreamFactory::set_use_alternate_protocols(true);
- HttpStreamFactory::set_next_protos(SpdyNextProtos());
+ HttpStreamFactory::SetNextProtos(SpdyNextProtos());
// Set up a special HttpNetworkSession with a MockCachingHostResolver.
SessionDependencies session_deps;
@@ -9133,7 +9133,7 @@ TEST_F(HttpNetworkTransactionTest, UseIPConnectionPooling) {
ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data));
EXPECT_EQ("hello!", response_data);
- HttpStreamFactory::set_next_protos(std::vector<std::string>());
+ HttpStreamFactory::SetNextProtos(std::vector<std::string>());
HttpStreamFactory::set_use_alternate_protocols(false);
}
@@ -9180,7 +9180,7 @@ class OneTimeCachingHostResolver : public net::HostResolver {
TEST_F(HttpNetworkTransactionTest,
UseIPConnectionPoolingWithHostCacheExpiration) {
HttpStreamFactory::set_use_alternate_protocols(true);
- HttpStreamFactory::set_next_protos(SpdyNextProtos());
+ HttpStreamFactory::SetNextProtos(SpdyNextProtos());
// Set up a special HttpNetworkSession with a OneTimeCachingHostResolver.
SessionDependencies session_deps;
@@ -9283,7 +9283,7 @@ TEST_F(HttpNetworkTransactionTest,
ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data));
EXPECT_EQ("hello!", response_data);
- HttpStreamFactory::set_next_protos(std::vector<std::string>());
+ HttpStreamFactory::SetNextProtos(std::vector<std::string>());
HttpStreamFactory::set_use_alternate_protocols(false);
}
diff --git a/net/http/http_stream_factory.cc b/net/http/http_stream_factory.cc
index 82d8449..6d0fc31 100644
--- a/net/http/http_stream_factory.cc
+++ b/net/http/http_stream_factory.cc
@@ -10,7 +10,6 @@
#include "googleurl/src/gurl.h"
#include "net/base/host_mapping_rules.h"
#include "net/base/host_port_pair.h"
-#include "net/http/http_server_properties.h"
namespace net {
@@ -22,6 +21,8 @@ const HostMappingRules* HttpStreamFactory::host_mapping_rules_ = NULL;
// static
std::vector<std::string>* HttpStreamFactory::next_protos_ = NULL;
// static
+bool HttpStreamFactory::enabled_protocols_[NUM_ALTERNATE_PROTOCOLS];
+// static
bool HttpStreamFactory::spdy_enabled_ = true;
// static
bool HttpStreamFactory::use_alternate_protocols_ = false;
@@ -56,6 +57,8 @@ void HttpStreamFactory::ResetStaticSettingsToInit() {
force_spdy_always_ = false;
forced_spdy_exclusions_ = NULL;
ignore_certificate_errors_ = false;
+ for (int i = 0; i < NUM_ALTERNATE_PROTOCOLS; ++i)
+ enabled_protocols_[i] = false;
}
void HttpStreamFactory::ProcessAlternateProtocol(
@@ -81,10 +84,11 @@ void HttpStreamFactory::ProcessAlternateProtocol(
}
AlternateProtocol protocol = ALTERNATE_PROTOCOL_BROKEN;
- // We skip NPN_SPDY_1 here, because we've rolled the protocol version to 2.
- for (int i = NPN_SPDY_2; i < NUM_ALTERNATE_PROTOCOLS; ++i) {
- if (port_protocol_vector[1] == kAlternateProtocolStrings[i])
+ for (int i = 0; i < NUM_ALTERNATE_PROTOCOLS; ++i) {
+ if (enabled_protocols_[i] &&
+ port_protocol_vector[1] == kAlternateProtocolStrings[i]) {
protocol = static_cast<AlternateProtocol>(i);
+ }
}
if (protocol == ALTERNATE_PROTOCOL_BROKEN) {
@@ -145,6 +149,30 @@ bool HttpStreamFactory::HasSpdyExclusion(const HostPortPair& endpoint) {
}
// static
+void HttpStreamFactory::SetNextProtos(const std::vector<std::string>& value) {
+ if (!next_protos_)
+ next_protos_ = new std::vector<std::string>;
+
+ *next_protos_ = value;
+
+ for (uint32 i = 0; i < NUM_ALTERNATE_PROTOCOLS; ++i)
+ enabled_protocols_[i] = false;
+
+ // TODO(rtenneti): bug 116575 - consider using same strings/enums for SPDY
+ // versions in next_protos and kAlternateProtocolStrings.
+ for (uint32 i = 0; i < value.size(); ++i) {
+ if (value[i] == "spdy/1") {
+ enabled_protocols_[NPN_SPDY_1] = true;
+ } else if (value[i] == "spdy/2") {
+ enabled_protocols_[NPN_SPDY_2] = true;
+ } else if (value[i] == "spdy/2.1") {
+ enabled_protocols_[NPN_SPDY_21] = true;
+ }
+ }
+ enabled_protocols_[NPN_SPDY_1] = false;
+}
+
+// static
void HttpStreamFactory::SetHostMappingRules(const std::string& rules) {
HostMappingRules* host_mapping_rules = new HostMappingRules;
host_mapping_rules->SetRulesFromString(rules);
diff --git a/net/http/http_stream_factory.h b/net/http/http_stream_factory.h
index c119cf2..8c726bb 100644
--- a/net/http/http_stream_factory.h
+++ b/net/http/http_stream_factory.h
@@ -15,6 +15,7 @@
#include "net/base/completion_callback.h"
#include "net/base/load_states.h"
#include "net/base/net_export.h"
+#include "net/http/http_server_properties.h"
#include "net/socket/ssl_client_socket.h"
class GURL;
@@ -229,12 +230,9 @@ class NET_EXPORT HttpStreamFactory {
// Check if a HostPortPair is excluded from using spdy.
static bool HasSpdyExclusion(const HostPortPair& endpoint);
- // Sets the next protocol negotiation value used during the SSL handshake.
- static void set_next_protos(const std::vector<std::string>& value) {
- if (!next_protos_)
- next_protos_ = new std::vector<std::string>;
- *next_protos_ = value;
- }
+ // Sets the protocols supported by NPN (next protocol negotiation) during the
+ // SSL handshake as well as by HTTP Alternate-Protocol.
+ static void SetNextProtos(const std::vector<std::string>& value);
static bool has_next_protos() { return next_protos_ != NULL; }
static const std::vector<std::string>& next_protos() {
return *next_protos_;
@@ -274,6 +272,7 @@ class NET_EXPORT HttpStreamFactory {
static const HostMappingRules* host_mapping_rules_;
static std::vector<std::string>* next_protos_;
+ static bool enabled_protocols_[NUM_ALTERNATE_PROTOCOLS];
static bool spdy_enabled_;
static bool use_alternate_protocols_;
static bool force_spdy_over_ssl_;