OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 27 matching lines...) Expand all Loading... |
38 #include "net/http/http_network_session.h" | 38 #include "net/http/http_network_session.h" |
39 #include "net/http/http_network_session_peer.h" | 39 #include "net/http/http_network_session_peer.h" |
40 #include "net/http/http_server_properties_impl.h" | 40 #include "net/http/http_server_properties_impl.h" |
41 #include "net/http/http_stream.h" | 41 #include "net/http/http_stream.h" |
42 #include "net/http/http_stream_factory.h" | 42 #include "net/http/http_stream_factory.h" |
43 #include "net/http/http_transaction_unittest.h" | 43 #include "net/http/http_transaction_unittest.h" |
44 #include "net/proxy/proxy_config_service_fixed.h" | 44 #include "net/proxy/proxy_config_service_fixed.h" |
45 #include "net/proxy/proxy_resolver.h" | 45 #include "net/proxy/proxy_resolver.h" |
46 #include "net/proxy/proxy_service.h" | 46 #include "net/proxy/proxy_service.h" |
47 #include "net/socket/client_socket_factory.h" | 47 #include "net/socket/client_socket_factory.h" |
| 48 #include "net/socket/mock_client_socket_pool_manager.h" |
48 #include "net/socket/socket_test_util.h" | 49 #include "net/socket/socket_test_util.h" |
49 #include "net/socket/ssl_client_socket.h" | 50 #include "net/socket/ssl_client_socket.h" |
50 #include "net/spdy/spdy_framer.h" | 51 #include "net/spdy/spdy_framer.h" |
51 #include "net/spdy/spdy_session.h" | 52 #include "net/spdy/spdy_session.h" |
52 #include "net/spdy/spdy_session_pool.h" | 53 #include "net/spdy/spdy_session_pool.h" |
53 #include "net/spdy/spdy_test_util.h" | 54 #include "net/spdy/spdy_test_util.h" |
54 #include "testing/gtest/include/gtest/gtest.h" | 55 #include "testing/gtest/include/gtest/gtest.h" |
55 #include "testing/platform_test.h" | 56 #include "testing/platform_test.h" |
56 | 57 |
57 //----------------------------------------------------------------------------- | 58 //----------------------------------------------------------------------------- |
(...skipping 5561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5619 | 5620 |
5620 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | 5621 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { |
5621 SessionDependencies session_deps( | 5622 SessionDependencies session_deps( |
5622 ProxyService::CreateFixed(tests[i].proxy_server)); | 5623 ProxyService::CreateFixed(tests[i].proxy_server)); |
5623 scoped_refptr<HttpNetworkSession> session( | 5624 scoped_refptr<HttpNetworkSession> session( |
5624 SetupSessionForGroupNameTests(&session_deps)); | 5625 SetupSessionForGroupNameTests(&session_deps)); |
5625 | 5626 |
5626 HttpNetworkSessionPeer peer(session); | 5627 HttpNetworkSessionPeer peer(session); |
5627 CaptureGroupNameTransportSocketPool* transport_conn_pool = | 5628 CaptureGroupNameTransportSocketPool* transport_conn_pool = |
5628 new CaptureGroupNameTransportSocketPool(NULL, NULL); | 5629 new CaptureGroupNameTransportSocketPool(NULL, NULL); |
5629 peer.SetTransportSocketPool(transport_conn_pool); | |
5630 CaptureGroupNameSSLSocketPool* ssl_conn_pool = | 5630 CaptureGroupNameSSLSocketPool* ssl_conn_pool = |
5631 new CaptureGroupNameSSLSocketPool(NULL, NULL); | 5631 new CaptureGroupNameSSLSocketPool(NULL, NULL); |
5632 peer.SetSSLSocketPool(ssl_conn_pool); | 5632 MockClientSocketPoolManager* mock_pool_manager = |
| 5633 new MockClientSocketPoolManager; |
| 5634 mock_pool_manager->SetTransportSocketPool(transport_conn_pool); |
| 5635 mock_pool_manager->SetSSLSocketPool(ssl_conn_pool); |
| 5636 peer.SetClientSocketPoolManager(mock_pool_manager); |
5633 | 5637 |
5634 EXPECT_EQ(ERR_IO_PENDING, | 5638 EXPECT_EQ(ERR_IO_PENDING, |
5635 GroupNameTransactionHelper(tests[i].url, session)); | 5639 GroupNameTransactionHelper(tests[i].url, session)); |
5636 if (tests[i].ssl) | 5640 if (tests[i].ssl) |
5637 EXPECT_EQ(tests[i].expected_group_name, | 5641 EXPECT_EQ(tests[i].expected_group_name, |
5638 ssl_conn_pool->last_group_name_received()); | 5642 ssl_conn_pool->last_group_name_received()); |
5639 else | 5643 else |
5640 EXPECT_EQ(tests[i].expected_group_name, | 5644 EXPECT_EQ(tests[i].expected_group_name, |
5641 transport_conn_pool->last_group_name_received()); | 5645 transport_conn_pool->last_group_name_received()); |
5642 } | 5646 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5675 SessionDependencies session_deps( | 5679 SessionDependencies session_deps( |
5676 ProxyService::CreateFixed(tests[i].proxy_server)); | 5680 ProxyService::CreateFixed(tests[i].proxy_server)); |
5677 scoped_refptr<HttpNetworkSession> session( | 5681 scoped_refptr<HttpNetworkSession> session( |
5678 SetupSessionForGroupNameTests(&session_deps)); | 5682 SetupSessionForGroupNameTests(&session_deps)); |
5679 | 5683 |
5680 HttpNetworkSessionPeer peer(session); | 5684 HttpNetworkSessionPeer peer(session); |
5681 | 5685 |
5682 HostPortPair proxy_host("http_proxy", 80); | 5686 HostPortPair proxy_host("http_proxy", 80); |
5683 CaptureGroupNameHttpProxySocketPool* http_proxy_pool = | 5687 CaptureGroupNameHttpProxySocketPool* http_proxy_pool = |
5684 new CaptureGroupNameHttpProxySocketPool(NULL, NULL); | 5688 new CaptureGroupNameHttpProxySocketPool(NULL, NULL); |
5685 peer.SetSocketPoolForHTTPProxy(proxy_host, http_proxy_pool); | |
5686 CaptureGroupNameSSLSocketPool* ssl_conn_pool = | 5689 CaptureGroupNameSSLSocketPool* ssl_conn_pool = |
5687 new CaptureGroupNameSSLSocketPool(NULL, NULL); | 5690 new CaptureGroupNameSSLSocketPool(NULL, NULL); |
5688 peer.SetSocketPoolForSSLWithProxy(proxy_host, ssl_conn_pool); | 5691 |
| 5692 MockClientSocketPoolManager* mock_pool_manager = |
| 5693 new MockClientSocketPoolManager; |
| 5694 mock_pool_manager->SetSocketPoolForHTTPProxy(proxy_host, http_proxy_pool); |
| 5695 mock_pool_manager->SetSocketPoolForSSLWithProxy(proxy_host, ssl_conn_pool); |
| 5696 peer.SetClientSocketPoolManager(mock_pool_manager); |
5689 | 5697 |
5690 EXPECT_EQ(ERR_IO_PENDING, | 5698 EXPECT_EQ(ERR_IO_PENDING, |
5691 GroupNameTransactionHelper(tests[i].url, session)); | 5699 GroupNameTransactionHelper(tests[i].url, session)); |
5692 if (tests[i].ssl) | 5700 if (tests[i].ssl) |
5693 EXPECT_EQ(tests[i].expected_group_name, | 5701 EXPECT_EQ(tests[i].expected_group_name, |
5694 ssl_conn_pool->last_group_name_received()); | 5702 ssl_conn_pool->last_group_name_received()); |
5695 else | 5703 else |
5696 EXPECT_EQ(tests[i].expected_group_name, | 5704 EXPECT_EQ(tests[i].expected_group_name, |
5697 http_proxy_pool->last_group_name_received()); | 5705 http_proxy_pool->last_group_name_received()); |
5698 } | 5706 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5743 SessionDependencies session_deps( | 5751 SessionDependencies session_deps( |
5744 ProxyService::CreateFixed(tests[i].proxy_server)); | 5752 ProxyService::CreateFixed(tests[i].proxy_server)); |
5745 scoped_refptr<HttpNetworkSession> session( | 5753 scoped_refptr<HttpNetworkSession> session( |
5746 SetupSessionForGroupNameTests(&session_deps)); | 5754 SetupSessionForGroupNameTests(&session_deps)); |
5747 | 5755 |
5748 HttpNetworkSessionPeer peer(session); | 5756 HttpNetworkSessionPeer peer(session); |
5749 | 5757 |
5750 HostPortPair proxy_host("socks_proxy", 1080); | 5758 HostPortPair proxy_host("socks_proxy", 1080); |
5751 CaptureGroupNameSOCKSSocketPool* socks_conn_pool = | 5759 CaptureGroupNameSOCKSSocketPool* socks_conn_pool = |
5752 new CaptureGroupNameSOCKSSocketPool(NULL, NULL); | 5760 new CaptureGroupNameSOCKSSocketPool(NULL, NULL); |
5753 peer.SetSocketPoolForSOCKSProxy(proxy_host, socks_conn_pool); | |
5754 CaptureGroupNameSSLSocketPool* ssl_conn_pool = | 5761 CaptureGroupNameSSLSocketPool* ssl_conn_pool = |
5755 new CaptureGroupNameSSLSocketPool(NULL, NULL); | 5762 new CaptureGroupNameSSLSocketPool(NULL, NULL); |
5756 peer.SetSocketPoolForSSLWithProxy(proxy_host, ssl_conn_pool); | 5763 |
| 5764 MockClientSocketPoolManager* mock_pool_manager = |
| 5765 new MockClientSocketPoolManager; |
| 5766 mock_pool_manager->SetSocketPoolForSOCKSProxy(proxy_host, socks_conn_pool); |
| 5767 mock_pool_manager->SetSocketPoolForSSLWithProxy(proxy_host, ssl_conn_pool); |
| 5768 peer.SetClientSocketPoolManager(mock_pool_manager); |
5757 | 5769 |
5758 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 5770 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
5759 | 5771 |
5760 EXPECT_EQ(ERR_IO_PENDING, | 5772 EXPECT_EQ(ERR_IO_PENDING, |
5761 GroupNameTransactionHelper(tests[i].url, session)); | 5773 GroupNameTransactionHelper(tests[i].url, session)); |
5762 if (tests[i].ssl) | 5774 if (tests[i].ssl) |
5763 EXPECT_EQ(tests[i].expected_group_name, | 5775 EXPECT_EQ(tests[i].expected_group_name, |
5764 ssl_conn_pool->last_group_name_received()); | 5776 ssl_conn_pool->last_group_name_received()); |
5765 else | 5777 else |
5766 EXPECT_EQ(tests[i].expected_group_name, | 5778 EXPECT_EQ(tests[i].expected_group_name, |
(...skipping 1987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7754 // each round of multi-round authentication. | 7766 // each round of multi-round authentication. |
7755 HttpNetworkSessionPeer session_peer(session); | 7767 HttpNetworkSessionPeer session_peer(session); |
7756 ClientSocketPoolHistograms transport_pool_histograms("SmallTCP"); | 7768 ClientSocketPoolHistograms transport_pool_histograms("SmallTCP"); |
7757 TransportClientSocketPool* transport_pool = new TransportClientSocketPool( | 7769 TransportClientSocketPool* transport_pool = new TransportClientSocketPool( |
7758 50, // Max sockets for pool | 7770 50, // Max sockets for pool |
7759 1, // Max sockets per group | 7771 1, // Max sockets per group |
7760 &transport_pool_histograms, | 7772 &transport_pool_histograms, |
7761 session_deps.host_resolver.get(), | 7773 session_deps.host_resolver.get(), |
7762 &session_deps.socket_factory, | 7774 &session_deps.socket_factory, |
7763 session_deps.net_log); | 7775 session_deps.net_log); |
7764 session_peer.SetTransportSocketPool(transport_pool); | 7776 MockClientSocketPoolManager* mock_pool_manager = |
| 7777 new MockClientSocketPoolManager; |
| 7778 mock_pool_manager->SetTransportSocketPool(transport_pool); |
| 7779 session_peer.SetClientSocketPoolManager(mock_pool_manager); |
7765 | 7780 |
7766 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 7781 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
7767 TestOldCompletionCallback callback; | 7782 TestOldCompletionCallback callback; |
7768 | 7783 |
7769 const MockWrite kGet( | 7784 const MockWrite kGet( |
7770 "GET / HTTP/1.1\r\n" | 7785 "GET / HTTP/1.1\r\n" |
7771 "Host: www.example.com\r\n" | 7786 "Host: www.example.com\r\n" |
7772 "Connection: keep-alive\r\n\r\n"); | 7787 "Connection: keep-alive\r\n\r\n"); |
7773 const MockWrite kGetAuth( | 7788 const MockWrite kGetAuth( |
7774 "GET / HTTP/1.1\r\n" | 7789 "GET / HTTP/1.1\r\n" |
(...skipping 1447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9222 StaticSocketDataProvider* data[] = { &data1, &data2 }; | 9237 StaticSocketDataProvider* data[] = { &data1, &data2 }; |
9223 | 9238 |
9224 SimpleGetHelperResult out = SimpleGetHelperForData(data, arraysize(data)); | 9239 SimpleGetHelperResult out = SimpleGetHelperForData(data, arraysize(data)); |
9225 | 9240 |
9226 EXPECT_EQ(OK, out.rv); | 9241 EXPECT_EQ(OK, out.rv); |
9227 EXPECT_EQ("HTTP/1.0 200 OK", out.status_line); | 9242 EXPECT_EQ("HTTP/1.0 200 OK", out.status_line); |
9228 EXPECT_EQ("hello world", out.response_data); | 9243 EXPECT_EQ("hello world", out.response_data); |
9229 } | 9244 } |
9230 | 9245 |
9231 } // namespace net | 9246 } // namespace net |
OLD | NEW |