diff options
author | mbelshe@chromium.org <mbelshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-30 02:16:35 +0000 |
---|---|---|
committer | mbelshe@chromium.org <mbelshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-30 02:16:35 +0000 |
commit | dae22c5cddc8f1ebdfe77e66ebbf834255f94319 (patch) | |
tree | f949e3011b81a4b1234c90311a074fda63706e9c /net/http | |
parent | d420c31e107cd932582a4a8add0ce2676e4b52da (diff) | |
download | chromium_src-dae22c5cddc8f1ebdfe77e66ebbf834255f94319.zip chromium_src-dae22c5cddc8f1ebdfe77e66ebbf834255f94319.tar.gz chromium_src-dae22c5cddc8f1ebdfe77e66ebbf834255f94319.tar.bz2 |
Bump the SPDY protocol version to version 2.
Remove "http1.1" and "spdy" from the NPN advertisement string (the
proper values are "http/1.1" and "spdy/2", which were included redundantly).
BUG=50550
TEST=existing
Review URL: http://codereview.chromium.org/3044034
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54258 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http')
-rw-r--r-- | net/http/http_alternate_protocols.cc | 1 | ||||
-rw-r--r-- | net/http/http_alternate_protocols.h | 1 | ||||
-rw-r--r-- | net/http/http_network_layer.cc | 2 | ||||
-rw-r--r-- | net/http/http_network_transaction.cc | 24 | ||||
-rw-r--r-- | net/http/http_network_transaction_unittest.cc | 49 |
5 files changed, 44 insertions, 33 deletions
diff --git a/net/http/http_alternate_protocols.cc b/net/http/http_alternate_protocols.cc index c3804ac4..fbd1d92 100644 --- a/net/http/http_alternate_protocols.cc +++ b/net/http/http_alternate_protocols.cc @@ -12,6 +12,7 @@ namespace net { const char HttpAlternateProtocols::kHeader[] = "Alternate-Protocol"; const char* const HttpAlternateProtocols::kProtocolStrings[] = { "npn-spdy/1", + "npn-spdy/2", }; HttpAlternateProtocols::HttpAlternateProtocols() {} diff --git a/net/http/http_alternate_protocols.h b/net/http/http_alternate_protocols.h index 72f67ae..22bbac3 100644 --- a/net/http/http_alternate_protocols.h +++ b/net/http/http_alternate_protocols.h @@ -23,6 +23,7 @@ class HttpAlternateProtocols { public: enum Protocol { NPN_SPDY_1, + NPN_SPDY_2, NUM_ALTERNATE_PROTOCOLS, BROKEN, // The alternate protocol is known to be broken. }; diff --git a/net/http/http_network_layer.cc b/net/http/http_network_layer.cc index 30feddc..74e364a 100644 --- a/net/http/http_network_layer.cc +++ b/net/http/http_network_layer.cc @@ -149,7 +149,7 @@ void HttpNetworkLayer::EnableSpdy(const std::string& mode) { // it presumedly has a better understanding of which protocol we should // use, therefore the rest of the ordering here is not important. static const char kNpnProtosFull[] = - "\x08http/1.1\x07http1.1\x06spdy/1\x04spdy"; + "\x08http/1.1\x06spdy/2"; // No spdy specified. static const char kNpnProtosHttpOnly[] = "\x08http/1.1\x07http1.1"; diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc index 5cc3895..a9d557f 100644 --- a/net/http/http_network_transaction.cc +++ b/net/http/http_network_transaction.cc @@ -163,9 +163,14 @@ void ProcessAlternateProtocol(const HttpResponseHeaders& headers, return; } - if (port_protocol_vector[1] != - HttpAlternateProtocols::kProtocolStrings[ - HttpAlternateProtocols::NPN_SPDY_1]) { + HttpAlternateProtocols::Protocol protocol = HttpAlternateProtocols::BROKEN; + for (int i = HttpAlternateProtocols::NPN_SPDY_1; + i < HttpAlternateProtocols::NUM_ALTERNATE_PROTOCOLS; ++i) { + if (port_protocol_vector[1] == HttpAlternateProtocols::kProtocolStrings[i]) + protocol = static_cast<HttpAlternateProtocols::Protocol>(i); + } + + if (protocol == HttpAlternateProtocols::BROKEN) { // Currently, we only recognize the npn-spdy protocol. DLOG(WARNING) << HttpAlternateProtocols::kHeader << " header has unrecognized protocol: " @@ -185,8 +190,7 @@ void ProcessAlternateProtocol(const HttpResponseHeaders& headers, return; } - alternate_protocols->SetAlternateProtocolFor( - host_port, port, HttpAlternateProtocols::NPN_SPDY_1); + alternate_protocols->SetAlternateProtocolFor(host_port, port, protocol); } } // namespace @@ -663,9 +667,11 @@ int HttpNetworkTransaction::DoResolveProxy() { HttpAlternateProtocols::PortProtocolPair alternate = alternate_protocols.GetAlternateProtocolFor(endpoint_); if (alternate.protocol != HttpAlternateProtocols::BROKEN) { - DCHECK_EQ(HttpAlternateProtocols::NPN_SPDY_1, alternate.protocol); + DCHECK_LE(HttpAlternateProtocols::NPN_SPDY_1, alternate.protocol); + DCHECK_GT(HttpAlternateProtocols::NUM_ALTERNATE_PROTOCOLS, + alternate.protocol); endpoint_.set_port(alternate.port); - alternate_protocol_ = HttpAlternateProtocols::NPN_SPDY_1; + alternate_protocol_ = alternate.protocol; alternate_protocol_mode_ = kUsingAlternateProtocol; url_canon::Replacements<char> replacements; @@ -726,7 +732,7 @@ int HttpNetworkTransaction::DoInitConnection() { } bool want_spdy_over_npn = alternate_protocol_mode_ == kUsingAlternateProtocol - && alternate_protocol_ == HttpAlternateProtocols::NPN_SPDY_1; + && alternate_protocol_ == HttpAlternateProtocols::NPN_SPDY_2; using_ssl_ = request_->url.SchemeIs("https") || (want_spdy_without_npn_ && want_ssl_over_spdy_without_npn_) || want_spdy_over_npn; @@ -876,7 +882,7 @@ int HttpNetworkTransaction::DoInitConnectionComplete(int result) { std::string proto; ssl_socket->GetNextProto(&proto); if (SSLClientSocket::NextProtoFromString(proto) == - SSLClientSocket::kProtoSPDY1) + SSLClientSocket::kProtoSPDY2) using_spdy_ = true; } if(want_ssl_over_spdy_without_npn_ && want_spdy_without_npn_) diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc index 09b0029..dcdf13f 100644 --- a/net/http/http_network_transaction_unittest.cc +++ b/net/http/http_network_transaction_unittest.cc @@ -331,6 +331,14 @@ CaptureGroupNameSSLSocketPool::CaptureGroupNameSocketPool( //----------------------------------------------------------------------------- +// This is the expected list of advertised protocols from the browser's NPN +// list. +static const char kExpectedNPNString[] = "\x08http/1.1\x06spdy/2"; + +// 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"; + TEST_F(HttpNetworkTransactionTest, Basic) { SessionDependencies session_deps; scoped_ptr<HttpTransaction> trans( @@ -4027,7 +4035,7 @@ scoped_refptr<HttpNetworkSession> SetupSessionForGroupNameTests( session->mutable_alternate_protocols(); alternate_protocols->SetAlternateProtocolFor( HostPortPair("host.with.alternate", 80), 443, - HttpAlternateProtocols::NPN_SPDY_1); + HttpAlternateProtocols::NPN_SPDY_2); return session; } @@ -4978,7 +4986,7 @@ TEST_F(HttpNetworkTransactionTest, HonorAlternateProtocolHeader) { MockRead data_reads[] = { MockRead("HTTP/1.1 200 OK\r\n"), - MockRead("Alternate-Protocol: 443:npn-spdy/1\r\n\r\n"), + MockRead(kAlternateProtocolHttpHeader), MockRead("hello world"), MockRead(false, OK), }; @@ -5025,7 +5033,7 @@ TEST_F(HttpNetworkTransactionTest, HonorAlternateProtocolHeader) { alternate_protocols.GetAlternateProtocolFor(http_host_port_pair); HttpAlternateProtocols::PortProtocolPair expected_alternate; expected_alternate.port = 443; - expected_alternate.protocol = HttpAlternateProtocols::NPN_SPDY_1; + expected_alternate.protocol = HttpAlternateProtocols::NPN_SPDY_2; EXPECT_TRUE(expected_alternate.Equals(alternate)); HttpNetworkTransaction::SetUseAlternateProtocols(false); @@ -5069,7 +5077,7 @@ TEST_F(HttpNetworkTransactionTest, MarkBrokenAlternateProtocol) { session->mutable_alternate_protocols(); alternate_protocols->SetAlternateProtocolFor( http_host_port_pair, 1234 /* port is ignored by MockConnect anyway */, - HttpAlternateProtocols::NPN_SPDY_1); + HttpAlternateProtocols::NPN_SPDY_2); scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); @@ -5149,8 +5157,7 @@ TEST_F(HttpNetworkTransactionTest, MarkBrokenAlternateProtocol) { TEST_F(HttpNetworkTransactionTest, FailNpnSpdyAndFallback) { HttpNetworkTransaction::SetUseAlternateProtocols(true); - HttpNetworkTransaction::SetNextProtos( - "\x08http/1.1\x07http1.1\x06spdy/1\x04spdy"); + HttpNetworkTransaction::SetNextProtos(kExpectedNPNString); SessionDependencies session_deps; HttpRequestInfo request; @@ -5182,7 +5189,7 @@ TEST_F(HttpNetworkTransactionTest, FailNpnSpdyAndFallback) { session->mutable_alternate_protocols(); alternate_protocols->SetAlternateProtocolFor( http_host_port_pair, 1234 /* port is ignored */, - HttpAlternateProtocols::NPN_SPDY_1); + HttpAlternateProtocols::NPN_SPDY_2); scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); @@ -5204,8 +5211,7 @@ TEST_F(HttpNetworkTransactionTest, FailNpnSpdyAndFallback) { TEST_F(HttpNetworkTransactionTest, UseAlternateProtocolForNpnSpdy) { HttpNetworkTransaction::SetUseAlternateProtocols(true); - HttpNetworkTransaction::SetNextProtos( - "\x08http/1.1\x07http1.1\x06spdy/1\x04spdy"); + HttpNetworkTransaction::SetNextProtos(kExpectedNPNString); SessionDependencies session_deps; HttpRequestInfo request; @@ -5215,7 +5221,7 @@ TEST_F(HttpNetworkTransactionTest, UseAlternateProtocolForNpnSpdy) { MockRead data_reads[] = { MockRead("HTTP/1.1 200 OK\r\n"), - MockRead("Alternate-Protocol: 443:npn-spdy/1\r\n\r\n"), + MockRead(kAlternateProtocolHttpHeader), MockRead("hello world"), MockRead(true, OK), }; @@ -5226,7 +5232,7 @@ TEST_F(HttpNetworkTransactionTest, UseAlternateProtocolForNpnSpdy) { SSLSocketDataProvider ssl(true, OK); ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; - ssl.next_proto = "spdy/1"; + ssl.next_proto = "spdy/2"; ssl.was_npn_negotiated = true; session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); @@ -5323,8 +5329,7 @@ class CapturingProxyResolver : public ProxyResolver { TEST_F(HttpNetworkTransactionTest, UseAlternateProtocolForTunneledNpnSpdy) { HttpNetworkTransaction::SetUseAlternateProtocols(true); - HttpNetworkTransaction::SetNextProtos( - "\x08http/1.1\x07http1.1\x06spdy/1\x04spdy"); + HttpNetworkTransaction::SetNextProtos(kExpectedNPNString); ProxyConfig proxy_config; proxy_config.set_auto_detect(true); @@ -5343,7 +5348,7 @@ TEST_F(HttpNetworkTransactionTest, UseAlternateProtocolForTunneledNpnSpdy) { MockRead data_reads[] = { MockRead("HTTP/1.1 200 OK\r\n"), - MockRead("Alternate-Protocol: 443:npn-spdy/1\r\n\r\n"), + MockRead(kAlternateProtocolHttpHeader), MockRead("hello world"), MockRead(true, OK), }; @@ -5354,7 +5359,7 @@ TEST_F(HttpNetworkTransactionTest, UseAlternateProtocolForTunneledNpnSpdy) { SSLSocketDataProvider ssl(true, OK); ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; - ssl.next_proto = "spdy/1"; + ssl.next_proto = "spdy/2"; ssl.was_npn_negotiated = true; session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); @@ -5431,8 +5436,7 @@ TEST_F(HttpNetworkTransactionTest, UseAlternateProtocolForTunneledNpnSpdy) { TEST_F(HttpNetworkTransactionTest, UseAlternateProtocolForNpnSpdyWithExistingSpdySession) { HttpNetworkTransaction::SetUseAlternateProtocols(true); - HttpNetworkTransaction::SetNextProtos( - "\x08http/1.1\x07http1.1\x06spdy/1\x04spdy"); + HttpNetworkTransaction::SetNextProtos(kExpectedNPNString); SessionDependencies session_deps; HttpRequestInfo request; @@ -5442,7 +5446,7 @@ TEST_F(HttpNetworkTransactionTest, MockRead data_reads[] = { MockRead("HTTP/1.1 200 OK\r\n"), - MockRead("Alternate-Protocol: 443:npn-spdy/1\r\n\r\n"), + MockRead(kAlternateProtocolHttpHeader), MockRead("hello world"), MockRead(true, OK), }; @@ -5453,7 +5457,7 @@ TEST_F(HttpNetworkTransactionTest, SSLSocketDataProvider ssl(true, OK); ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; - ssl.next_proto = "spdy/1"; + ssl.next_proto = "spdy/2"; ssl.was_npn_negotiated = true; session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); // Make sure we use ssl for spdy here. @@ -6176,7 +6180,7 @@ TEST_F(HttpNetworkTransactionTest, NpnWithHttpOverSSL) { MockRead data_reads[] = { MockRead("HTTP/1.1 200 OK\r\n"), - MockRead("Alternate-Protocol: 443:npn-spdy/1\r\n\r\n"), + MockRead(kAlternateProtocolHttpHeader), MockRead("hello world"), MockRead(false, OK), }; @@ -6223,8 +6227,7 @@ TEST_F(HttpNetworkTransactionTest, SpdyPostNPNServerHangup) { // followed by an immediate server closing of the socket. // Fix crash: http://crbug.com/46369 HttpNetworkTransaction::SetUseAlternateProtocols(true); - HttpNetworkTransaction::SetNextProtos( - "\x08http/1.1\x07http1.1\x06spdy/1\x04spdy"); + HttpNetworkTransaction::SetNextProtos(kExpectedNPNString); SessionDependencies session_deps; HttpRequestInfo request; @@ -6234,7 +6237,7 @@ TEST_F(HttpNetworkTransactionTest, SpdyPostNPNServerHangup) { SSLSocketDataProvider ssl(true, OK); ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; - ssl.next_proto = "spdy/1"; + ssl.next_proto = "spdy/2"; ssl.was_npn_negotiated = true; session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |