diff options
Diffstat (limited to 'net/http/http_network_transaction_unittest.cc')
-rw-r--r-- | net/http/http_network_transaction_unittest.cc | 122 |
1 files changed, 29 insertions, 93 deletions
diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc index ca06785..7dda13e 100644 --- a/net/http/http_network_transaction_unittest.cc +++ b/net/http/http_network_transaction_unittest.cc @@ -289,8 +289,7 @@ class HttpNetworkTransactionTest // failure should cause the network transaction to resend the request, and the // other argument should be NULL. void PreconnectErrorResendRequestTest(const MockWrite* write_failure, - const MockRead* read_failure, - bool use_spdy); + const MockRead* read_failure); SimpleGetHelperResult SimpleGetHelperForData(StaticSocketDataProvider* data[], size_t data_count) { @@ -1309,81 +1308,46 @@ void HttpNetworkTransactionTest::KeepAliveConnectionResendRequestTest( void HttpNetworkTransactionTest::PreconnectErrorResendRequestTest( const MockWrite* write_failure, - const MockRead* read_failure, - bool use_spdy) { + const MockRead* read_failure) { HttpRequestInfo request; request.method = "GET"; - request.url = GURL("https://www.foo.com/"); + request.url = GURL("http://www.foo.com/"); request.load_flags = 0; CapturingNetLog net_log; session_deps_.net_log = &net_log; scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); - SSLSocketDataProvider ssl1(ASYNC, OK); - SSLSocketDataProvider ssl2(ASYNC, OK); - if (use_spdy) { - ssl1.SetNextProto(GetParam()); - ssl2.SetNextProto(GetParam()); - } - session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl1); - session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl2); - - // SPDY versions of the request and response. - scoped_ptr<SpdyFrame> spdy_request(spdy_util_.ConstructSpdyGet( - request.url.spec().c_str(), false, 1, DEFAULT_PRIORITY)); - scoped_ptr<SpdyFrame> spdy_response( - spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); - scoped_ptr<SpdyFrame> spdy_data( - spdy_util_.ConstructSpdyBodyFrame(1, "hello", 5, true)); + // Written data for successfully sending a request. + MockWrite data1_writes[] = { + MockWrite("GET / HTTP/1.1\r\n" + "Host: www.foo.com\r\n" + "Connection: keep-alive\r\n\r\n"), + }; - // HTTP/1.1 versions of the request and response. - const char kHttpRequest[] = "GET / HTTP/1.1\r\n" - "Host: www.foo.com\r\n" - "Connection: keep-alive\r\n\r\n"; - const char kHttpResponse[] = "HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"; - const char kHttpData[] = "hello"; + // Read results for the first request. + MockRead data1_reads[] = { + MockRead(ASYNC, OK), + }; - std::vector<MockRead> data1_reads; - std::vector<MockWrite> data1_writes; if (write_failure) { ASSERT_FALSE(read_failure); - data1_writes.push_back(*write_failure); - data1_reads.push_back(MockRead(ASYNC, OK)); + data1_writes[0] = *write_failure; } else { ASSERT_TRUE(read_failure); - if (use_spdy) { - data1_writes.push_back(CreateMockWrite(*spdy_request)); - } else { - data1_writes.push_back(MockWrite(kHttpRequest)); - } - data1_reads.push_back(*read_failure); + data1_reads[0] = *read_failure; } - StaticSocketDataProvider data1(&data1_reads[0], data1_reads.size(), - &data1_writes[0], data1_writes.size()); + StaticSocketDataProvider data1(data1_reads, arraysize(data1_reads), + data1_writes, arraysize(data1_writes)); session_deps_.socket_factory->AddSocketDataProvider(&data1); - std::vector<MockRead> data2_reads; - std::vector<MockWrite> data2_writes; - - if (use_spdy) { - data2_writes.push_back(CreateMockWrite(*spdy_request, 0, ASYNC)); - - data2_reads.push_back(CreateMockRead(*spdy_response, 1, ASYNC)); - data2_reads.push_back(CreateMockRead(*spdy_data, 2, ASYNC)); - data2_reads.push_back(MockRead(ASYNC, OK, 3)); - } else { - data2_writes.push_back( - MockWrite(ASYNC, kHttpRequest, strlen(kHttpRequest), 0)); - - data2_reads.push_back( - MockRead(ASYNC, kHttpResponse, strlen(kHttpResponse), 1)); - data2_reads.push_back(MockRead(ASYNC, kHttpData, strlen(kHttpData), 2)); - data2_reads.push_back(MockRead(ASYNC, OK, 3)); - } - OrderedSocketData data2(&data2_reads[0], data2_reads.size(), - &data2_writes[0], data2_writes.size()); + MockRead data2_reads[] = { + MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"), + MockRead("hello"), + MockRead(ASYNC, OK), + }; + StaticSocketDataProvider data2(data2_reads, arraysize(data2_reads), NULL, 0); session_deps_.socket_factory->AddSocketDataProvider(&data2); // Preconnect a socket. @@ -1396,7 +1360,7 @@ void HttpNetworkTransactionTest::PreconnectErrorResendRequestTest( // Wait for the preconnect to complete. // TODO(davidben): Some way to wait for an idle socket count might be handy. base::RunLoop().RunUntilIdle(); - EXPECT_EQ(1, GetIdleSocketCountInSSLSocketPool(session.get())); + EXPECT_EQ(1, GetIdleSocketCountInTransportSocketPool(session.get())); // Make the request. TestCompletionCallback callback; @@ -1412,9 +1376,7 @@ void HttpNetworkTransactionTest::PreconnectErrorResendRequestTest( LoadTimingInfo load_timing_info; EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); - TestLoadTimingNotReused( - load_timing_info, - CONNECT_TIMING_HAS_DNS_TIMES|CONNECT_TIMING_HAS_SSL_TIMES); + TestLoadTimingNotReused(load_timing_info, CONNECT_TIMING_HAS_DNS_TIMES); const HttpResponseInfo* response = trans->GetResponseInfo(); ASSERT_TRUE(response != NULL); @@ -1425,7 +1387,7 @@ void HttpNetworkTransactionTest::PreconnectErrorResendRequestTest( std::string response_data; rv = ReadTransaction(trans.get(), &response_data); EXPECT_EQ(OK, rv); - EXPECT_EQ(kHttpData, response_data); + EXPECT_EQ("hello", response_data); } TEST_P(HttpNetworkTransactionTest, @@ -1447,43 +1409,17 @@ TEST_P(HttpNetworkTransactionTest, KeepAliveConnectionEOF) { TEST_P(HttpNetworkTransactionTest, PreconnectErrorNotConnectedOnWrite) { MockWrite write_failure(ASYNC, ERR_SOCKET_NOT_CONNECTED); - PreconnectErrorResendRequestTest(&write_failure, NULL, false); + PreconnectErrorResendRequestTest(&write_failure, NULL); } TEST_P(HttpNetworkTransactionTest, PreconnectErrorReset) { MockRead read_failure(ASYNC, ERR_CONNECTION_RESET); - PreconnectErrorResendRequestTest(NULL, &read_failure, false); + PreconnectErrorResendRequestTest(NULL, &read_failure); } TEST_P(HttpNetworkTransactionTest, PreconnectErrorEOF) { MockRead read_failure(SYNCHRONOUS, OK); // EOF - PreconnectErrorResendRequestTest(NULL, &read_failure, false); -} - -TEST_P(HttpNetworkTransactionTest, PreconnectErrorAsyncEOF) { - MockRead read_failure(ASYNC, OK); // EOF - PreconnectErrorResendRequestTest(NULL, &read_failure, false); -} - -TEST_P(HttpNetworkTransactionTest, - SpdyPreconnectErrorNotConnectedOnWrite) { - MockWrite write_failure(ASYNC, ERR_SOCKET_NOT_CONNECTED); - PreconnectErrorResendRequestTest(&write_failure, NULL, true); -} - -TEST_P(HttpNetworkTransactionTest, SpdyPreconnectErrorReset) { - MockRead read_failure(ASYNC, ERR_CONNECTION_RESET); - PreconnectErrorResendRequestTest(NULL, &read_failure, true); -} - -TEST_P(HttpNetworkTransactionTest, SpdyPreconnectErrorEOF) { - MockRead read_failure(SYNCHRONOUS, OK); // EOF - PreconnectErrorResendRequestTest(NULL, &read_failure, true); -} - -TEST_P(HttpNetworkTransactionTest, SpdyPreconnectErrorAsyncEOF) { - MockRead read_failure(ASYNC, OK); // EOF - PreconnectErrorResendRequestTest(NULL, &read_failure, true); + PreconnectErrorResendRequestTest(NULL, &read_failure); } TEST_P(HttpNetworkTransactionTest, NonKeepAliveConnectionReset) { |