OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 const char kHttpProxyHost[] = "httpproxy.example.com"; | 59 const char kHttpProxyHost[] = "httpproxy.example.com"; |
60 const char kHttpsProxyHost[] = "httpsproxy.example.com"; | 60 const char kHttpsProxyHost[] = "httpsproxy.example.com"; |
61 | 61 |
62 class TestProxyDelegate : public ProxyDelegate { | 62 class TestProxyDelegate : public ProxyDelegate { |
63 public: | 63 public: |
64 TestProxyDelegate() | 64 TestProxyDelegate() |
65 : on_before_tunnel_request_called_(false), | 65 : on_before_tunnel_request_called_(false), |
66 on_tunnel_headers_received_called_(false) { | 66 on_tunnel_headers_received_called_(false) { |
67 } | 67 } |
68 | 68 |
69 virtual ~TestProxyDelegate() OVERRIDE { | 69 virtual ~TestProxyDelegate() override { |
70 } | 70 } |
71 | 71 |
72 bool on_before_tunnel_request_called() const { | 72 bool on_before_tunnel_request_called() const { |
73 return on_before_tunnel_request_called_; | 73 return on_before_tunnel_request_called_; |
74 } | 74 } |
75 | 75 |
76 bool on_tunnel_headers_received_called() const { | 76 bool on_tunnel_headers_received_called() const { |
77 return on_tunnel_headers_received_called_; | 77 return on_tunnel_headers_received_called_; |
78 } | 78 } |
79 | 79 |
80 void VerifyOnTunnelHeadersReceived(const std::string& origin, | 80 void VerifyOnTunnelHeadersReceived(const std::string& origin, |
81 const std::string& proxy_server, | 81 const std::string& proxy_server, |
82 const std::string& status_line) const { | 82 const std::string& status_line) const { |
83 EXPECT_TRUE(on_tunnel_headers_received_called_); | 83 EXPECT_TRUE(on_tunnel_headers_received_called_); |
84 EXPECT_TRUE(HostPortPair::FromString(origin).Equals( | 84 EXPECT_TRUE(HostPortPair::FromString(origin).Equals( |
85 on_tunnel_headers_received_origin_)); | 85 on_tunnel_headers_received_origin_)); |
86 EXPECT_TRUE(HostPortPair::FromString(proxy_server).Equals( | 86 EXPECT_TRUE(HostPortPair::FromString(proxy_server).Equals( |
87 on_tunnel_headers_received_proxy_server_)); | 87 on_tunnel_headers_received_proxy_server_)); |
88 EXPECT_EQ(status_line, on_tunnel_headers_received_status_line_); | 88 EXPECT_EQ(status_line, on_tunnel_headers_received_status_line_); |
89 } | 89 } |
90 | 90 |
91 // ProxyDelegate: | 91 // ProxyDelegate: |
92 virtual void OnResolveProxy(const GURL& url, | 92 virtual void OnResolveProxy(const GURL& url, |
93 int load_flags, | 93 int load_flags, |
94 const ProxyService& proxy_service, | 94 const ProxyService& proxy_service, |
95 ProxyInfo* result) OVERRIDE { | 95 ProxyInfo* result) override { |
96 } | 96 } |
97 | 97 |
98 virtual void OnFallback(const ProxyServer& bad_proxy, | 98 virtual void OnFallback(const ProxyServer& bad_proxy, |
99 int net_error) OVERRIDE { | 99 int net_error) override { |
100 } | 100 } |
101 | 101 |
102 virtual void OnBeforeSendHeaders(URLRequest* request, | 102 virtual void OnBeforeSendHeaders(URLRequest* request, |
103 const ProxyInfo& proxy_info, | 103 const ProxyInfo& proxy_info, |
104 HttpRequestHeaders* headers) OVERRIDE { | 104 HttpRequestHeaders* headers) override { |
105 } | 105 } |
106 | 106 |
107 virtual void OnBeforeTunnelRequest( | 107 virtual void OnBeforeTunnelRequest( |
108 const net::HostPortPair& proxy_server, | 108 const net::HostPortPair& proxy_server, |
109 net::HttpRequestHeaders* extra_headers) OVERRIDE { | 109 net::HttpRequestHeaders* extra_headers) override { |
110 on_before_tunnel_request_called_ = true; | 110 on_before_tunnel_request_called_ = true; |
111 if (extra_headers) { | 111 if (extra_headers) { |
112 extra_headers->SetHeader("Foo", proxy_server.ToString()); | 112 extra_headers->SetHeader("Foo", proxy_server.ToString()); |
113 } | 113 } |
114 } | 114 } |
115 | 115 |
116 virtual void OnTunnelHeadersReceived( | 116 virtual void OnTunnelHeadersReceived( |
117 const net::HostPortPair& origin, | 117 const net::HostPortPair& origin, |
118 const net::HostPortPair& proxy_server, | 118 const net::HostPortPair& proxy_server, |
119 const net::HttpResponseHeaders& response_headers) OVERRIDE { | 119 const net::HttpResponseHeaders& response_headers) override { |
120 on_tunnel_headers_received_called_ = true; | 120 on_tunnel_headers_received_called_ = true; |
121 on_tunnel_headers_received_origin_ = origin; | 121 on_tunnel_headers_received_origin_ = origin; |
122 on_tunnel_headers_received_proxy_server_ = proxy_server; | 122 on_tunnel_headers_received_proxy_server_ = proxy_server; |
123 on_tunnel_headers_received_status_line_ = response_headers.GetStatusLine(); | 123 on_tunnel_headers_received_status_line_ = response_headers.GetStatusLine(); |
124 } | 124 } |
125 | 125 |
126 private: | 126 private: |
127 bool on_before_tunnel_request_called_; | 127 bool on_before_tunnel_request_called_; |
128 bool on_tunnel_headers_received_called_; | 128 bool on_tunnel_headers_received_called_; |
129 HostPortPair on_tunnel_headers_received_origin_; | 129 HostPortPair on_tunnel_headers_received_origin_; |
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
810 EXPECT_TRUE(headers->IsRedirect(&location)); | 810 EXPECT_TRUE(headers->IsRedirect(&location)); |
811 EXPECT_EQ(location, redirectTarget); | 811 EXPECT_EQ(location, redirectTarget); |
812 } | 812 } |
813 } | 813 } |
814 | 814 |
815 // It would be nice to also test the timeouts in HttpProxyClientSocketPool. | 815 // It would be nice to also test the timeouts in HttpProxyClientSocketPool. |
816 | 816 |
817 } // namespace | 817 } // namespace |
818 | 818 |
819 } // namespace net | 819 } // namespace net |
OLD | NEW |