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_proxy_client_socket_pool.h" | 5 #include "net/http/http_proxy_client_socket_pool.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "net/base/mock_host_resolver.h" | 11 #include "net/base/mock_host_resolver.h" |
12 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
13 #include "net/base/ssl_config_service_defaults.h" | 13 #include "net/base/ssl_config_service_defaults.h" |
14 #include "net/base/test_completion_callback.h" | 14 #include "net/base/test_completion_callback.h" |
15 #include "net/http/http_auth_handler_factory.h" | 15 #include "net/http/http_auth_handler_factory.h" |
16 #include "net/http/http_network_session.h" | 16 #include "net/http/http_network_session.h" |
17 #include "net/http/http_proxy_client_socket.h" | 17 #include "net/http/http_proxy_client_socket.h" |
18 #include "net/http/http_server_properties_impl.h" | 18 #include "net/http/http_server_properties_impl.h" |
19 #include "net/proxy/proxy_service.h" | 19 #include "net/proxy/proxy_service.h" |
20 #include "net/socket/client_socket_handle.h" | 20 #include "net/socket/client_socket_handle.h" |
21 #include "net/socket/client_socket_pool_histograms.h" | 21 #include "net/socket/client_socket_pool_histograms.h" |
22 #include "net/socket/socket_test_util.h" | 22 #include "net/socket/socket_test_util.h" |
23 #include "net/spdy/spdy_protocol.h" | 23 #include "net/spdy/spdy_protocol.h" |
| 24 #include "net/spdy/spdy_session.h" |
24 #include "net/spdy/spdy_test_util.h" | 25 #include "net/spdy/spdy_test_util.h" |
25 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
26 | 27 |
27 namespace net { | 28 namespace net { |
28 | 29 |
29 namespace { | 30 namespace { |
30 | 31 |
31 const int kMaxSockets = 32; | 32 const int kMaxSockets = 32; |
32 const int kMaxSocketsPerGroup = 6; | 33 const int kMaxSocketsPerGroup = 6; |
33 const char * const kAuthHeaders[] = { | 34 const char * const kAuthHeaders[] = { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 &http_proxy_histograms_, | 88 &http_proxy_histograms_, |
88 NULL, | 89 NULL, |
89 &transport_socket_pool_, | 90 &transport_socket_pool_, |
90 &ssl_socket_pool_, | 91 &ssl_socket_pool_, |
91 NULL) { | 92 NULL) { |
92 } | 93 } |
93 | 94 |
94 virtual ~HttpProxyClientSocketPoolTest() { | 95 virtual ~HttpProxyClientSocketPoolTest() { |
95 } | 96 } |
96 | 97 |
| 98 virtual void SetUp() OVERRIDE { |
| 99 // Disable sending PING. |
| 100 SpdySession::set_enable_ping_based_connection_checking(false); |
| 101 } |
| 102 |
| 103 virtual void TearDown() OVERRIDE { |
| 104 // Enable sending PING. |
| 105 SpdySession::set_enable_ping_based_connection_checking(true); |
| 106 } |
| 107 |
97 void AddAuthToCache() { | 108 void AddAuthToCache() { |
98 const string16 kFoo(ASCIIToUTF16("foo")); | 109 const string16 kFoo(ASCIIToUTF16("foo")); |
99 const string16 kBar(ASCIIToUTF16("bar")); | 110 const string16 kBar(ASCIIToUTF16("bar")); |
100 GURL proxy_url(GetParam() == HTTP ? "http://proxy" : "https://proxy:80"); | 111 GURL proxy_url(GetParam() == HTTP ? "http://proxy" : "https://proxy:80"); |
101 session_->http_auth_cache()->Add(proxy_url, | 112 session_->http_auth_cache()->Add(proxy_url, |
102 "MyRealm1", | 113 "MyRealm1", |
103 HttpAuth::AUTH_SCHEME_BASIC, | 114 HttpAuth::AUTH_SCHEME_BASIC, |
104 "Basic realm=MyRealm1", | 115 "Basic realm=MyRealm1", |
105 kFoo, | 116 kFoo, |
106 kBar, | 117 kBar, |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 // HTTPS or SPDY Proxy CONNECT responses are trustworthy | 532 // HTTPS or SPDY Proxy CONNECT responses are trustworthy |
522 EXPECT_EQ(ERR_HTTPS_PROXY_TUNNEL_RESPONSE, rv); | 533 EXPECT_EQ(ERR_HTTPS_PROXY_TUNNEL_RESPONSE, rv); |
523 EXPECT_TRUE(handle_.is_initialized()); | 534 EXPECT_TRUE(handle_.is_initialized()); |
524 EXPECT_TRUE(handle_.socket()); | 535 EXPECT_TRUE(handle_.socket()); |
525 } | 536 } |
526 } | 537 } |
527 | 538 |
528 // It would be nice to also test the timeouts in HttpProxyClientSocketPool. | 539 // It would be nice to also test the timeouts in HttpProxyClientSocketPool. |
529 | 540 |
530 } // namespace net | 541 } // namespace net |
OLD | NEW |