diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/http/http_network_layer.cc | 5 | ||||
-rw-r--r-- | net/http/http_network_transaction_unittest.cc | 94 | ||||
-rw-r--r-- | net/http/http_pipelined_host_impl_unittest.cc | 6 | ||||
-rw-r--r-- | net/http/http_proxy_client_socket_pool_unittest.cc | 4 | ||||
-rw-r--r-- | net/http/http_server_properties_impl_unittest.cc | 8 | ||||
-rw-r--r-- | net/http/http_stream_factory_impl.cc | 4 | ||||
-rw-r--r-- | net/socket/ssl_client_socket_pool_unittest.cc | 24 | ||||
-rw-r--r-- | net/spdy/spdy_network_transaction_unittest.cc | 40 | ||||
-rw-r--r-- | net/spdy/spdy_session.cc | 19 | ||||
-rw-r--r-- | net/spdy/spdy_session.h | 16 |
10 files changed, 129 insertions, 91 deletions
diff --git a/net/http/http_network_layer.cc b/net/http/http_network_layer.cc index 5690f6d..672700f 100644 --- a/net/http/http_network_layer.cc +++ b/net/http/http_network_layer.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -101,6 +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); } else if (option == kEnableNpnHttpOnly) { // Avoid alternate protocol in this case. Otherwise, browser will try SSL @@ -129,7 +130,7 @@ void HttpNetworkLayer::EnableSpdy(const std::string& mode) { } else if (option == kForceAltProtocols) { PortAlternateProtocolPair pair; pair.port = 443; - pair.protocol = NPN_SPDY_2; + pair.protocol = NPN_SPDY_21; 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 8dda238..c522e8b 100644 --- a/net/http/http_network_transaction_unittest.cc +++ b/net/http/http_network_transaction_unittest.cc @@ -377,7 +377,7 @@ CaptureGroupNameSSLSocketPool::CaptureGroupNameSocketPool( // This is the expected return from a current server advertising SPDY. static const char kAlternateProtocolHttpHeader[] = - "Alternate-Protocol: 443:npn-spdy/2\r\n\r\n"; + "Alternate-Protocol: 443:npn-spdy/2.1\r\n\r\n"; // Helper functions for validating that AuthChallengeInfo's are correctly // configured for common cases. @@ -2541,9 +2541,9 @@ TEST_F(HttpNetworkTransactionTest, HttpsProxySpdyGet) { SSLSocketDataProvider ssl(true, OK); ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; - ssl.next_proto = "spdy/2"; + ssl.next_proto = "spdy/2.1"; ssl.was_npn_negotiated = true; - ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; + ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); TestCompletionCallback callback1; @@ -2628,9 +2628,9 @@ TEST_F(HttpNetworkTransactionTest, HttpsProxySpdyGetWithProxyAuth) { SSLSocketDataProvider ssl(true, OK); ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; - ssl.next_proto = "spdy/2"; + ssl.next_proto = "spdy/2.1"; ssl.was_npn_negotiated = true; - ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; + ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); TestCompletionCallback callback1; @@ -2723,9 +2723,9 @@ TEST_F(HttpNetworkTransactionTest, HttpsProxySpdyConnectHttps) { SSLSocketDataProvider ssl(true, OK); ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; - ssl.next_proto = "spdy/2"; + ssl.next_proto = "spdy/2.1"; ssl.was_npn_negotiated = true; - ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; + ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); SSLSocketDataProvider ssl2(true, OK); ssl2.was_npn_negotiated = false; @@ -2798,15 +2798,15 @@ TEST_F(HttpNetworkTransactionTest, HttpsProxySpdyConnectSpdy) { SSLSocketDataProvider ssl(true, OK); ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; - ssl.next_proto = "spdy/2"; + ssl.next_proto = "spdy/2.1"; ssl.was_npn_negotiated = true; - ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; + ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); SSLSocketDataProvider ssl2(true, OK); ssl2.next_proto_status = SSLClientSocket::kNextProtoNegotiated; - ssl2.next_proto = "spdy/2"; + ssl2.next_proto = "spdy/2.1"; ssl2.was_npn_negotiated = true; - ssl2.protocol_negotiated = SSLClientSocket::kProtoSPDY2; + ssl2.protocol_negotiated = SSLClientSocket::kProtoSPDY21; session_deps.socket_factory.AddSSLSocketDataProvider(&ssl2); TestCompletionCallback callback1; @@ -2867,15 +2867,15 @@ TEST_F(HttpNetworkTransactionTest, HttpsProxySpdyConnectFailure) { SSLSocketDataProvider ssl(true, OK); ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; - ssl.next_proto = "spdy/2"; + ssl.next_proto = "spdy/2.1"; ssl.was_npn_negotiated = true; - ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; + ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); SSLSocketDataProvider ssl2(true, OK); ssl2.next_proto_status = SSLClientSocket::kNextProtoNegotiated; - ssl2.next_proto = "spdy/2"; + ssl2.next_proto = "spdy/2.1"; ssl2.was_npn_negotiated = true; - ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; + ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; session_deps.socket_factory.AddSSLSocketDataProvider(&ssl2); TestCompletionCallback callback1; @@ -5269,9 +5269,9 @@ TEST_F(HttpNetworkTransactionTest, RedirectOfHttpsConnectViaSpdyProxy) { data_writes, arraysize(data_writes))); SSLSocketDataProvider proxy_ssl(true, OK); // SSL to the proxy proxy_ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; - proxy_ssl.next_proto = "spdy/2"; + proxy_ssl.next_proto = "spdy/2.1"; proxy_ssl.was_npn_negotiated = true; - proxy_ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; + proxy_ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; session_deps.socket_factory.AddSocketDataProvider(data.get()); session_deps.socket_factory.AddSSLSocketDataProvider(&proxy_ssl); @@ -5389,9 +5389,9 @@ TEST_F(HttpNetworkTransactionTest, ErrorResponseTofHttpsConnectViaSpdyProxy) { data_writes, arraysize(data_writes))); SSLSocketDataProvider proxy_ssl(true, OK); // SSL to the proxy proxy_ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; - proxy_ssl.next_proto = "spdy/2"; + proxy_ssl.next_proto = "spdy/2.1"; proxy_ssl.was_npn_negotiated = true; - proxy_ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; + proxy_ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; session_deps.socket_factory.AddSocketDataProvider(data.get()); session_deps.socket_factory.AddSSLSocketDataProvider(&proxy_ssl); @@ -6145,7 +6145,7 @@ scoped_refptr<HttpNetworkSession> SetupSessionForGroupNameTests( session->http_server_properties(); http_server_properties->SetAlternateProtocol( HostPortPair("host.with.alternate", 80), 443, - NPN_SPDY_2); + NPN_SPDY_21); return session; } @@ -7085,7 +7085,7 @@ TEST_F(HttpNetworkTransactionTest, HonorAlternateProtocolHeader) { http_server_properties.GetAlternateProtocol(http_host_port_pair); PortAlternateProtocolPair expected_alternate; expected_alternate.port = 443; - expected_alternate.protocol = NPN_SPDY_2; + expected_alternate.protocol = NPN_SPDY_21; EXPECT_TRUE(expected_alternate.Equals(alternate)); HttpStreamFactory::set_use_alternate_protocols(false); @@ -7124,7 +7124,7 @@ TEST_F(HttpNetworkTransactionTest, MarkBrokenAlternateProtocolAndFallback) { http_server_properties->SetAlternateProtocol( HostPortPair::FromURL(request.url), 666 /* port is ignored by MockConnect anyway */, - NPN_SPDY_2); + NPN_SPDY_21); scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); TestCompletionCallback callback; @@ -7186,7 +7186,7 @@ TEST_F(HttpNetworkTransactionTest, AlternateProtocolPortRestrictedBlocked) { http_server_properties->SetAlternateProtocol( HostPortPair::FromURL(restricted_port_request.url), kUnrestrictedAlternatePort, - NPN_SPDY_2); + NPN_SPDY_21); scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); TestCompletionCallback callback; @@ -7235,7 +7235,7 @@ TEST_F(HttpNetworkTransactionTest, AlternateProtocolPortRestrictedAllowed) { http_server_properties->SetAlternateProtocol( HostPortPair::FromURL(restricted_port_request.url), kRestrictedAlternatePort, - NPN_SPDY_2); + NPN_SPDY_21); scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); TestCompletionCallback callback; @@ -7284,7 +7284,7 @@ TEST_F(HttpNetworkTransactionTest, AlternateProtocolPortUnrestrictedAllowed1) { http_server_properties->SetAlternateProtocol( HostPortPair::FromURL(unrestricted_port_request.url), kRestrictedAlternatePort, - NPN_SPDY_2); + NPN_SPDY_21); scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); TestCompletionCallback callback; @@ -7333,7 +7333,7 @@ TEST_F(HttpNetworkTransactionTest, AlternateProtocolPortUnrestrictedAllowed2) { http_server_properties->SetAlternateProtocol( HostPortPair::FromURL(unrestricted_port_request.url), kUnrestrictedAlternatePort, - NPN_SPDY_2); + NPN_SPDY_21); scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); TestCompletionCallback callback; @@ -7424,9 +7424,9 @@ TEST_F(HttpNetworkTransactionTest, UseAlternateProtocolForNpnSpdy) { SSLSocketDataProvider ssl(true, OK); ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; - ssl.next_proto = "spdy/2"; + ssl.next_proto = "spdy/2.1"; ssl.was_npn_negotiated = true; - ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; + ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); @@ -7526,9 +7526,9 @@ TEST_F(HttpNetworkTransactionTest, AlternateProtocolWithSpdyLateBinding) { SSLSocketDataProvider ssl(true, OK); ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; - ssl.next_proto = "spdy/2"; + ssl.next_proto = "spdy/2.1"; ssl.was_npn_negotiated = true; - ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; + ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); scoped_ptr<spdy::SpdyFrame> req1(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); @@ -7635,9 +7635,9 @@ TEST_F(HttpNetworkTransactionTest, StallAlternateProtocolForNpnSpdy) { SSLSocketDataProvider ssl(true, OK); ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; - ssl.next_proto = "spdy/2"; + ssl.next_proto = "spdy/2.1"; ssl.was_npn_negotiated = true; - ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; + ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); MockConnect never_finishing_connect(false, ERR_IO_PENDING); @@ -7770,9 +7770,9 @@ TEST_F(HttpNetworkTransactionTest, UseAlternateProtocolForTunneledNpnSpdy) { SSLSocketDataProvider ssl(true, OK); ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; - ssl.next_proto = "spdy/2"; + ssl.next_proto = "spdy/2.1"; ssl.was_npn_negotiated = true; - ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; + ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); @@ -7877,9 +7877,9 @@ TEST_F(HttpNetworkTransactionTest, SSLSocketDataProvider ssl(true, OK); ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; - ssl.next_proto = "spdy/2"; + ssl.next_proto = "spdy/2.1"; ssl.was_npn_negotiated = true; - ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; + ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); // Make sure we use ssl for spdy here. SpdySession::SetSSLMode(true); @@ -8764,9 +8764,9 @@ TEST_F(HttpNetworkTransactionTest, SpdyPostNPNServerHangup) { SSLSocketDataProvider ssl(true, OK); ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; - ssl.next_proto = "spdy/2"; + ssl.next_proto = "spdy/2.1"; ssl.was_npn_negotiated = true; - ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; + ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); @@ -8827,7 +8827,7 @@ TEST_F(HttpNetworkTransactionTest, SpdyAlternateProtocolThroughProxy) { MockRead data_reads_1[] = { MockRead(false, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), MockRead("HTTP/1.1 200 OK\r\n" - "Alternate-Protocol: 443:npn-spdy/2\r\n" + "Alternate-Protocol: 443:npn-spdy/2.1\r\n" "Proxy-Connection: close\r\n" "\r\n"), }; @@ -8920,9 +8920,9 @@ TEST_F(HttpNetworkTransactionTest, SpdyAlternateProtocolThroughProxy) { SSLSocketDataProvider ssl(true, OK); ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; - ssl.next_proto = "spdy/2"; + ssl.next_proto = "spdy/2.1"; ssl.was_npn_negotiated = true; - ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; + ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; MockConnect never_finishing_connect(false, ERR_IO_PENDING); StaticSocketDataProvider hanging_non_alternate_protocol_socket( @@ -9207,9 +9207,9 @@ TEST_F(HttpNetworkTransactionTest, PreconnectWithExistingSpdySession) { SSLSocketDataProvider ssl(true, OK); ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; - ssl.next_proto = "spdy/2"; + ssl.next_proto = "spdy/2.1"; ssl.was_npn_negotiated = true; - ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; + ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); @@ -9644,9 +9644,9 @@ TEST_F(HttpNetworkTransactionTest, UseIPConnectionPooling) { SSLSocketDataProvider ssl(true, OK); ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; - ssl.next_proto = "spdy/2"; + ssl.next_proto = "spdy/2.1"; ssl.was_npn_negotiated = true; - ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; + ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); scoped_ptr<spdy::SpdyFrame> host1_req(ConstructSpdyGet( @@ -9798,9 +9798,9 @@ TEST_F(HttpNetworkTransactionTest, SSLSocketDataProvider ssl(true, OK); ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; - ssl.next_proto = "spdy/2"; + ssl.next_proto = "spdy/2.1"; ssl.was_npn_negotiated = true; - ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; + ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); scoped_ptr<spdy::SpdyFrame> host1_req(ConstructSpdyGet( diff --git a/net/http/http_pipelined_host_impl_unittest.cc b/net/http/http_pipelined_host_impl_unittest.cc index c52d573e..48107b5 100644 --- a/net/http/http_pipelined_host_impl_unittest.cc +++ b/net/http/http_pipelined_host_impl_unittest.cc @@ -103,7 +103,7 @@ class HttpPipelinedHostImplTest : public testing::Test { MatchesOrigin(origin_), Ref(ssl_config_), Ref(proxy_info_), Ref(net_log_), true, - SSLClientSocket::kProtoSPDY2)) + SSLClientSocket::kProtoSPDY21)) .Times(1) .WillOnce(Return(pipeline)); EXPECT_CALL(*pipeline, CreateNewStream()) @@ -111,7 +111,7 @@ class HttpPipelinedHostImplTest : public testing::Test { .WillOnce(Return(kDummyStream)); EXPECT_EQ(kDummyStream, host_->CreateStreamOnNewPipeline( kDummyConnection, ssl_config_, proxy_info_, net_log_, true, - SSLClientSocket::kProtoSPDY2)); + SSLClientSocket::kProtoSPDY21)); return pipeline; } @@ -263,7 +263,7 @@ TEST_F(HttpPipelinedHostImplTest, ShutsDownOnOldVersion) { ClearTestPipeline(pipeline); EXPECT_EQ(NULL, host_->CreateStreamOnNewPipeline( kDummyConnection, ssl_config_, proxy_info_, net_log_, true, - SSLClientSocket::kProtoSPDY2)); + SSLClientSocket::kProtoSPDY21)); } TEST_F(HttpPipelinedHostImplTest, ShutsDownOnAuthenticationRequired) { diff --git a/net/http/http_proxy_client_socket_pool_unittest.cc b/net/http/http_proxy_client_socket_pool_unittest.cc index ba7b6b5..bf5b418 100644 --- a/net/http/http_proxy_client_socket_pool_unittest.cc +++ b/net/http/http_proxy_client_socket_pool_unittest.cc @@ -176,9 +176,9 @@ class HttpProxyClientSocketPoolTest : public TestWithHttpParam { void InitializeSpdySsl() { spdy::SpdyFramer::set_enable_compression_default(false); ssl_data_->next_proto_status = SSLClientSocket::kNextProtoNegotiated; - ssl_data_->next_proto = "spdy/2"; + ssl_data_->next_proto = "spdy/2.1"; ssl_data_->was_npn_negotiated = true; - ssl_data_->protocol_negotiated = SSLClientSocket::kProtoSPDY2; + ssl_data_->protocol_negotiated = SSLClientSocket::kProtoSPDY21; } HttpNetworkSession* CreateNetworkSession() { diff --git a/net/http/http_server_properties_impl_unittest.cc b/net/http/http_server_properties_impl_unittest.cc index a3bb781..724dea0 100644 --- a/net/http/http_server_properties_impl_unittest.cc +++ b/net/http/http_server_properties_impl_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -212,7 +212,7 @@ TEST_F(AlternateProtocolServerPropertiesTest, Initialize) { AlternateProtocolMap alternate_protocol_map; PortAlternateProtocolPair port_alternate_protocol_pair; port_alternate_protocol_pair.port = 123; - port_alternate_protocol_pair.protocol = NPN_SPDY_2; + port_alternate_protocol_pair.protocol = NPN_SPDY_21; alternate_protocol_map[test_host_port_pair2] = port_alternate_protocol_pair; impl_.InitializeAlternateProtocolServers(&alternate_protocol_map); @@ -224,7 +224,7 @@ TEST_F(AlternateProtocolServerPropertiesTest, Initialize) { port_alternate_protocol_pair = impl_.GetAlternateProtocol(test_host_port_pair2); EXPECT_EQ(123, port_alternate_protocol_pair.port); - EXPECT_EQ(NPN_SPDY_2, port_alternate_protocol_pair.protocol); + EXPECT_EQ(NPN_SPDY_21, port_alternate_protocol_pair.protocol); } TEST_F(AlternateProtocolServerPropertiesTest, SetBroken) { @@ -249,7 +249,7 @@ TEST_F(AlternateProtocolServerPropertiesTest, Forced) { PortAlternateProtocolPair default_protocol; default_protocol.port = 1234; - default_protocol.protocol = NPN_SPDY_2; + default_protocol.protocol = NPN_SPDY_21; HttpServerPropertiesImpl::ForceAlternateProtocol(default_protocol); // Verify the forced protocol. diff --git a/net/http/http_stream_factory_impl.cc b/net/http/http_stream_factory_impl.cc index 9ef81b1..2e817f6 100644 --- a/net/http/http_stream_factory_impl.cc +++ b/net/http/http_stream_factory_impl.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -156,7 +156,7 @@ bool HttpStreamFactoryImpl::GetAlternateProtocolRequestFor( DCHECK_LE(NPN_SPDY_1, alternate.protocol); DCHECK_GT(NUM_ALTERNATE_PROTOCOLS, alternate.protocol); - if (alternate.protocol != NPN_SPDY_2) + if (alternate.protocol < NPN_SPDY_2) return false; // Some shared unix systems may have user home directories (like diff --git a/net/socket/ssl_client_socket_pool_unittest.cc b/net/socket/ssl_client_socket_pool_unittest.cc index 125cba9..53e6382 100644 --- a/net/socket/ssl_client_socket_pool_unittest.cc +++ b/net/socket/ssl_client_socket_pool_unittest.cc @@ -373,8 +373,8 @@ TEST_F(SSLClientSocketPoolTest, DirectGotSPDY) { socket_factory_.AddSocketDataProvider(&data); SSLSocketDataProvider ssl(true, OK); ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; - ssl.next_proto = "spdy/2"; - ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; + ssl.next_proto = "spdy/2.1"; + ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; socket_factory_.AddSSLSocketDataProvider(&ssl); CreatePool(true /* tcp pool */, false, false); @@ -399,7 +399,7 @@ TEST_F(SSLClientSocketPoolTest, DirectGotSPDY) { std::string server_protos; ssl_socket->GetNextProto(&proto, &server_protos); EXPECT_EQ(SSLClientSocket::NextProtoFromString(proto), - SSLClientSocket::kProtoSPDY2); + SSLClientSocket::kProtoSPDY21); } TEST_F(SSLClientSocketPoolTest, DirectGotBonusSPDY) { @@ -407,8 +407,8 @@ TEST_F(SSLClientSocketPoolTest, DirectGotBonusSPDY) { socket_factory_.AddSocketDataProvider(&data); SSLSocketDataProvider ssl(true, OK); ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; - ssl.next_proto = "spdy/2"; - ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; + ssl.next_proto = "spdy/2.1"; + ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; socket_factory_.AddSSLSocketDataProvider(&ssl); CreatePool(true /* tcp pool */, false, false); @@ -433,7 +433,7 @@ TEST_F(SSLClientSocketPoolTest, DirectGotBonusSPDY) { std::string server_protos; ssl_socket->GetNextProto(&proto, &server_protos); EXPECT_EQ(SSLClientSocket::NextProtoFromString(proto), - SSLClientSocket::kProtoSPDY2); + SSLClientSocket::kProtoSPDY21); } TEST_F(SSLClientSocketPoolTest, SOCKSFail) { @@ -709,8 +709,8 @@ TEST_F(SSLClientSocketPoolTest, IPPooling) { ssl.cert = X509Certificate::CreateFromBytes( reinterpret_cast<const char*>(webkit_der), sizeof(webkit_der)); ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; - ssl.next_proto = "spdy/2"; - ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; + ssl.next_proto = "spdy/2.1"; + ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; socket_factory_.AddSSLSocketDataProvider(&ssl); CreatePool(true /* tcp pool */, false, false); @@ -735,7 +735,7 @@ TEST_F(SSLClientSocketPoolTest, IPPooling) { std::string server_protos; ssl_socket->GetNextProto(&proto, &server_protos); EXPECT_EQ(SSLClientSocket::NextProtoFromString(proto), - SSLClientSocket::kProtoSPDY2); + SSLClientSocket::kProtoSPDY21); // TODO(rtenneti): MockClientSocket::GetPeerAddress returns 0 as the port // number. Fix it to return port 80 and then use GetPeerAddress to AddAlias. @@ -797,9 +797,9 @@ TEST_F(SSLClientSocketPoolTest, IPPoolingClientCert) { ssl.cert = X509Certificate::CreateFromBytes( reinterpret_cast<const char*>(webkit_der), sizeof(webkit_der)); ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; - ssl.next_proto = "spdy/2"; + ssl.next_proto = "spdy/2.1"; ssl.client_cert_sent = true; - ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY2; + ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY21; socket_factory_.AddSSLSocketDataProvider(&ssl); CreatePool(true /* tcp pool */, false, false); @@ -823,7 +823,7 @@ TEST_F(SSLClientSocketPoolTest, IPPoolingClientCert) { std::string server_protos; ssl_socket->GetNextProto(&proto, &server_protos); EXPECT_EQ(SSLClientSocket::NextProtoFromString(proto), - SSLClientSocket::kProtoSPDY2); + SSLClientSocket::kProtoSPDY21); // TODO(rtenneti): MockClientSocket::GetPeerAddress returns 0 as the port // number. Fix it to return port 80 and then use GetPeerAddress to AddAlias. diff --git a/net/spdy/spdy_network_transaction_unittest.cc b/net/spdy/spdy_network_transaction_unittest.cc index 98e27cf..d6b3666 100644 --- a/net/spdy/spdy_network_transaction_unittest.cc +++ b/net/spdy/spdy_network_transaction_unittest.cc @@ -127,7 +127,7 @@ class SpdyNetworkTransactionTest case SPDYNPN: session_->http_server_properties()->SetAlternateProtocol( HostPortPair("www.google.com", 80), 443, - NPN_SPDY_2); + NPN_SPDY_21); HttpStreamFactory::set_use_alternate_protocols(true); HttpStreamFactory::set_next_protos(next_protos); break; @@ -234,9 +234,9 @@ class SpdyNetworkTransactionTest new SSLSocketDataProvider(true, OK)); if (test_type_ == SPDYNPN) { ssl_->next_proto_status = SSLClientSocket::kNextProtoNegotiated; - ssl_->next_proto = "spdy/2"; + ssl_->next_proto = "spdy/2.1"; ssl_->was_npn_negotiated = true; - ssl_->protocol_negotiated = SSLClientSocket::kProtoSPDY2; + ssl_->protocol_negotiated = SSLClientSocket::kProtoSPDY21; } ssl_vector_.push_back(ssl_); if (test_type_ == SPDYNPN || test_type_ == SPDYSSL) @@ -262,9 +262,9 @@ class SpdyNetworkTransactionTest new SSLSocketDataProvider(true, OK)); if (test_type_ == SPDYNPN) { ssl_->next_proto_status = SSLClientSocket::kNextProtoNegotiated; - ssl_->next_proto = "spdy/2"; + ssl_->next_proto = "spdy/2.1"; ssl_->was_npn_negotiated = true; - ssl_->protocol_negotiated = SSLClientSocket::kProtoSPDY2; + ssl_->protocol_negotiated = SSLClientSocket::kProtoSPDY21; } ssl_vector_.push_back(ssl_); if (test_type_ == SPDYNPN || test_type_ == SPDYSSL) { @@ -1885,7 +1885,7 @@ TEST_P(SpdyNetworkTransactionTest, ResponseWithTwoSynReplies) { // limitations as described above and it's not deterministic, tests may // fail under specific circumstances. TEST_P(SpdyNetworkTransactionTest, WindowUpdateReceived) { - SpdySession::set_use_flow_control(true); + SpdySession::set_use_flow_control(SpdySession::kEnableFlowControl); static int kFrameCount = 2; scoped_ptr<std::string> content( @@ -1956,13 +1956,14 @@ TEST_P(SpdyNetworkTransactionTest, WindowUpdateReceived) { kMaxSpdyFrameChunkSize * kFrameCount, stream->stream()->send_window_size()); helper.VerifyDataConsumed(); - SpdySession::set_use_flow_control(false); + + SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN); } // Test that received data frames and sent WINDOW_UPDATE frames change // the recv_window_size_ correctly. TEST_P(SpdyNetworkTransactionTest, WindowUpdateSent) { - SpdySession::set_use_flow_control(true); + SpdySession::set_use_flow_control(SpdySession::kEnableFlowControl); scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); scoped_ptr<spdy::SpdyFrame> window_update( @@ -2039,13 +2040,14 @@ TEST_P(SpdyNetworkTransactionTest, WindowUpdateSent) { data->CompleteRead(); helper.VerifyDataConsumed(); - SpdySession::set_use_flow_control(false); + + SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN); } // Test that WINDOW_UPDATE frame causing overflow is handled correctly. We // use the same trick as in the above test to enforce our scenario. TEST_P(SpdyNetworkTransactionTest, WindowUpdateOverflow) { - SpdySession::set_use_flow_control(true); + SpdySession::set_use_flow_control(SpdySession::kEnableFlowControl); // number of full frames we hope to write (but will not, used to // set content-length header correctly) @@ -2118,7 +2120,7 @@ TEST_P(SpdyNetworkTransactionTest, WindowUpdateOverflow) { helper.session()->spdy_session_pool()->CloseAllSessions(); helper.VerifyDataConsumed(); - SpdySession::set_use_flow_control(false); + SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN); } // Test that after hitting a send window size of 0, the write process @@ -2137,7 +2139,7 @@ TEST_P(SpdyNetworkTransactionTest, WindowUpdateOverflow) { // After that, next read is artifically enforced, which causes a // WINDOW_UPDATE to be read and I/O process resumes. TEST_P(SpdyNetworkTransactionTest, FlowControlStallResume) { - SpdySession::set_use_flow_control(true); + SpdySession::set_use_flow_control(SpdySession::kEnableFlowControl); // Number of frames we need to send to zero out the window size: data // frames plus SYN_STREAM plus the last data frame; also we need another @@ -2228,7 +2230,7 @@ TEST_P(SpdyNetworkTransactionTest, FlowControlStallResume) { rv = callback.WaitForResult(); helper.VerifyDataConsumed(); - SpdySession::set_use_flow_control(false); + SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN); } TEST_P(SpdyNetworkTransactionTest, CancelledTransaction) { @@ -2965,6 +2967,8 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushMultipleDataFrame) { } TEST_P(SpdyNetworkTransactionTest, ServerPushMultipleDataFrameInterrupted) { + SpdySession::set_use_flow_control(SpdySession::kDisableFlowControl); + static const unsigned char kPushBodyFrame1[] = { 0x00, 0x00, 0x00, 0x02, // header, ID 0x01, 0x00, 0x00, 0x1F, // FIN, length @@ -3026,6 +3030,8 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushMultipleDataFrameInterrupted) { // Verify the pushed stream. EXPECT_TRUE(response2.headers != NULL); EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); + + SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN); } TEST_P(SpdyNetworkTransactionTest, ServerPushInvalidAssociatedStreamID0) { @@ -3740,6 +3746,8 @@ TEST_P(SpdyNetworkTransactionTest, NetLog) { // on the network, but issued a Read for only 5 of those bytes) that the data // flow still works correctly. TEST_P(SpdyNetworkTransactionTest, BufferFull) { + SpdySession::set_use_flow_control(SpdySession::kDisableFlowControl); + spdy::SpdyFramer framer; scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); @@ -3829,12 +3837,16 @@ TEST_P(SpdyNetworkTransactionTest, BufferFull) { EXPECT_EQ(OK, out.rv); EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); EXPECT_EQ("goodbye world", out.response_data); + + SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN); } // Verify that basic buffering works; when multiple data frames arrive // at the same time, ensure that we don't notify a read completion for // each data frame individually. TEST_P(SpdyNetworkTransactionTest, Buffering) { + SpdySession::set_use_flow_control(SpdySession::kDisableFlowControl); + spdy::SpdyFramer framer; scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); @@ -3926,6 +3938,8 @@ TEST_P(SpdyNetworkTransactionTest, Buffering) { EXPECT_EQ(OK, out.rv); EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); EXPECT_EQ("messagemessagemessagemessage", out.response_data); + + SpdySession::set_use_flow_control(SpdySession::kFlowControlBasedOnNPN); } // Verify the case where we buffer data but read it after it has been buffered. diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc index 16188b8..71a55fc 100644 --- a/net/spdy/spdy_session.cc +++ b/net/spdy/spdy_session.cc @@ -227,7 +227,8 @@ class NetLogSpdyGoAwayParameter : public NetLog::EventParameters { bool SpdySession::use_ssl_ = true; // static -bool SpdySession::use_flow_control_ = false; +SpdySession::FlowControl SpdySession::use_flow_control_ = + SpdySession::kFlowControlBasedOnNPN; // static size_t SpdySession::init_max_concurrent_streams_ = 10; @@ -282,7 +283,7 @@ SpdySession::SpdySession(const HostPortProxyPair& host_port_proxy_pair, trailing_ping_pending_(false), check_ping_status_pending_(false), need_to_send_ping_(false), - flow_control_(use_flow_control_), + flow_control_(false), initial_send_window_size_(spdy::kSpdyStreamInitialWindowSize), initial_recv_window_size_(spdy::kSpdyStreamInitialWindowSize), net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_SPDY_SESSION)), @@ -293,6 +294,10 @@ SpdySession::SpdySession(const HostPortProxyPair& host_port_proxy_pair, make_scoped_refptr( new NetLogSpdySessionParameter(host_port_proxy_pair_))); + // In unit tests, check if use_flow_control_ is enabled or disabled. + if (use_flow_control_ == SpdySession::kEnableFlowControl) + flow_control_ = true; + // TODO(mbelshe): consider randomization of the stream_hi_water_mark. buffered_spdy_framer_.set_visitor(this); @@ -344,8 +349,14 @@ net::Error SpdySession::InitializeWithSocket( SSLClientSocket* ssl_socket = reinterpret_cast<SSLClientSocket*>(connection_->socket()); DCHECK(ssl_socket); - if (ssl_socket->protocol_negotiated() == SSLClientSocket::kProtoSPDY21) - flow_control_ = true; + + // For SPDY 2.1 and above versions, flow control is enabled by default and + // for older versions, flow control is disabled by default. Unit tests can + // either enable or disable flow_control_ by setting the use_flow_control_. + if (ssl_socket->protocol_negotiated() >= SSLClientSocket::kProtoSPDY21) + flow_control_ = (use_flow_control_ != SpdySession::kDisableFlowControl); + else + flow_control_ = (use_flow_control_ == SpdySession::kEnableFlowControl); } // Write out any data that we might have to send, such as the settings frame. diff --git a/net/spdy/spdy_session.h b/net/spdy/spdy_session.h index f2b260f..47c33f7 100644 --- a/net/spdy/spdy_session.h +++ b/net/spdy/spdy_session.h @@ -48,6 +48,16 @@ class SSLInfo; class NET_EXPORT SpdySession : public base::RefCounted<SpdySession>, public spdy::BufferedSpdyFramerVisitorInterface { public: + // FlowControl provides the ability for unit tests to either enable or disable + // flow control (independent of NPN protocol negotiated). If + // |use_flow_control_| is set to kFlowControlBasedOnNPN then flow control is + // determined by the NPN protocol negotiated with the server. + enum FlowControl { + kFlowControlBasedOnNPN = 0, + kDisableFlowControl = 1, + kEnableFlowControl = 2, + }; + // Create a new SpdySession. // |host_port_proxy_pair| is the host/port that this session connects to, and // the proxy configuration settings that it's using. @@ -153,7 +163,9 @@ class NET_EXPORT SpdySession : public base::RefCounted<SpdySession>, // Enable or disable flow control used by unit tests. This only applies for // new SpdySessions. - static void set_use_flow_control(bool enable) { use_flow_control_ = enable; } + static void set_use_flow_control(FlowControl flow_control) { + use_flow_control_ = flow_control; + } // Sets the max concurrent streams per session, as a ceiling on any server // specific SETTINGS value. @@ -579,7 +591,7 @@ class NET_EXPORT SpdySession : public base::RefCounted<SpdySession>, bool verify_domain_authentication_; static bool use_ssl_; - static bool use_flow_control_; + static FlowControl use_flow_control_; static size_t init_max_concurrent_streams_; static size_t max_concurrent_stream_limit_; |