diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-13 22:14:03 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-13 22:14:03 +0000 |
commit | 749eefa86bfae16ea4bdc6aeba3f97bfa98f22f7 (patch) | |
tree | 5412fc267f2ec81666fff988b7986293b844f7f4 /net/http/http_network_transaction_unittest.cc | |
parent | 242c8f40453ad06a06fc2db689a4d3aa8ca20d2f (diff) | |
download | chromium_src-749eefa86bfae16ea4bdc6aeba3f97bfa98f22f7.zip chromium_src-749eefa86bfae16ea4bdc6aeba3f97bfa98f22f7.tar.gz chromium_src-749eefa86bfae16ea4bdc6aeba3f97bfa98f22f7.tar.bz2 |
Fix a crash when we preconnect to a host that we already have a SPDY session for.
BUG=55424
TEST=HttpNetworkTransactionTest.PreconnectWithExistingSpdySession
Review URL: http://codereview.chromium.org/3308029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59288 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_network_transaction_unittest.cc')
-rw-r--r-- | net/http/http_network_transaction_unittest.cc | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc index ef27954..41873da 100644 --- a/net/http/http_network_transaction_unittest.cc +++ b/net/http/http_network_transaction_unittest.cc @@ -7278,4 +7278,60 @@ TEST_F(HttpNetworkTransactionTest, ProxyTunnelGetHangup) { NetLog::PHASE_NONE); } +// Test for crbug.com/55424. +TEST_F(HttpNetworkTransactionTest, PreconnectWithExistingSpdySession) { + SessionDependencies session_deps; + + scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet( + "https://www.google.com", false, 1, LOWEST)); + MockWrite spdy_writes[] = { CreateMockWrite(*req) }; + + scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); + scoped_ptr<spdy::SpdyFrame> data(ConstructSpdyBodyFrame(1, true)); + MockRead spdy_reads[] = { + CreateMockRead(*resp), + CreateMockRead(*data), + MockRead(true, 0, 0), + }; + + scoped_refptr<DelayedSocketData> spdy_data( + new DelayedSocketData( + 1, // wait for one write to finish before reading. + spdy_reads, arraysize(spdy_reads), + spdy_writes, arraysize(spdy_writes))); + session_deps.socket_factory.AddSocketDataProvider(spdy_data); + + SSLSocketDataProvider ssl(true, OK); + ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; + ssl.next_proto = "spdy/2"; + ssl.was_npn_negotiated = true; + session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); + + scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); + + // Set up an initial SpdySession in the pool to reuse. + HostPortProxyPair pair(HostPortPair("www.google.com", 443), + ProxyServer::Direct()); + scoped_refptr<SpdySession> spdy_session = + session->spdy_session_pool()->Get(pair, session, BoundNetLog()); + scoped_refptr<TCPSocketParams> tcp_params = + new TCPSocketParams("www.google.com", 443, MEDIUM, GURL(), false); + spdy_session->Connect("www.google.com:443", tcp_params, MEDIUM); + + HttpRequestInfo request; + request.method = "GET"; + request.url = GURL("https://www.google.com/"); + request.load_flags = 0; + + // This is the important line that marks this as a preconnect. + request.motivation = HttpRequestInfo::PRECONNECT_MOTIVATED; + + scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); + + TestCompletionCallback callback; + int rv = trans->Start(&request, &callback, BoundNetLog()); + EXPECT_EQ(ERR_IO_PENDING, rv); + EXPECT_EQ(OK, callback.WaitForResult()); +} + } // namespace net |