OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/time.h" | 9 #include "base/time.h" |
10 #include "net/base/auth.h" | 10 #include "net/base/auth.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 &socket_factory_, | 70 &socket_factory_, |
71 tcp_pool ? tcp_socket_pool_ : NULL, | 71 tcp_pool ? tcp_socket_pool_ : NULL, |
72 http_proxy_pool ? http_proxy_socket_pool_ : NULL, | 72 http_proxy_pool ? http_proxy_socket_pool_ : NULL, |
73 socks_pool ? socks_socket_pool_ : NULL, | 73 socks_pool ? socks_socket_pool_ : NULL, |
74 NULL); | 74 NULL); |
75 } | 75 } |
76 | 76 |
77 scoped_refptr<SSLSocketParams> SSLParams( | 77 scoped_refptr<SSLSocketParams> SSLParams( |
78 ProxyServer::Scheme proxy, struct MockHttpAuthControllerData* auth_data, | 78 ProxyServer::Scheme proxy, struct MockHttpAuthControllerData* auth_data, |
79 size_t auth_data_len, bool want_spdy_over_ssl, bool want_spdy_over_npn) { | 79 size_t auth_data_len, bool want_spdy_over_ssl, bool want_spdy_over_npn) { |
80 | |
81 scoped_refptr<HttpProxySocketParams> http_proxy_params; | 80 scoped_refptr<HttpProxySocketParams> http_proxy_params; |
82 if (proxy == ProxyServer::SCHEME_HTTP) { | 81 if (proxy == ProxyServer::SCHEME_HTTP) { |
83 scoped_refptr<MockHttpAuthController> auth_controller = | 82 scoped_refptr<MockHttpAuthController> auth_controller = |
84 new MockHttpAuthController(); | 83 new MockHttpAuthController(); |
85 auth_controller->SetMockAuthControllerData(auth_data, auth_data_len); | 84 auth_controller->SetMockAuthControllerData(auth_data, auth_data_len); |
86 http_proxy_params = new HttpProxySocketParams(proxy_tcp_socket_params_, | 85 http_proxy_params = new HttpProxySocketParams(proxy_tcp_socket_params_, |
87 GURL("http://host"), | 86 GURL("http://host"), |
88 HostPortPair("host", 80), | 87 HostPortPair("host", 80), |
89 auth_controller, true); | 88 auth_controller, true); |
90 } | 89 } |
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 EXPECT_FALSE(handle.is_initialized()); | 633 EXPECT_FALSE(handle.is_initialized()); |
635 EXPECT_FALSE(handle.socket()); | 634 EXPECT_FALSE(handle.socket()); |
636 | 635 |
637 EXPECT_EQ(ERR_PROXY_AUTH_REQUESTED, callback.WaitForResult()); | 636 EXPECT_EQ(ERR_PROXY_AUTH_REQUESTED, callback.WaitForResult()); |
638 EXPECT_FALSE(handle.is_initialized()); | 637 EXPECT_FALSE(handle.is_initialized()); |
639 EXPECT_FALSE(handle.socket()); | 638 EXPECT_FALSE(handle.socket()); |
640 EXPECT_FALSE(handle.is_ssl_error()); | 639 EXPECT_FALSE(handle.is_ssl_error()); |
641 const HttpResponseInfo& tunnel_info = handle.ssl_error_response_info(); | 640 const HttpResponseInfo& tunnel_info = handle.ssl_error_response_info(); |
642 EXPECT_EQ(tunnel_info.headers->response_code(), 407); | 641 EXPECT_EQ(tunnel_info.headers->response_code(), 407); |
643 | 642 |
644 params->http_proxy_params()->auth_controller()->ResetAuth(std::wstring(), | 643 params->http_proxy_params()->auth_controller()->ResetAuth(string16(), |
645 std::wstring()); | 644 string16()); |
646 rv = handle.Init("a", params, MEDIUM, &callback, pool_, BoundNetLog()); | 645 rv = handle.Init("a", params, MEDIUM, &callback, pool_, BoundNetLog()); |
647 EXPECT_EQ(ERR_IO_PENDING, rv); | 646 EXPECT_EQ(ERR_IO_PENDING, rv); |
648 EXPECT_FALSE(handle.is_initialized()); | 647 EXPECT_FALSE(handle.is_initialized()); |
649 EXPECT_FALSE(handle.socket()); | 648 EXPECT_FALSE(handle.socket()); |
650 | 649 |
651 // Test that http://crbug.com/49325 doesn't regress. | 650 // Test that http://crbug.com/49325 doesn't regress. |
652 EXPECT_EQ(handle.GetLoadState(), LOAD_STATE_ESTABLISHING_PROXY_TUNNEL); | 651 EXPECT_EQ(handle.GetLoadState(), LOAD_STATE_ESTABLISHING_PROXY_TUNNEL); |
653 | 652 |
654 EXPECT_EQ(OK, callback.WaitForResult()); | 653 EXPECT_EQ(OK, callback.WaitForResult()); |
655 EXPECT_TRUE(handle.is_initialized()); | 654 EXPECT_TRUE(handle.is_initialized()); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 EXPECT_FALSE(handle.is_initialized()); | 702 EXPECT_FALSE(handle.is_initialized()); |
704 EXPECT_FALSE(handle.socket()); | 703 EXPECT_FALSE(handle.socket()); |
705 | 704 |
706 EXPECT_EQ(ERR_PROXY_AUTH_REQUESTED, callback.WaitForResult()); | 705 EXPECT_EQ(ERR_PROXY_AUTH_REQUESTED, callback.WaitForResult()); |
707 EXPECT_FALSE(handle.is_initialized()); | 706 EXPECT_FALSE(handle.is_initialized()); |
708 EXPECT_FALSE(handle.socket()); | 707 EXPECT_FALSE(handle.socket()); |
709 EXPECT_FALSE(handle.is_ssl_error()); | 708 EXPECT_FALSE(handle.is_ssl_error()); |
710 const HttpResponseInfo& tunnel_info = handle.ssl_error_response_info(); | 709 const HttpResponseInfo& tunnel_info = handle.ssl_error_response_info(); |
711 EXPECT_EQ(tunnel_info.headers->response_code(), 407); | 710 EXPECT_EQ(tunnel_info.headers->response_code(), 407); |
712 | 711 |
713 params->http_proxy_params()->auth_controller()->ResetAuth(std::wstring(), | 712 params->http_proxy_params()->auth_controller()->ResetAuth(string16(), |
714 std::wstring()); | 713 string16()); |
715 rv = handle.Init("a", params, MEDIUM, &callback, pool_, BoundNetLog()); | 714 rv = handle.Init("a", params, MEDIUM, &callback, pool_, BoundNetLog()); |
716 EXPECT_EQ(ERR_IO_PENDING, rv); | 715 EXPECT_EQ(ERR_IO_PENDING, rv); |
717 EXPECT_FALSE(handle.is_initialized()); | 716 EXPECT_FALSE(handle.is_initialized()); |
718 EXPECT_FALSE(handle.socket()); | 717 EXPECT_FALSE(handle.socket()); |
719 | 718 |
720 EXPECT_EQ(OK, callback.WaitForResult()); | 719 EXPECT_EQ(OK, callback.WaitForResult()); |
721 EXPECT_TRUE(handle.is_initialized()); | 720 EXPECT_TRUE(handle.is_initialized()); |
722 EXPECT_TRUE(handle.socket()); | 721 EXPECT_TRUE(handle.socket()); |
723 } | 722 } |
724 | 723 |
725 // It would be nice to also test the timeouts in SSLClientSocketPool. | 724 // It would be nice to also test the timeouts in SSLClientSocketPool. |
726 | 725 |
727 } // namespace | 726 } // namespace |
728 | 727 |
729 } // namespace net | 728 } // namespace net |
OLD | NEW |