diff options
Diffstat (limited to 'net/http/http_network_transaction_unittest.cc')
-rw-r--r-- | net/http/http_network_transaction_unittest.cc | 209 |
1 files changed, 130 insertions, 79 deletions
diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc index d2a35bc..a8d9ea5 100644 --- a/net/http/http_network_transaction_unittest.cc +++ b/net/http/http_network_transaction_unittest.cc @@ -154,14 +154,20 @@ HttpNetworkSession* CreateSession(SessionDependencies* session_deps) { class HttpNetworkTransactionTest : public PlatformTest { public: virtual void SetUp() { + NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); + MessageLoop::current()->RunAllPending(); spdy::SpdyFramer::set_enable_compression_default(false); } virtual void TearDown() { + NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); + MessageLoop::current()->RunAllPending(); spdy::SpdyFramer::set_enable_compression_default(true); // Empty the current queue. MessageLoop::current()->RunAllPending(); PlatformTest::TearDown(); + NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); + MessageLoop::current()->RunAllPending(); } protected: @@ -560,7 +566,7 @@ TEST_F(HttpNetworkTransactionTest, ReuseConnection) { StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); session_deps.socket_factory.AddSocketDataProvider(&data); - const char* kExpectedResponseData[] = { + const char* const kExpectedResponseData[] = { "hello", "world" }; @@ -850,8 +856,9 @@ TEST_F(HttpNetworkTransactionTest, NonKeepAliveConnectionEOF) { EXPECT_EQ(ERR_EMPTY_RESPONSE, out.rv); } -// Test that we correctly reuse a keep-alive connection after receiving a 304. -TEST_F(HttpNetworkTransactionTest, KeepAliveAfter304) { +// Test that we correctly reuse a keep-alive connection after not explicitly +// reading the body. +TEST_F(HttpNetworkTransactionTest, KeepAliveAfterUnreadBody) { SessionDependencies session_deps; scoped_refptr<HttpNetworkSession> session = CreateSession(&session_deps); @@ -860,8 +867,23 @@ TEST_F(HttpNetworkTransactionTest, KeepAliveAfter304) { request.url = GURL("http://www.foo.com/"); request.load_flags = 0; + // Note that because all these reads happen in the same + // StaticSocketDataProvider, it shows that the same socket is being reused for + // all transactions. MockRead data1_reads[] = { + MockRead("HTTP/1.1 204 No Content\r\n\r\n"), + MockRead("HTTP/1.1 205 Reset Content\r\n\r\n"), MockRead("HTTP/1.1 304 Not Modified\r\n\r\n"), + MockRead("HTTP/1.1 302 Found\r\n" + "Content-Length: 0\r\n\r\n"), + MockRead("HTTP/1.1 302 Found\r\n" + "Content-Length: 5\r\n\r\n" + "hello"), + MockRead("HTTP/1.1 301 Moved Permanently\r\n" + "Content-Length: 0\r\n\r\n"), + MockRead("HTTP/1.1 301 Moved Permanently\r\n" + "Content-Length: 5\r\n\r\n" + "hello"), MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"), MockRead("hello"), }; @@ -874,7 +896,10 @@ TEST_F(HttpNetworkTransactionTest, KeepAliveAfter304) { StaticSocketDataProvider data2(data2_reads, arraysize(data2_reads), NULL, 0); session_deps.socket_factory.AddSocketDataProvider(&data2); - for (int i = 0; i < 2; ++i) { + const int kNumUnreadBodies = arraysize(data1_reads) - 2; + std::string response_lines[kNumUnreadBodies]; + + for (size_t i = 0; i < arraysize(data1_reads) - 2; ++i) { TestCompletionCallback callback; scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); @@ -886,22 +911,44 @@ TEST_F(HttpNetworkTransactionTest, KeepAliveAfter304) { EXPECT_EQ(OK, rv); const HttpResponseInfo* response = trans->GetResponseInfo(); - EXPECT_TRUE(response != NULL); + ASSERT_TRUE(response != NULL); - EXPECT_TRUE(response->headers != NULL); - if (i == 0) { - EXPECT_EQ("HTTP/1.1 304 Not Modified", - response->headers->GetStatusLine()); - // We intentionally don't read the response in this case, to reflect how - // HttpCache::Transaction uses HttpNetworkTransaction. - } else { - EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); - std::string response_data; - rv = ReadTransaction(trans.get(), &response_data); - EXPECT_EQ(OK, rv); - EXPECT_EQ("hello", response_data); - } + ASSERT_TRUE(response->headers != NULL); + response_lines[i] = response->headers->GetStatusLine(); + + // We intentionally don't read the response bodies. } + + const char* const kStatusLines[] = { + "HTTP/1.1 204 No Content", + "HTTP/1.1 205 Reset Content", + "HTTP/1.1 304 Not Modified", + "HTTP/1.1 302 Found", + "HTTP/1.1 302 Found", + "HTTP/1.1 301 Moved Permanently", + "HTTP/1.1 301 Moved Permanently", + }; + + COMPILE_ASSERT(kNumUnreadBodies == arraysize(kStatusLines), + forgot_to_update_kStatusLines); + + for (int i = 0; i < kNumUnreadBodies; ++i) + EXPECT_EQ(kStatusLines[i], response_lines[i]); + + TestCompletionCallback callback; + scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); + int rv = trans->Start(&request, &callback, BoundNetLog()); + EXPECT_EQ(ERR_IO_PENDING, rv); + rv = callback.WaitForResult(); + EXPECT_EQ(OK, rv); + const HttpResponseInfo* response = trans->GetResponseInfo(); + ASSERT_TRUE(response != NULL); + ASSERT_TRUE(response->headers != NULL); + EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); + std::string response_data; + rv = ReadTransaction(trans.get(), &response_data); + EXPECT_EQ(OK, rv); + EXPECT_EQ("hello", response_data); } // Test the request-challenge-retry sequence for basic auth. @@ -1036,8 +1083,7 @@ TEST_F(HttpNetworkTransactionTest, DoNotSendAuth) { // connection. TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAlive) { SessionDependencies session_deps; - scoped_ptr<HttpTransaction> trans( - new HttpNetworkTransaction(CreateSession(&session_deps))); + scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); HttpRequestInfo request; request.method = "GET"; @@ -1067,8 +1113,8 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAlive) { // Lastly, the server responds with the actual content. MockRead("HTTP/1.1 200 OK\r\n"), MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), - MockRead("Content-Length: 100\r\n\r\n"), - MockRead(false, OK), + MockRead("Content-Length: 5\r\n\r\n"), + MockRead("Hello"), }; StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), @@ -1077,6 +1123,7 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAlive) { TestCompletionCallback callback1; + scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); int rv = trans->Start(&request, &callback1, BoundNetLog()); EXPECT_EQ(ERR_IO_PENDING, rv); @@ -1104,15 +1151,14 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAlive) { response = trans->GetResponseInfo(); EXPECT_FALSE(response == NULL); EXPECT_TRUE(response->auth_challenge.get() == NULL); - EXPECT_EQ(100, response->headers->GetContentLength()); + EXPECT_EQ(5, response->headers->GetContentLength()); } // Test the request-challenge-retry sequence for basic auth, over a keep-alive // connection and with no response body to drain. TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAliveNoBody) { SessionDependencies session_deps; - scoped_ptr<HttpTransaction> trans( - new HttpNetworkTransaction(CreateSession(&session_deps))); + scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); HttpRequestInfo request; request.method = "GET"; @@ -1140,8 +1186,8 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAliveNoBody) { // Lastly, the server responds with the actual content. MockRead("HTTP/1.1 200 OK\r\n"), MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), - MockRead("Content-Length: 100\r\n\r\n"), - MockRead(false, OK), + MockRead("Content-Length: 5\r\n\r\n"), + MockRead("hello"), }; StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), @@ -1150,6 +1196,7 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAliveNoBody) { TestCompletionCallback callback1; + scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); int rv = trans->Start(&request, &callback1, BoundNetLog()); EXPECT_EQ(ERR_IO_PENDING, rv); @@ -1177,15 +1224,14 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAliveNoBody) { response = trans->GetResponseInfo(); EXPECT_FALSE(response == NULL); EXPECT_TRUE(response->auth_challenge.get() == NULL); - EXPECT_EQ(100, response->headers->GetContentLength()); + EXPECT_EQ(5, response->headers->GetContentLength()); } // Test the request-challenge-retry sequence for basic auth, over a keep-alive // connection and with a large response body to drain. TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAliveLargeBody) { SessionDependencies session_deps; - scoped_ptr<HttpTransaction> trans( - new HttpNetworkTransaction(CreateSession(&session_deps))); + scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); HttpRequestInfo request; request.method = "GET"; @@ -1221,8 +1267,8 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAliveLargeBody) { // Lastly, the server responds with the actual content. MockRead("HTTP/1.1 200 OK\r\n"), MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), - MockRead("Content-Length: 100\r\n\r\n"), - MockRead(false, OK), + MockRead("Content-Length: 5\r\n\r\n"), + MockRead("hello"), }; StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), @@ -1231,6 +1277,7 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAliveLargeBody) { TestCompletionCallback callback1; + scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); int rv = trans->Start(&request, &callback1, BoundNetLog()); EXPECT_EQ(ERR_IO_PENDING, rv); @@ -1258,15 +1305,14 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAliveLargeBody) { response = trans->GetResponseInfo(); EXPECT_FALSE(response == NULL); EXPECT_TRUE(response->auth_challenge.get() == NULL); - EXPECT_EQ(100, response->headers->GetContentLength()); + EXPECT_EQ(5, response->headers->GetContentLength()); } // Test the request-challenge-retry sequence for basic auth, over a keep-alive // connection, but the server gets impatient and closes the connection. TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAliveImpatientServer) { SessionDependencies session_deps; - scoped_ptr<HttpTransaction> trans( - new HttpNetworkTransaction(CreateSession(&session_deps))); + scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); HttpRequestInfo request; request.method = "GET"; @@ -1309,8 +1355,8 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAliveImpatientServer) { MockRead data_reads2[] = { MockRead("HTTP/1.1 200 OK\r\n"), MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), - MockRead("Content-Length: 100\r\n\r\n"), - MockRead(false, OK), + MockRead("Content-Length: 5\r\n\r\n"), + MockRead("hello"), }; StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), @@ -1322,6 +1368,7 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAliveImpatientServer) { TestCompletionCallback callback1; + scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); int rv = trans->Start(&request, &callback1, BoundNetLog()); EXPECT_EQ(ERR_IO_PENDING, rv); @@ -1349,7 +1396,7 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAliveImpatientServer) { response = trans->GetResponseInfo(); ASSERT_FALSE(response == NULL); EXPECT_TRUE(response->auth_challenge.get() == NULL); - EXPECT_EQ(100, response->headers->GetContentLength()); + EXPECT_EQ(5, response->headers->GetContentLength()); } // Test the request-challenge-retry sequence for basic auth, over a connection @@ -1361,8 +1408,6 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthProxyNoKeepAlive) { session_deps.net_log = log.bound().net_log(); scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); - scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); - HttpRequestInfo request; request.method = "GET"; request.url = GURL("https://www.google.com/"); @@ -1399,8 +1444,8 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthProxyNoKeepAlive) { MockRead("HTTP/1.1 200 OK\r\n"), MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), - MockRead("Content-Length: 100\r\n\r\n"), - MockRead(false, OK), + MockRead("Content-Length: 5\r\n\r\n"), + MockRead(false, "hello"), }; StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), @@ -1411,6 +1456,8 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthProxyNoKeepAlive) { TestCompletionCallback callback1; + scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); + int rv = trans->Start(&request, &callback1, log.bound()); EXPECT_EQ(ERR_IO_PENDING, rv); @@ -1450,11 +1497,14 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthProxyNoKeepAlive) { EXPECT_TRUE(response->headers->IsKeepAlive()); EXPECT_EQ(200, response->headers->response_code()); - EXPECT_EQ(100, response->headers->GetContentLength()); + EXPECT_EQ(5, response->headers->GetContentLength()); EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); // The password prompt info should not be set. EXPECT_TRUE(response->auth_challenge.get() == NULL); + + trans.reset(); + session->FlushSocketPools(); } // Test the request-challenge-retry sequence for basic auth, over a keep-alive @@ -1676,8 +1726,6 @@ TEST_F(HttpNetworkTransactionTest, HttpsProxyGet) { session_deps.net_log = log.bound().net_log(); scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); - scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); - HttpRequestInfo request; request.method = "GET"; request.url = GURL("http://www.google.com/"); @@ -1704,6 +1752,8 @@ TEST_F(HttpNetworkTransactionTest, HttpsProxyGet) { TestCompletionCallback callback1; + scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); + int rv = trans->Start(&request, &callback1, log.bound()); EXPECT_EQ(ERR_IO_PENDING, rv); @@ -1730,8 +1780,6 @@ TEST_F(HttpNetworkTransactionTest, HttpsProxySpdyGet) { session_deps.net_log = log.bound().net_log(); scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); - scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); - HttpRequestInfo request; request.method = "GET"; request.url = GURL("http://www.google.com/"); @@ -1765,6 +1813,8 @@ TEST_F(HttpNetworkTransactionTest, HttpsProxySpdyGet) { TestCompletionCallback callback1; + scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); + int rv = trans->Start(&request, &callback1, log.bound()); EXPECT_EQ(ERR_IO_PENDING, rv); @@ -1789,8 +1839,6 @@ TEST_F(HttpNetworkTransactionTest, HttpsProxyAuthRetry) { session_deps.net_log = log.bound().net_log(); scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); - scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); - HttpRequestInfo request; request.method = "GET"; request.url = GURL("http://www.google.com/"); @@ -1834,6 +1882,8 @@ TEST_F(HttpNetworkTransactionTest, HttpsProxyAuthRetry) { TestCompletionCallback callback1; + scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); + int rv = trans->Start(&request, &callback1, log.bound()); EXPECT_EQ(ERR_IO_PENDING, rv); @@ -1880,8 +1930,6 @@ void HttpNetworkTransactionTest::ConnectStatusHelperWithExpectedStatus( scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); - scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); - HttpRequestInfo request; request.method = "GET"; request.url = GURL("https://www.google.com/"); @@ -1907,6 +1955,8 @@ void HttpNetworkTransactionTest::ConnectStatusHelperWithExpectedStatus( TestCompletionCallback callback; + scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); + int rv = trans->Start(&request, &callback, BoundNetLog()); EXPECT_EQ(ERR_IO_PENDING, rv); @@ -2227,8 +2277,7 @@ TEST_F(HttpNetworkTransactionTest, NTLMAuth1) { HttpAuthHandlerNTLM::ScopedProcSetter proc_setter(MockGenerateRandom1, MockGetHostName); SessionDependencies session_deps; - scoped_ptr<HttpTransaction> trans( - new HttpNetworkTransaction(CreateSession(&session_deps))); + scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); HttpRequestInfo request; request.method = "GET"; @@ -2309,6 +2358,8 @@ TEST_F(HttpNetworkTransactionTest, NTLMAuth1) { TestCompletionCallback callback1; + scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); + int rv = trans->Start(&request, &callback1, BoundNetLog()); EXPECT_EQ(ERR_IO_PENDING, rv); @@ -2354,8 +2405,7 @@ TEST_F(HttpNetworkTransactionTest, NTLMAuth2) { HttpAuthHandlerNTLM::ScopedProcSetter proc_setter(MockGenerateRandom2, MockGetHostName); SessionDependencies session_deps; - scoped_ptr<HttpTransaction> trans( - new HttpNetworkTransaction(CreateSession(&session_deps))); + scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); HttpRequestInfo request; request.method = "GET"; @@ -2487,6 +2537,8 @@ TEST_F(HttpNetworkTransactionTest, NTLMAuth2) { TestCompletionCallback callback1; + scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); + int rv = trans->Start(&request, &callback1, BoundNetLog()); EXPECT_EQ(ERR_IO_PENDING, rv); @@ -5134,8 +5186,7 @@ TEST_F(HttpNetworkTransactionTest, ConnectionClosedAfterStartOfHeaders) { // restart does the right thing. TEST_F(HttpNetworkTransactionTest, DrainResetOK) { SessionDependencies session_deps; - scoped_ptr<HttpTransaction> trans( - new HttpNetworkTransaction(CreateSession(&session_deps))); + scoped_refptr<HttpNetworkSession> session = CreateSession(&session_deps); HttpRequestInfo request; request.method = "GET"; @@ -5184,6 +5235,8 @@ TEST_F(HttpNetworkTransactionTest, DrainResetOK) { TestCompletionCallback callback1; + scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); + int rv = trans->Start(&request, &callback1, BoundNetLog()); EXPECT_EQ(ERR_IO_PENDING, rv); @@ -5488,8 +5541,6 @@ TEST_F(HttpNetworkTransactionTest, UnreadableUploadFileAfterAuthRestart) { // Tests that changes to Auth realms are treated like auth rejections. TEST_F(HttpNetworkTransactionTest, ChangeAuthRealms) { SessionDependencies session_deps; - scoped_ptr<HttpTransaction> trans( - new HttpNetworkTransaction(CreateSession(&session_deps))); HttpRequestInfo request; request.method = "GET"; @@ -5552,8 +5603,9 @@ TEST_F(HttpNetworkTransactionTest, ChangeAuthRealms) { MockRead data_reads4[] = { MockRead("HTTP/1.1 200 OK\r\n" "Content-Type: text/html; charset=iso-8859-1\r\n" - "Content-Length: 100\r\n" - "\r\n"), + "Content-Length: 5\r\n" + "\r\n" + "hello"), }; StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), @@ -5571,6 +5623,9 @@ TEST_F(HttpNetworkTransactionTest, ChangeAuthRealms) { TestCompletionCallback callback1; + scoped_ptr<HttpTransaction> trans( + new HttpNetworkTransaction(CreateSession(&session_deps))); + // Issue the first request with Authorize headers. There should be a // password prompt for first_realm waiting to be filled in after the // transaction completes. @@ -6195,9 +6250,9 @@ TEST_F(HttpNetworkTransactionTest, // specifies both the configuration for the test as well as the expectations // for the results. TEST_F(HttpNetworkTransactionTest, GenerateAuthToken) { - const char* kServer = "http://www.example.com"; - const char* kSecureServer = "https://www.example.com"; - const char* kProxy = "myproxy:70"; + static const char kServer[] = "http://www.example.com"; + static const char kSecureServer[] = "https://www.example.com"; + static const char kProxy[] = "myproxy:70"; const int kAuthErr = ERR_INVALID_AUTH_CREDENTIALS; enum AuthTiming { @@ -6482,7 +6537,6 @@ TEST_F(HttpNetworkTransactionTest, GenerateAuthToken) { }; SessionDependencies session_deps; - scoped_refptr<HttpNetworkSession> session = CreateSession(&session_deps); HttpAuthHandlerMock::Factory* auth_factory( new HttpAuthHandlerMock::Factory()); session_deps.http_auth_handler_factory.reset(auth_factory); @@ -6529,8 +6583,8 @@ TEST_F(HttpNetworkTransactionTest, GenerateAuthToken) { request.url = GURL(test_config.server_url); request.load_flags = 0; - scoped_ptr<HttpTransaction> trans( - new HttpNetworkTransaction(CreateSession(&session_deps))); + scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); + HttpNetworkTransaction trans(CreateSession(&session_deps)); for (int round = 0; round < test_config.num_auth_rounds; ++round) { const TestRound& read_write_round = test_config.rounds[round]; @@ -6565,16 +6619,16 @@ TEST_F(HttpNetworkTransactionTest, GenerateAuthToken) { TestCompletionCallback callback; int rv; if (round == 0) { - rv = trans->Start(&request, &callback, BoundNetLog()); + rv = trans.Start(&request, &callback, BoundNetLog()); } else { - rv = trans->RestartWithAuth(kFoo, kBar, &callback); + rv = trans.RestartWithAuth(kFoo, kBar, &callback); } if (rv == ERR_IO_PENDING) rv = callback.WaitForResult(); // Compare results with expected data. EXPECT_EQ(read_write_round.expected_rv, rv); - const HttpResponseInfo* response = trans->GetResponseInfo(); + const HttpResponseInfo* response = trans.GetResponseInfo(); if (read_write_round.expected_rv == OK) { EXPECT_FALSE(response == NULL); } else { @@ -6589,9 +6643,6 @@ TEST_F(HttpNetworkTransactionTest, GenerateAuthToken) { } } } - - // Flush the idle socket before the HttpNetworkTransaction goes out of scope. - session->FlushSocketPools(); } TEST_F(HttpNetworkTransactionTest, MultiRoundAuth) { @@ -7120,8 +7171,6 @@ TEST_F(HttpNetworkTransactionTest, ProxyGet) { session_deps.net_log = log.bound().net_log(); scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); - scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); - HttpRequestInfo request; request.method = "GET"; request.url = GURL("http://www.google.com/"); @@ -7145,6 +7194,8 @@ TEST_F(HttpNetworkTransactionTest, ProxyGet) { TestCompletionCallback callback1; + scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); + int rv = trans->Start(&request, &callback1, log.bound()); EXPECT_EQ(ERR_IO_PENDING, rv); @@ -7168,8 +7219,6 @@ TEST_F(HttpNetworkTransactionTest, ProxyTunnelGet) { session_deps.net_log = log.bound().net_log(); scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); - scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); - HttpRequestInfo request; request.method = "GET"; request.url = GURL("https://www.google.com/"); @@ -7202,6 +7251,8 @@ TEST_F(HttpNetworkTransactionTest, ProxyTunnelGet) { TestCompletionCallback callback1; + scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); + int rv = trans->Start(&request, &callback1, log.bound()); EXPECT_EQ(ERR_IO_PENDING, rv); @@ -7233,8 +7284,6 @@ TEST_F(HttpNetworkTransactionTest, ProxyTunnelGetHangup) { session_deps.net_log = log.bound().net_log(); scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); - scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); - HttpRequestInfo request; request.method = "GET"; request.url = GURL("https://www.google.com/"); @@ -7264,6 +7313,8 @@ TEST_F(HttpNetworkTransactionTest, ProxyTunnelGetHangup) { TestCompletionCallback callback1; + scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); + int rv = trans->Start(&request, &callback1, log.bound()); EXPECT_EQ(ERR_IO_PENDING, rv); |