OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/http/http_network_transaction.h" | 5 #include "net/http/http_network_transaction.h" |
6 | 6 |
7 #include <math.h> // ceil | 7 #include <math.h> // ceil |
8 #include <stdarg.h> | 8 #include <stdarg.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 std::string response_data; | 293 std::string response_data; |
294 int64_t total_received_bytes; | 294 int64_t total_received_bytes; |
295 int64_t total_sent_bytes; | 295 int64_t total_sent_bytes; |
296 LoadTimingInfo load_timing_info; | 296 LoadTimingInfo load_timing_info; |
297 ConnectionAttempts connection_attempts; | 297 ConnectionAttempts connection_attempts; |
298 IPEndPoint remote_endpoint_after_start; | 298 IPEndPoint remote_endpoint_after_start; |
299 }; | 299 }; |
300 | 300 |
301 void SetUp() override { | 301 void SetUp() override { |
302 NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); | 302 NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); |
303 base::MessageLoop::current()->RunUntilIdle(); | 303 base::RunLoop().RunUntilIdle(); |
304 } | 304 } |
305 | 305 |
306 void TearDown() override { | 306 void TearDown() override { |
307 NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); | 307 NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); |
308 base::MessageLoop::current()->RunUntilIdle(); | 308 base::RunLoop().RunUntilIdle(); |
309 // Empty the current queue. | 309 // Empty the current queue. |
310 base::MessageLoop::current()->RunUntilIdle(); | 310 base::RunLoop().RunUntilIdle(); |
311 PlatformTest::TearDown(); | 311 PlatformTest::TearDown(); |
312 NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); | 312 NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); |
313 base::MessageLoop::current()->RunUntilIdle(); | 313 base::RunLoop().RunUntilIdle(); |
314 } | 314 } |
315 | 315 |
316 NextProto GetProtocol() const { | 316 NextProto GetProtocol() const { |
317 return GetParam() == kTestCaseSPDY31 ? kProtoSPDY31 : kProtoHTTP2; | 317 return GetParam() == kTestCaseSPDY31 ? kProtoSPDY31 : kProtoHTTP2; |
318 } | 318 } |
319 | 319 |
320 bool GetDependenciesFromPriority() const { | 320 bool GetDependenciesFromPriority() const { |
321 return GetParam() == kTestCaseHTTP2PriorityDependencies; | 321 return GetParam() == kTestCaseHTTP2PriorityDependencies; |
322 } | 322 } |
323 | 323 |
(...skipping 1365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1689 MockRead("hello"), | 1689 MockRead("hello"), |
1690 MockRead(SYNCHRONOUS, 0), | 1690 MockRead(SYNCHRONOUS, 0), |
1691 }; | 1691 }; |
1692 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 1692 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
1693 session_deps_.socket_factory->AddSocketDataProvider(&data); | 1693 session_deps_.socket_factory->AddSocketDataProvider(&data); |
1694 | 1694 |
1695 TestCompletionCallback callback; | 1695 TestCompletionCallback callback; |
1696 | 1696 |
1697 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 1697 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
1698 EXPECT_EQ(ERR_IO_PENDING, rv); | 1698 EXPECT_EQ(ERR_IO_PENDING, rv); |
1699 base::MessageLoop::current()->RunUntilIdle(); | 1699 base::RunLoop().RunUntilIdle(); |
1700 | 1700 |
1701 // Should have deferred for network start. | 1701 // Should have deferred for network start. |
1702 EXPECT_TRUE(net_start_handler.observed_before_network_start()); | 1702 EXPECT_TRUE(net_start_handler.observed_before_network_start()); |
1703 EXPECT_EQ(LOAD_STATE_WAITING_FOR_DELEGATE, trans->GetLoadState()); | 1703 EXPECT_EQ(LOAD_STATE_WAITING_FOR_DELEGATE, trans->GetLoadState()); |
1704 | 1704 |
1705 trans->ResumeNetworkStart(); | 1705 trans->ResumeNetworkStart(); |
1706 rv = callback.WaitForResult(); | 1706 rv = callback.WaitForResult(); |
1707 EXPECT_EQ(OK, rv); | 1707 EXPECT_EQ(OK, rv); |
1708 EXPECT_TRUE(trans->GetResponseInfo()); | 1708 EXPECT_TRUE(trans->GetResponseInfo()); |
1709 | 1709 |
(...skipping 19 matching lines...) Expand all Loading... |
1729 // Defer on OnBeforeNetworkStart. | 1729 // Defer on OnBeforeNetworkStart. |
1730 BeforeNetworkStartHandler net_start_handler(true); // defer | 1730 BeforeNetworkStartHandler net_start_handler(true); // defer |
1731 trans->SetBeforeNetworkStartCallback( | 1731 trans->SetBeforeNetworkStartCallback( |
1732 base::Bind(&BeforeNetworkStartHandler::OnBeforeNetworkStart, | 1732 base::Bind(&BeforeNetworkStartHandler::OnBeforeNetworkStart, |
1733 base::Unretained(&net_start_handler))); | 1733 base::Unretained(&net_start_handler))); |
1734 | 1734 |
1735 TestCompletionCallback callback; | 1735 TestCompletionCallback callback; |
1736 | 1736 |
1737 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 1737 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
1738 EXPECT_EQ(ERR_IO_PENDING, rv); | 1738 EXPECT_EQ(ERR_IO_PENDING, rv); |
1739 base::MessageLoop::current()->RunUntilIdle(); | 1739 base::RunLoop().RunUntilIdle(); |
1740 | 1740 |
1741 // Should have deferred for network start. | 1741 // Should have deferred for network start. |
1742 EXPECT_TRUE(net_start_handler.observed_before_network_start()); | 1742 EXPECT_TRUE(net_start_handler.observed_before_network_start()); |
1743 EXPECT_EQ(LOAD_STATE_WAITING_FOR_DELEGATE, trans->GetLoadState()); | 1743 EXPECT_EQ(LOAD_STATE_WAITING_FOR_DELEGATE, trans->GetLoadState()); |
1744 } | 1744 } |
1745 | 1745 |
1746 // Next 2 cases (KeepAliveEarlyClose and KeepAliveEarlyClose2) are regression | 1746 // Next 2 cases (KeepAliveEarlyClose and KeepAliveEarlyClose2) are regression |
1747 // tests. There was a bug causing HttpNetworkTransaction to hang in the | 1747 // tests. There was a bug causing HttpNetworkTransaction to hang in the |
1748 // destructor in such situations. | 1748 // destructor in such situations. |
1749 // See http://crbug.com/154712 and http://crbug.com/156609. | 1749 // See http://crbug.com/154712 and http://crbug.com/156609. |
(...skipping 27 matching lines...) Expand all Loading... |
1777 | 1777 |
1778 scoped_refptr<IOBufferWithSize> io_buf(new IOBufferWithSize(100)); | 1778 scoped_refptr<IOBufferWithSize> io_buf(new IOBufferWithSize(100)); |
1779 rv = trans->Read(io_buf.get(), io_buf->size(), callback.callback()); | 1779 rv = trans->Read(io_buf.get(), io_buf->size(), callback.callback()); |
1780 if (rv == ERR_IO_PENDING) | 1780 if (rv == ERR_IO_PENDING) |
1781 rv = callback.WaitForResult(); | 1781 rv = callback.WaitForResult(); |
1782 EXPECT_EQ(5, rv); | 1782 EXPECT_EQ(5, rv); |
1783 rv = trans->Read(io_buf.get(), io_buf->size(), callback.callback()); | 1783 rv = trans->Read(io_buf.get(), io_buf->size(), callback.callback()); |
1784 EXPECT_EQ(ERR_CONTENT_LENGTH_MISMATCH, rv); | 1784 EXPECT_EQ(ERR_CONTENT_LENGTH_MISMATCH, rv); |
1785 | 1785 |
1786 trans.reset(); | 1786 trans.reset(); |
1787 base::MessageLoop::current()->RunUntilIdle(); | 1787 base::RunLoop().RunUntilIdle(); |
1788 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); | 1788 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); |
1789 } | 1789 } |
1790 | 1790 |
1791 TEST_P(HttpNetworkTransactionTest, KeepAliveEarlyClose2) { | 1791 TEST_P(HttpNetworkTransactionTest, KeepAliveEarlyClose2) { |
1792 HttpRequestInfo request; | 1792 HttpRequestInfo request; |
1793 request.method = "GET"; | 1793 request.method = "GET"; |
1794 request.url = GURL("http://www.example.org/"); | 1794 request.url = GURL("http://www.example.org/"); |
1795 request.load_flags = 0; | 1795 request.load_flags = 0; |
1796 | 1796 |
1797 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 1797 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
(...skipping 17 matching lines...) Expand all Loading... |
1815 rv = callback.WaitForResult(); | 1815 rv = callback.WaitForResult(); |
1816 EXPECT_EQ(OK, rv); | 1816 EXPECT_EQ(OK, rv); |
1817 | 1817 |
1818 scoped_refptr<IOBufferWithSize> io_buf(new IOBufferWithSize(100)); | 1818 scoped_refptr<IOBufferWithSize> io_buf(new IOBufferWithSize(100)); |
1819 rv = trans->Read(io_buf.get(), io_buf->size(), callback.callback()); | 1819 rv = trans->Read(io_buf.get(), io_buf->size(), callback.callback()); |
1820 if (rv == ERR_IO_PENDING) | 1820 if (rv == ERR_IO_PENDING) |
1821 rv = callback.WaitForResult(); | 1821 rv = callback.WaitForResult(); |
1822 EXPECT_EQ(ERR_CONTENT_LENGTH_MISMATCH, rv); | 1822 EXPECT_EQ(ERR_CONTENT_LENGTH_MISMATCH, rv); |
1823 | 1823 |
1824 trans.reset(); | 1824 trans.reset(); |
1825 base::MessageLoop::current()->RunUntilIdle(); | 1825 base::RunLoop().RunUntilIdle(); |
1826 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); | 1826 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); |
1827 } | 1827 } |
1828 | 1828 |
1829 // Test that we correctly reuse a keep-alive connection after not explicitly | 1829 // Test that we correctly reuse a keep-alive connection after not explicitly |
1830 // reading the body. | 1830 // reading the body. |
1831 TEST_P(HttpNetworkTransactionTest, KeepAliveAfterUnreadBody) { | 1831 TEST_P(HttpNetworkTransactionTest, KeepAliveAfterUnreadBody) { |
1832 HttpRequestInfo request; | 1832 HttpRequestInfo request; |
1833 request.method = "GET"; | 1833 request.method = "GET"; |
1834 request.url = GURL("http://www.foo.com/"); | 1834 request.url = GURL("http://www.foo.com/"); |
1835 request.load_flags = 0; | 1835 request.load_flags = 0; |
(...skipping 3020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4856 SSLSocketDataProvider ssl2(ASYNC, OK); | 4856 SSLSocketDataProvider ssl2(ASYNC, OK); |
4857 ssl2.SetNextProto(GetProtocol()); | 4857 ssl2.SetNextProto(GetProtocol()); |
4858 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl2); | 4858 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl2); |
4859 | 4859 |
4860 TestCompletionCallback callback1; | 4860 TestCompletionCallback callback1; |
4861 | 4861 |
4862 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 4862 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
4863 EXPECT_EQ(ERR_IO_PENDING, rv); | 4863 EXPECT_EQ(ERR_IO_PENDING, rv); |
4864 | 4864 |
4865 // Allow the SpdyProxyClientSocket's write callback to complete. | 4865 // Allow the SpdyProxyClientSocket's write callback to complete. |
4866 base::MessageLoop::current()->RunUntilIdle(); | 4866 base::RunLoop().RunUntilIdle(); |
4867 // Now allow the read of the response to complete. | 4867 // Now allow the read of the response to complete. |
4868 spdy_data.Resume(); | 4868 spdy_data.Resume(); |
4869 rv = callback1.WaitForResult(); | 4869 rv = callback1.WaitForResult(); |
4870 EXPECT_EQ(OK, rv); | 4870 EXPECT_EQ(OK, rv); |
4871 | 4871 |
4872 LoadTimingInfo load_timing_info; | 4872 LoadTimingInfo load_timing_info; |
4873 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); | 4873 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); |
4874 TestLoadTimingNotReused(load_timing_info, CONNECT_TIMING_HAS_SSL_TIMES); | 4874 TestLoadTimingNotReused(load_timing_info, CONNECT_TIMING_HAS_SSL_TIMES); |
4875 | 4875 |
4876 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4876 const HttpResponseInfo* response = trans->GetResponseInfo(); |
(...skipping 1287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6164 TestCompletionCallback callback1; | 6164 TestCompletionCallback callback1; |
6165 | 6165 |
6166 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 6166 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
6167 EXPECT_EQ(ERR_IO_PENDING, rv); | 6167 EXPECT_EQ(ERR_IO_PENDING, rv); |
6168 | 6168 |
6169 rv = callback1.WaitForResult(); | 6169 rv = callback1.WaitForResult(); |
6170 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv); | 6170 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv); |
6171 | 6171 |
6172 // Empty the current queue. This is necessary because idle sockets are | 6172 // Empty the current queue. This is necessary because idle sockets are |
6173 // added to the connection pool asynchronously with a PostTask. | 6173 // added to the connection pool asynchronously with a PostTask. |
6174 base::MessageLoop::current()->RunUntilIdle(); | 6174 base::RunLoop().RunUntilIdle(); |
6175 | 6175 |
6176 // We now check to make sure the TCPClientSocket was not added back to | 6176 // We now check to make sure the TCPClientSocket was not added back to |
6177 // the pool. | 6177 // the pool. |
6178 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); | 6178 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); |
6179 trans.reset(); | 6179 trans.reset(); |
6180 base::MessageLoop::current()->RunUntilIdle(); | 6180 base::RunLoop().RunUntilIdle(); |
6181 // Make sure that the socket didn't get recycled after calling the destructor. | 6181 // Make sure that the socket didn't get recycled after calling the destructor. |
6182 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); | 6182 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); |
6183 } | 6183 } |
6184 | 6184 |
6185 // Make sure that we recycle a socket after reading all of the response body. | 6185 // Make sure that we recycle a socket after reading all of the response body. |
6186 TEST_P(HttpNetworkTransactionTest, RecycleSocket) { | 6186 TEST_P(HttpNetworkTransactionTest, RecycleSocket) { |
6187 HttpRequestInfo request; | 6187 HttpRequestInfo request; |
6188 request.method = "GET"; | 6188 request.method = "GET"; |
6189 request.url = GURL("http://www.example.org/"); | 6189 request.url = GURL("http://www.example.org/"); |
6190 request.load_flags = 0; | 6190 request.load_flags = 0; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6224 | 6224 |
6225 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); | 6225 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); |
6226 | 6226 |
6227 std::string response_data; | 6227 std::string response_data; |
6228 rv = ReadTransaction(trans.get(), &response_data); | 6228 rv = ReadTransaction(trans.get(), &response_data); |
6229 EXPECT_EQ(OK, rv); | 6229 EXPECT_EQ(OK, rv); |
6230 EXPECT_EQ("hello world", response_data); | 6230 EXPECT_EQ("hello world", response_data); |
6231 | 6231 |
6232 // Empty the current queue. This is necessary because idle sockets are | 6232 // Empty the current queue. This is necessary because idle sockets are |
6233 // added to the connection pool asynchronously with a PostTask. | 6233 // added to the connection pool asynchronously with a PostTask. |
6234 base::MessageLoop::current()->RunUntilIdle(); | 6234 base::RunLoop().RunUntilIdle(); |
6235 | 6235 |
6236 // We now check to make sure the socket was added back to the pool. | 6236 // We now check to make sure the socket was added back to the pool. |
6237 EXPECT_EQ(1, GetIdleSocketCountInTransportSocketPool(session.get())); | 6237 EXPECT_EQ(1, GetIdleSocketCountInTransportSocketPool(session.get())); |
6238 } | 6238 } |
6239 | 6239 |
6240 // Make sure that we recycle a SSL socket after reading all of the response | 6240 // Make sure that we recycle a SSL socket after reading all of the response |
6241 // body. | 6241 // body. |
6242 TEST_P(HttpNetworkTransactionTest, RecycleSSLSocket) { | 6242 TEST_P(HttpNetworkTransactionTest, RecycleSSLSocket) { |
6243 HttpRequestInfo request; | 6243 HttpRequestInfo request; |
6244 request.method = "GET"; | 6244 request.method = "GET"; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6284 | 6284 |
6285 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); | 6285 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); |
6286 | 6286 |
6287 std::string response_data; | 6287 std::string response_data; |
6288 rv = ReadTransaction(trans.get(), &response_data); | 6288 rv = ReadTransaction(trans.get(), &response_data); |
6289 EXPECT_EQ(OK, rv); | 6289 EXPECT_EQ(OK, rv); |
6290 EXPECT_EQ("hello world", response_data); | 6290 EXPECT_EQ("hello world", response_data); |
6291 | 6291 |
6292 // Empty the current queue. This is necessary because idle sockets are | 6292 // Empty the current queue. This is necessary because idle sockets are |
6293 // added to the connection pool asynchronously with a PostTask. | 6293 // added to the connection pool asynchronously with a PostTask. |
6294 base::MessageLoop::current()->RunUntilIdle(); | 6294 base::RunLoop().RunUntilIdle(); |
6295 | 6295 |
6296 // We now check to make sure the socket was added back to the pool. | 6296 // We now check to make sure the socket was added back to the pool. |
6297 EXPECT_EQ(1, GetIdleSocketCountInSSLSocketPool(session.get())); | 6297 EXPECT_EQ(1, GetIdleSocketCountInSSLSocketPool(session.get())); |
6298 } | 6298 } |
6299 | 6299 |
6300 // Grab a SSL socket, use it, and put it back into the pool. Then, reuse it | 6300 // Grab a SSL socket, use it, and put it back into the pool. Then, reuse it |
6301 // from the pool and make sure that we recover okay. | 6301 // from the pool and make sure that we recover okay. |
6302 TEST_P(HttpNetworkTransactionTest, RecycleDeadSSLSocket) { | 6302 TEST_P(HttpNetworkTransactionTest, RecycleDeadSSLSocket) { |
6303 HttpRequestInfo request; | 6303 HttpRequestInfo request; |
6304 request.method = "GET"; | 6304 request.method = "GET"; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6350 | 6350 |
6351 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); | 6351 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); |
6352 | 6352 |
6353 std::string response_data; | 6353 std::string response_data; |
6354 rv = ReadTransaction(trans.get(), &response_data); | 6354 rv = ReadTransaction(trans.get(), &response_data); |
6355 EXPECT_EQ(OK, rv); | 6355 EXPECT_EQ(OK, rv); |
6356 EXPECT_EQ("hello world", response_data); | 6356 EXPECT_EQ("hello world", response_data); |
6357 | 6357 |
6358 // Empty the current queue. This is necessary because idle sockets are | 6358 // Empty the current queue. This is necessary because idle sockets are |
6359 // added to the connection pool asynchronously with a PostTask. | 6359 // added to the connection pool asynchronously with a PostTask. |
6360 base::MessageLoop::current()->RunUntilIdle(); | 6360 base::RunLoop().RunUntilIdle(); |
6361 | 6361 |
6362 // We now check to make sure the socket was added back to the pool. | 6362 // We now check to make sure the socket was added back to the pool. |
6363 EXPECT_EQ(1, GetIdleSocketCountInSSLSocketPool(session.get())); | 6363 EXPECT_EQ(1, GetIdleSocketCountInSSLSocketPool(session.get())); |
6364 | 6364 |
6365 // Now start the second transaction, which should reuse the previous socket. | 6365 // Now start the second transaction, which should reuse the previous socket. |
6366 | 6366 |
6367 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 6367 trans.reset(new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
6368 | 6368 |
6369 rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 6369 rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
6370 | 6370 |
6371 EXPECT_EQ(ERR_IO_PENDING, rv); | 6371 EXPECT_EQ(ERR_IO_PENDING, rv); |
6372 EXPECT_EQ(OK, callback.WaitForResult()); | 6372 EXPECT_EQ(OK, callback.WaitForResult()); |
6373 | 6373 |
6374 response = trans->GetResponseInfo(); | 6374 response = trans->GetResponseInfo(); |
6375 ASSERT_TRUE(response); | 6375 ASSERT_TRUE(response); |
6376 ASSERT_TRUE(response->headers); | 6376 ASSERT_TRUE(response->headers); |
6377 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 6377 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
6378 | 6378 |
6379 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); | 6379 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); |
6380 | 6380 |
6381 rv = ReadTransaction(trans.get(), &response_data); | 6381 rv = ReadTransaction(trans.get(), &response_data); |
6382 EXPECT_EQ(OK, rv); | 6382 EXPECT_EQ(OK, rv); |
6383 EXPECT_EQ("hello world", response_data); | 6383 EXPECT_EQ("hello world", response_data); |
6384 | 6384 |
6385 // Empty the current queue. This is necessary because idle sockets are | 6385 // Empty the current queue. This is necessary because idle sockets are |
6386 // added to the connection pool asynchronously with a PostTask. | 6386 // added to the connection pool asynchronously with a PostTask. |
6387 base::MessageLoop::current()->RunUntilIdle(); | 6387 base::RunLoop().RunUntilIdle(); |
6388 | 6388 |
6389 // We now check to make sure the socket was added back to the pool. | 6389 // We now check to make sure the socket was added back to the pool. |
6390 EXPECT_EQ(1, GetIdleSocketCountInSSLSocketPool(session.get())); | 6390 EXPECT_EQ(1, GetIdleSocketCountInSSLSocketPool(session.get())); |
6391 } | 6391 } |
6392 | 6392 |
6393 // Make sure that we recycle a socket after a zero-length response. | 6393 // Make sure that we recycle a socket after a zero-length response. |
6394 // http://crbug.com/9880 | 6394 // http://crbug.com/9880 |
6395 TEST_P(HttpNetworkTransactionTest, RecycleSocketAfterZeroContentLength) { | 6395 TEST_P(HttpNetworkTransactionTest, RecycleSocketAfterZeroContentLength) { |
6396 HttpRequestInfo request; | 6396 HttpRequestInfo request; |
6397 request.method = "GET"; | 6397 request.method = "GET"; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6437 | 6437 |
6438 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); | 6438 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); |
6439 | 6439 |
6440 std::string response_data; | 6440 std::string response_data; |
6441 rv = ReadTransaction(trans.get(), &response_data); | 6441 rv = ReadTransaction(trans.get(), &response_data); |
6442 EXPECT_EQ(OK, rv); | 6442 EXPECT_EQ(OK, rv); |
6443 EXPECT_EQ("", response_data); | 6443 EXPECT_EQ("", response_data); |
6444 | 6444 |
6445 // Empty the current queue. This is necessary because idle sockets are | 6445 // Empty the current queue. This is necessary because idle sockets are |
6446 // added to the connection pool asynchronously with a PostTask. | 6446 // added to the connection pool asynchronously with a PostTask. |
6447 base::MessageLoop::current()->RunUntilIdle(); | 6447 base::RunLoop().RunUntilIdle(); |
6448 | 6448 |
6449 // We now check to make sure the socket was added back to the pool. | 6449 // We now check to make sure the socket was added back to the pool. |
6450 EXPECT_EQ(1, GetIdleSocketCountInTransportSocketPool(session.get())); | 6450 EXPECT_EQ(1, GetIdleSocketCountInTransportSocketPool(session.get())); |
6451 } | 6451 } |
6452 | 6452 |
6453 TEST_P(HttpNetworkTransactionTest, ResendRequestOnWriteBodyError) { | 6453 TEST_P(HttpNetworkTransactionTest, ResendRequestOnWriteBodyError) { |
6454 std::vector<std::unique_ptr<UploadElementReader>> element_readers; | 6454 std::vector<std::unique_ptr<UploadElementReader>> element_readers; |
6455 element_readers.push_back( | 6455 element_readers.push_back( |
6456 base::WrapUnique(new UploadBytesElementReader("foo", 3))); | 6456 base::WrapUnique(new UploadBytesElementReader("foo", 3))); |
6457 ElementsUploadDataStream upload_data_stream(std::move(element_readers), 0); | 6457 ElementsUploadDataStream upload_data_stream(std::move(element_readers), 0); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6610 | 6610 |
6611 const HttpResponseInfo* response = trans->GetResponseInfo(); | 6611 const HttpResponseInfo* response = trans->GetResponseInfo(); |
6612 ASSERT_TRUE(response); | 6612 ASSERT_TRUE(response); |
6613 | 6613 |
6614 // There is no challenge info, since the identity in URL worked. | 6614 // There is no challenge info, since the identity in URL worked. |
6615 EXPECT_FALSE(response->auth_challenge); | 6615 EXPECT_FALSE(response->auth_challenge); |
6616 | 6616 |
6617 EXPECT_EQ(100, response->headers->GetContentLength()); | 6617 EXPECT_EQ(100, response->headers->GetContentLength()); |
6618 | 6618 |
6619 // Empty the current queue. | 6619 // Empty the current queue. |
6620 base::MessageLoop::current()->RunUntilIdle(); | 6620 base::RunLoop().RunUntilIdle(); |
6621 } | 6621 } |
6622 | 6622 |
6623 // Test the request-challenge-retry sequence for basic auth when there is an | 6623 // Test the request-challenge-retry sequence for basic auth when there is an |
6624 // incorrect identity in the URL. The identity from the URL should be used only | 6624 // incorrect identity in the URL. The identity from the URL should be used only |
6625 // once. | 6625 // once. |
6626 TEST_P(HttpNetworkTransactionTest, WrongAuthIdentityInURL) { | 6626 TEST_P(HttpNetworkTransactionTest, WrongAuthIdentityInURL) { |
6627 HttpRequestInfo request; | 6627 HttpRequestInfo request; |
6628 request.method = "GET"; | 6628 request.method = "GET"; |
6629 // Note: the URL has a username:password in it. The password "baz" is | 6629 // Note: the URL has a username:password in it. The password "baz" is |
6630 // wrong (should be "bar"). | 6630 // wrong (should be "bar"). |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6723 | 6723 |
6724 response = trans->GetResponseInfo(); | 6724 response = trans->GetResponseInfo(); |
6725 ASSERT_TRUE(response); | 6725 ASSERT_TRUE(response); |
6726 | 6726 |
6727 // There is no challenge info, since the identity worked. | 6727 // There is no challenge info, since the identity worked. |
6728 EXPECT_FALSE(response->auth_challenge); | 6728 EXPECT_FALSE(response->auth_challenge); |
6729 | 6729 |
6730 EXPECT_EQ(100, response->headers->GetContentLength()); | 6730 EXPECT_EQ(100, response->headers->GetContentLength()); |
6731 | 6731 |
6732 // Empty the current queue. | 6732 // Empty the current queue. |
6733 base::MessageLoop::current()->RunUntilIdle(); | 6733 base::RunLoop().RunUntilIdle(); |
6734 } | 6734 } |
6735 | 6735 |
6736 | 6736 |
6737 // Test the request-challenge-retry sequence for basic auth when there is a | 6737 // Test the request-challenge-retry sequence for basic auth when there is a |
6738 // correct identity in the URL, but its use is being suppressed. The identity | 6738 // correct identity in the URL, but its use is being suppressed. The identity |
6739 // from the URL should never be used. | 6739 // from the URL should never be used. |
6740 TEST_P(HttpNetworkTransactionTest, AuthIdentityInURLSuppressed) { | 6740 TEST_P(HttpNetworkTransactionTest, AuthIdentityInURLSuppressed) { |
6741 HttpRequestInfo request; | 6741 HttpRequestInfo request; |
6742 request.method = "GET"; | 6742 request.method = "GET"; |
6743 request.url = GURL("http://foo:bar@www.example.org/"); | 6743 request.url = GURL("http://foo:bar@www.example.org/"); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6805 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 6805 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
6806 | 6806 |
6807 response = trans->GetResponseInfo(); | 6807 response = trans->GetResponseInfo(); |
6808 ASSERT_TRUE(response); | 6808 ASSERT_TRUE(response); |
6809 | 6809 |
6810 // There is no challenge info, since the identity worked. | 6810 // There is no challenge info, since the identity worked. |
6811 EXPECT_FALSE(response->auth_challenge); | 6811 EXPECT_FALSE(response->auth_challenge); |
6812 EXPECT_EQ(100, response->headers->GetContentLength()); | 6812 EXPECT_EQ(100, response->headers->GetContentLength()); |
6813 | 6813 |
6814 // Empty the current queue. | 6814 // Empty the current queue. |
6815 base::MessageLoop::current()->RunUntilIdle(); | 6815 base::RunLoop().RunUntilIdle(); |
6816 } | 6816 } |
6817 | 6817 |
6818 // Test that previously tried username/passwords for a realm get re-used. | 6818 // Test that previously tried username/passwords for a realm get re-used. |
6819 TEST_P(HttpNetworkTransactionTest, BasicAuthCacheAndPreauth) { | 6819 TEST_P(HttpNetworkTransactionTest, BasicAuthCacheAndPreauth) { |
6820 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 6820 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
6821 | 6821 |
6822 // Transaction 1: authenticate (foo, bar) on MyRealm1 | 6822 // Transaction 1: authenticate (foo, bar) on MyRealm1 |
6823 { | 6823 { |
6824 HttpRequestInfo request; | 6824 HttpRequestInfo request; |
6825 request.method = "GET"; | 6825 request.method = "GET"; |
(...skipping 2930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9756 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 9756 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
9757 std::unique_ptr<HttpTransaction> trans( | 9757 std::unique_ptr<HttpTransaction> trans( |
9758 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 9758 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
9759 | 9759 |
9760 StaticSocketDataProvider data; | 9760 StaticSocketDataProvider data; |
9761 session_deps_.socket_factory->AddSocketDataProvider(&data); | 9761 session_deps_.socket_factory->AddSocketDataProvider(&data); |
9762 | 9762 |
9763 TestCompletionCallback callback; | 9763 TestCompletionCallback callback; |
9764 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 9764 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
9765 EXPECT_EQ(ERR_IO_PENDING, rv); | 9765 EXPECT_EQ(ERR_IO_PENDING, rv); |
9766 base::MessageLoop::current()->RunUntilIdle(); | 9766 base::RunLoop().RunUntilIdle(); |
9767 | 9767 |
9768 // Transaction is pending on request body initialization. | 9768 // Transaction is pending on request body initialization. |
9769 ASSERT_FALSE(fake_reader->callback().is_null()); | 9769 ASSERT_FALSE(fake_reader->callback().is_null()); |
9770 | 9770 |
9771 // Return Init()'s result after the transaction gets destroyed. | 9771 // Return Init()'s result after the transaction gets destroyed. |
9772 trans.reset(); | 9772 trans.reset(); |
9773 fake_reader->callback().Run(OK); // Should not crash. | 9773 fake_reader->callback().Run(OK); // Should not crash. |
9774 } | 9774 } |
9775 | 9775 |
9776 // Tests that changes to Auth realms are treated like auth rejections. | 9776 // Tests that changes to Auth realms are treated like auth rejections. |
(...skipping 2509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12286 data.set_connect_data(mock_connect); | 12286 data.set_connect_data(mock_connect); |
12287 session_deps_.socket_factory->AddSocketDataProvider(&data); | 12287 session_deps_.socket_factory->AddSocketDataProvider(&data); |
12288 | 12288 |
12289 TestCompletionCallback callback; | 12289 TestCompletionCallback callback; |
12290 | 12290 |
12291 BoundTestNetLog log; | 12291 BoundTestNetLog log; |
12292 int rv = trans->Start(&request, callback.callback(), log.bound()); | 12292 int rv = trans->Start(&request, callback.callback(), log.bound()); |
12293 EXPECT_EQ(ERR_IO_PENDING, rv); | 12293 EXPECT_EQ(ERR_IO_PENDING, rv); |
12294 trans.reset(); // Cancel the transaction here. | 12294 trans.reset(); // Cancel the transaction here. |
12295 | 12295 |
12296 base::MessageLoop::current()->RunUntilIdle(); | 12296 base::RunLoop().RunUntilIdle(); |
12297 } | 12297 } |
12298 | 12298 |
12299 // Test that if a transaction is cancelled after receiving the headers, the | 12299 // Test that if a transaction is cancelled after receiving the headers, the |
12300 // stream is drained properly and added back to the socket pool. The main | 12300 // stream is drained properly and added back to the socket pool. The main |
12301 // purpose of this test is to make sure that an HttpStreamParser can be read | 12301 // purpose of this test is to make sure that an HttpStreamParser can be read |
12302 // from after the HttpNetworkTransaction and the objects it owns have been | 12302 // from after the HttpNetworkTransaction and the objects it owns have been |
12303 // deleted. | 12303 // deleted. |
12304 // See http://crbug.com/368418 | 12304 // See http://crbug.com/368418 |
12305 TEST_P(HttpNetworkTransactionTest, CancelAfterHeaders) { | 12305 TEST_P(HttpNetworkTransactionTest, CancelAfterHeaders) { |
12306 MockRead data_reads[] = { | 12306 MockRead data_reads[] = { |
(...skipping 26 matching lines...) Expand all Loading... |
12333 | 12333 |
12334 const HttpResponseInfo* response = trans.GetResponseInfo(); | 12334 const HttpResponseInfo* response = trans.GetResponseInfo(); |
12335 ASSERT_TRUE(response); | 12335 ASSERT_TRUE(response); |
12336 EXPECT_TRUE(response->headers); | 12336 EXPECT_TRUE(response->headers); |
12337 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 12337 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
12338 | 12338 |
12339 // The transaction and HttpRequestInfo are deleted. | 12339 // The transaction and HttpRequestInfo are deleted. |
12340 } | 12340 } |
12341 | 12341 |
12342 // Let the HttpResponseBodyDrainer drain the socket. | 12342 // Let the HttpResponseBodyDrainer drain the socket. |
12343 base::MessageLoop::current()->RunUntilIdle(); | 12343 base::RunLoop().RunUntilIdle(); |
12344 | 12344 |
12345 // Socket should now be idle, waiting to be reused. | 12345 // Socket should now be idle, waiting to be reused. |
12346 EXPECT_EQ(1, GetIdleSocketCountInTransportSocketPool(session.get())); | 12346 EXPECT_EQ(1, GetIdleSocketCountInTransportSocketPool(session.get())); |
12347 } | 12347 } |
12348 | 12348 |
12349 // Test a basic GET request through a proxy. | 12349 // Test a basic GET request through a proxy. |
12350 TEST_P(HttpNetworkTransactionTest, ProxyGet) { | 12350 TEST_P(HttpNetworkTransactionTest, ProxyGet) { |
12351 session_deps_.proxy_service = | 12351 session_deps_.proxy_service = |
12352 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70"); | 12352 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70"); |
12353 BoundTestNetLog log; | 12353 BoundTestNetLog log; |
(...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13401 | 13401 |
13402 // Start the first transaction to set up the SpdySession | 13402 // Start the first transaction to set up the SpdySession |
13403 HttpRequestInfo request1; | 13403 HttpRequestInfo request1; |
13404 request1.method = "GET"; | 13404 request1.method = "GET"; |
13405 request1.url = GURL(https_url); | 13405 request1.url = GURL(https_url); |
13406 request1.load_flags = 0; | 13406 request1.load_flags = 0; |
13407 HttpNetworkTransaction trans1(LOWEST, session.get()); | 13407 HttpNetworkTransaction trans1(LOWEST, session.get()); |
13408 TestCompletionCallback callback1; | 13408 TestCompletionCallback callback1; |
13409 EXPECT_EQ(ERR_IO_PENDING, | 13409 EXPECT_EQ(ERR_IO_PENDING, |
13410 trans1.Start(&request1, callback1.callback(), BoundNetLog())); | 13410 trans1.Start(&request1, callback1.callback(), BoundNetLog())); |
13411 base::MessageLoop::current()->RunUntilIdle(); | 13411 base::RunLoop().RunUntilIdle(); |
13412 | 13412 |
13413 EXPECT_EQ(OK, callback1.WaitForResult()); | 13413 EXPECT_EQ(OK, callback1.WaitForResult()); |
13414 EXPECT_TRUE(trans1.GetResponseInfo()->was_fetched_via_spdy); | 13414 EXPECT_TRUE(trans1.GetResponseInfo()->was_fetched_via_spdy); |
13415 | 13415 |
13416 // Now, start the HTTP request | 13416 // Now, start the HTTP request |
13417 HttpRequestInfo request2; | 13417 HttpRequestInfo request2; |
13418 request2.method = "GET"; | 13418 request2.method = "GET"; |
13419 request2.url = GURL(http_url); | 13419 request2.url = GURL(http_url); |
13420 request2.load_flags = 0; | 13420 request2.load_flags = 0; |
13421 HttpNetworkTransaction trans2(MEDIUM, session.get()); | 13421 HttpNetworkTransaction trans2(MEDIUM, session.get()); |
13422 TestCompletionCallback callback2; | 13422 TestCompletionCallback callback2; |
13423 EXPECT_EQ(ERR_IO_PENDING, | 13423 EXPECT_EQ(ERR_IO_PENDING, |
13424 trans2.Start(&request2, callback2.callback(), BoundNetLog())); | 13424 trans2.Start(&request2, callback2.callback(), BoundNetLog())); |
13425 base::MessageLoop::current()->RunUntilIdle(); | 13425 base::RunLoop().RunUntilIdle(); |
13426 | 13426 |
13427 EXPECT_EQ(OK, callback2.WaitForResult()); | 13427 EXPECT_EQ(OK, callback2.WaitForResult()); |
13428 EXPECT_FALSE(trans2.GetResponseInfo()->was_fetched_via_spdy); | 13428 EXPECT_FALSE(trans2.GetResponseInfo()->was_fetched_via_spdy); |
13429 } | 13429 } |
13430 | 13430 |
13431 class AltSvcCertificateVerificationTest : public HttpNetworkTransactionTest { | 13431 class AltSvcCertificateVerificationTest : public HttpNetworkTransactionTest { |
13432 public: | 13432 public: |
13433 void Run(bool pooling, bool valid) { | 13433 void Run(bool pooling, bool valid) { |
13434 url::SchemeHostPort server(GURL(valid ? "https://mail.example.org:443" | 13434 url::SchemeHostPort server(GURL(valid ? "https://mail.example.org:443" |
13435 : "https://invalid.example.org:443")); | 13435 : "https://invalid.example.org:443")); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13539 std::unique_ptr<HttpTransaction> trans1( | 13539 std::unique_ptr<HttpTransaction> trans1( |
13540 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 13540 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
13541 HttpRequestInfo request1; | 13541 HttpRequestInfo request1; |
13542 request1.method = "GET"; | 13542 request1.method = "GET"; |
13543 request1.url = GURL(url1); | 13543 request1.url = GURL(url1); |
13544 request1.load_flags = 0; | 13544 request1.load_flags = 0; |
13545 TestCompletionCallback callback1; | 13545 TestCompletionCallback callback1; |
13546 | 13546 |
13547 int rv = trans1->Start(&request1, callback1.callback(), BoundNetLog()); | 13547 int rv = trans1->Start(&request1, callback1.callback(), BoundNetLog()); |
13548 EXPECT_EQ(ERR_IO_PENDING, rv); | 13548 EXPECT_EQ(ERR_IO_PENDING, rv); |
13549 base::MessageLoop::current()->RunUntilIdle(); | 13549 base::RunLoop().RunUntilIdle(); |
13550 if (data.IsPaused()) | 13550 if (data.IsPaused()) |
13551 data.Resume(); | 13551 data.Resume(); |
13552 rv = callback1.WaitForResult(); | 13552 rv = callback1.WaitForResult(); |
13553 if (valid) { | 13553 if (valid) { |
13554 EXPECT_EQ(OK, rv); | 13554 EXPECT_EQ(OK, rv); |
13555 } else { | 13555 } else { |
13556 if (pooling) { | 13556 if (pooling) { |
13557 EXPECT_EQ(ERR_CONNECTION_REFUSED, rv); | 13557 EXPECT_EQ(ERR_CONNECTION_REFUSED, rv); |
13558 } else { | 13558 } else { |
13559 EXPECT_EQ(ERR_ALTERNATIVE_CERT_NOT_VALID_FOR_ORIGIN, rv); | 13559 EXPECT_EQ(ERR_ALTERNATIVE_CERT_NOT_VALID_FOR_ORIGIN, rv); |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14094 | 14094 |
14095 // Now, start the HTTP request | 14095 // Now, start the HTTP request |
14096 HttpRequestInfo request2; | 14096 HttpRequestInfo request2; |
14097 request2.method = "GET"; | 14097 request2.method = "GET"; |
14098 request2.url = GURL(url2); | 14098 request2.url = GURL(url2); |
14099 request2.load_flags = 0; | 14099 request2.load_flags = 0; |
14100 HttpNetworkTransaction trans2(MEDIUM, session.get()); | 14100 HttpNetworkTransaction trans2(MEDIUM, session.get()); |
14101 TestCompletionCallback callback2; | 14101 TestCompletionCallback callback2; |
14102 EXPECT_EQ(ERR_IO_PENDING, | 14102 EXPECT_EQ(ERR_IO_PENDING, |
14103 trans2.Start(&request2, callback2.callback(), BoundNetLog())); | 14103 trans2.Start(&request2, callback2.callback(), BoundNetLog())); |
14104 base::MessageLoop::current()->RunUntilIdle(); | 14104 base::RunLoop().RunUntilIdle(); |
14105 | 14105 |
14106 ASSERT_TRUE(callback2.have_result()); | 14106 ASSERT_TRUE(callback2.have_result()); |
14107 EXPECT_EQ(OK, callback2.WaitForResult()); | 14107 EXPECT_EQ(OK, callback2.WaitForResult()); |
14108 EXPECT_TRUE(trans2.GetResponseInfo()->was_fetched_via_spdy); | 14108 EXPECT_TRUE(trans2.GetResponseInfo()->was_fetched_via_spdy); |
14109 } | 14109 } |
14110 | 14110 |
14111 // Test to verify that a failed socket read (due to an ERR_CONNECTION_CLOSED | 14111 // Test to verify that a failed socket read (due to an ERR_CONNECTION_CLOSED |
14112 // error) in SPDY session, removes the socket from pool and closes the SPDY | 14112 // error) in SPDY session, removes the socket from pool and closes the SPDY |
14113 // session. Verify that new url's from the same HttpNetworkSession (and a new | 14113 // session. Verify that new url's from the same HttpNetworkSession (and a new |
14114 // SpdySession) do work. http://crbug.com/224701 | 14114 // SpdySession) do work. http://crbug.com/224701 |
(...skipping 1989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16104 StaticSocketDataProvider data(reads, arraysize(reads), nullptr, 0); | 16104 StaticSocketDataProvider data(reads, arraysize(reads), nullptr, 0); |
16105 session_deps_.socket_factory->AddSocketDataProvider(&data); | 16105 session_deps_.socket_factory->AddSocketDataProvider(&data); |
16106 session_deps_.channel_id_service.reset(new ChannelIDService( | 16106 session_deps_.channel_id_service.reset(new ChannelIDService( |
16107 new DefaultChannelIDStore(nullptr), base::ThreadTaskRunnerHandle::Get())); | 16107 new DefaultChannelIDStore(nullptr), base::ThreadTaskRunnerHandle::Get())); |
16108 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 16108 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
16109 | 16109 |
16110 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); | 16110 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); |
16111 TestCompletionCallback callback; | 16111 TestCompletionCallback callback; |
16112 EXPECT_EQ(ERR_IO_PENDING, | 16112 EXPECT_EQ(ERR_IO_PENDING, |
16113 trans.Start(&request, callback.callback(), BoundNetLog())); | 16113 trans.Start(&request, callback.callback(), BoundNetLog())); |
16114 base::MessageLoop::current()->RunUntilIdle(); | 16114 base::RunLoop().RunUntilIdle(); |
16115 | 16115 |
16116 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); | 16116 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); |
16117 HttpRequestHeaders headers; | 16117 HttpRequestHeaders headers; |
16118 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); | 16118 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); |
16119 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); | 16119 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); |
16120 } | 16120 } |
16121 #endif // !defined(OS_IOS) | 16121 #endif // !defined(OS_IOS) |
16122 | 16122 |
16123 } // namespace net | 16123 } // namespace net |
OLD | NEW |