Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Side by Side Diff: net/http/http_proxy_client_socket_pool.h

Issue 9316101: Revert 118950 - Allow chrome to handle 407 auth challenges to CONNECT requests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/http/http_proxy_client_socket.cc ('k') | net/http/http_proxy_client_socket_pool.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef NET_HTTP_HTTP_PROXY_CLIENT_SOCKET_POOL_H_ 5 #ifndef NET_HTTP_HTTP_PROXY_CLIENT_SOCKET_POOL_H_
6 #define NET_HTTP_HTTP_PROXY_CLIENT_SOCKET_POOL_H_ 6 #define NET_HTTP_HTTP_PROXY_CLIENT_SOCKET_POOL_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/time.h" 14 #include "base/time.h"
15 #include "net/base/host_port_pair.h" 15 #include "net/base/host_port_pair.h"
16 #include "net/base/net_export.h" 16 #include "net/base/net_export.h"
17 #include "net/http/http_auth.h" 17 #include "net/http/http_auth.h"
18 #include "net/http/http_response_info.h" 18 #include "net/http/http_response_info.h"
19 #include "net/http/proxy_client_socket.h" 19 #include "net/http/proxy_client_socket.h"
20 #include "net/socket/client_socket_pool_base.h" 20 #include "net/socket/client_socket_pool_base.h"
21 #include "net/socket/client_socket_pool_histograms.h" 21 #include "net/socket/client_socket_pool_histograms.h"
22 #include "net/socket/client_socket_pool.h" 22 #include "net/socket/client_socket_pool.h"
23 #include "net/socket/ssl_client_socket.h" 23 #include "net/socket/ssl_client_socket.h"
24 24
25 namespace net { 25 namespace net {
26 26
27 class HostResolver; 27 class HostResolver;
28 class HttpAuthCache; 28 class HttpAuthCache;
29 class HttpAuthController;
30 class HttpAuthHandlerFactory; 29 class HttpAuthHandlerFactory;
31 class SSLClientSocketPool; 30 class SSLClientSocketPool;
32 class SSLSocketParams; 31 class SSLSocketParams;
33 class SpdySessionPool; 32 class SpdySessionPool;
34 class SpdyStream; 33 class SpdyStream;
35 class TransportClientSocketPool; 34 class TransportClientSocketPool;
36 class TransportSocketParams; 35 class TransportSocketParams;
37 36
38 // Called when a 407 Proxy Authentication Required response is received
39 // from an HTTP or HTTPS proxy when attempting to establish a CONNECT tunnel
40 // to an HTTPS server. Information about the challenge can be found in
41 // the HttpResponse info. Credentials should be added to the
42 // HttpAuthController, and the CompletionCallback should be invoked
43 // with the status.
44 typedef base::Callback<void (const HttpResponseInfo&,
45 HttpAuthController*,
46 CompletionCallback)>
47 TunnelAuthCallback;
48
49 // HttpProxySocketParams only needs the socket params for one of the proxy 37 // HttpProxySocketParams only needs the socket params for one of the proxy
50 // types. The other param must be NULL. When using an HTTP Proxy, 38 // types. The other param must be NULL. When using an HTTP Proxy,
51 // |transport_params| must be set. When using an HTTPS Proxy, |ssl_params| 39 // |transport_params| must be set. When using an HTTPS Proxy, |ssl_params|
52 // must be set. 40 // must be set.
53 class NET_EXPORT_PRIVATE HttpProxySocketParams 41 class NET_EXPORT_PRIVATE HttpProxySocketParams
54 : public base::RefCounted<HttpProxySocketParams> { 42 : public base::RefCounted<HttpProxySocketParams> {
55 public: 43 public:
56 HttpProxySocketParams( 44 HttpProxySocketParams(
57 const scoped_refptr<TransportSocketParams>& transport_params, 45 const scoped_refptr<TransportSocketParams>& transport_params,
58 const scoped_refptr<SSLSocketParams>& ssl_params, 46 const scoped_refptr<SSLSocketParams>& ssl_params,
59 const GURL& request_url, 47 const GURL& request_url,
60 const std::string& user_agent, 48 const std::string& user_agent,
61 const HostPortPair& endpoint, 49 const HostPortPair& endpoint,
62 HttpAuthCache* http_auth_cache, 50 HttpAuthCache* http_auth_cache,
63 HttpAuthHandlerFactory* http_auth_handler_factory, 51 HttpAuthHandlerFactory* http_auth_handler_factory,
64 SpdySessionPool* spdy_session_pool, 52 SpdySessionPool* spdy_session_pool,
65 bool tunnel, 53 bool tunnel);
66 TunnelAuthCallback auth_needed_callback);
67 54
68 const scoped_refptr<TransportSocketParams>& transport_params() const { 55 const scoped_refptr<TransportSocketParams>& transport_params() const {
69 return transport_params_; 56 return transport_params_;
70 } 57 }
71 const scoped_refptr<SSLSocketParams>& ssl_params() const { 58 const scoped_refptr<SSLSocketParams>& ssl_params() const {
72 return ssl_params_; 59 return ssl_params_;
73 } 60 }
74 const GURL& request_url() const { return request_url_; } 61 const GURL& request_url() const { return request_url_; }
75 const std::string& user_agent() const { return user_agent_; } 62 const std::string& user_agent() const { return user_agent_; }
76 const HostPortPair& endpoint() const { return endpoint_; } 63 const HostPortPair& endpoint() const { return endpoint_; }
77 HttpAuthCache* http_auth_cache() const { return http_auth_cache_; } 64 HttpAuthCache* http_auth_cache() const { return http_auth_cache_; }
78 HttpAuthHandlerFactory* http_auth_handler_factory() const { 65 HttpAuthHandlerFactory* http_auth_handler_factory() const {
79 return http_auth_handler_factory_; 66 return http_auth_handler_factory_;
80 } 67 }
81 SpdySessionPool* spdy_session_pool() { 68 SpdySessionPool* spdy_session_pool() {
82 return spdy_session_pool_; 69 return spdy_session_pool_;
83 } 70 }
84 const HostResolver::RequestInfo& destination() const; 71 const HostResolver::RequestInfo& destination() const;
85 bool tunnel() const { return tunnel_; } 72 bool tunnel() const { return tunnel_; }
86 bool ignore_limits() const { return ignore_limits_; } 73 bool ignore_limits() const { return ignore_limits_; }
87 TunnelAuthCallback auth_needed_callback() { return auth_needed_callback_; }
88 74
89 private: 75 private:
90 friend class base::RefCounted<HttpProxySocketParams>; 76 friend class base::RefCounted<HttpProxySocketParams>;
91 ~HttpProxySocketParams(); 77 ~HttpProxySocketParams();
92 78
93 const scoped_refptr<TransportSocketParams> transport_params_; 79 const scoped_refptr<TransportSocketParams> transport_params_;
94 const scoped_refptr<SSLSocketParams> ssl_params_; 80 const scoped_refptr<SSLSocketParams> ssl_params_;
95 SpdySessionPool* spdy_session_pool_; 81 SpdySessionPool* spdy_session_pool_;
96 const GURL request_url_; 82 const GURL request_url_;
97 const std::string user_agent_; 83 const std::string user_agent_;
98 const HostPortPair endpoint_; 84 const HostPortPair endpoint_;
99 HttpAuthCache* const http_auth_cache_; 85 HttpAuthCache* const http_auth_cache_;
100 HttpAuthHandlerFactory* const http_auth_handler_factory_; 86 HttpAuthHandlerFactory* const http_auth_handler_factory_;
101 const bool tunnel_; 87 const bool tunnel_;
102 bool ignore_limits_; 88 bool ignore_limits_;
103 TunnelAuthCallback auth_needed_callback_;
104 89
105 DISALLOW_COPY_AND_ASSIGN(HttpProxySocketParams); 90 DISALLOW_COPY_AND_ASSIGN(HttpProxySocketParams);
106 }; 91 };
107 92
108 // HttpProxyConnectJob optionally establishes a tunnel through the proxy 93 // HttpProxyConnectJob optionally establishes a tunnel through the proxy
109 // server after connecting the underlying transport socket. 94 // server after connecting the underlying transport socket.
110 class HttpProxyConnectJob : public ConnectJob { 95 class HttpProxyConnectJob : public ConnectJob {
111 public: 96 public:
112 HttpProxyConnectJob(const std::string& group_name, 97 HttpProxyConnectJob(const std::string& group_name,
113 const scoped_refptr<HttpProxySocketParams>& params, 98 const scoped_refptr<HttpProxySocketParams>& params,
(...skipping 14 matching lines...) Expand all
128 enum State { 113 enum State {
129 STATE_TCP_CONNECT, 114 STATE_TCP_CONNECT,
130 STATE_TCP_CONNECT_COMPLETE, 115 STATE_TCP_CONNECT_COMPLETE,
131 STATE_SSL_CONNECT, 116 STATE_SSL_CONNECT,
132 STATE_SSL_CONNECT_COMPLETE, 117 STATE_SSL_CONNECT_COMPLETE,
133 STATE_HTTP_PROXY_CONNECT, 118 STATE_HTTP_PROXY_CONNECT,
134 STATE_HTTP_PROXY_CONNECT_COMPLETE, 119 STATE_HTTP_PROXY_CONNECT_COMPLETE,
135 STATE_SPDY_PROXY_CREATE_STREAM, 120 STATE_SPDY_PROXY_CREATE_STREAM,
136 STATE_SPDY_PROXY_CREATE_STREAM_COMPLETE, 121 STATE_SPDY_PROXY_CREATE_STREAM_COMPLETE,
137 STATE_SPDY_PROXY_CONNECT_COMPLETE, 122 STATE_SPDY_PROXY_CONNECT_COMPLETE,
138 STATE_RESTART_WITH_AUTH,
139 STATE_RESTART_WITH_AUTH_COMPLETE,
140 STATE_NONE, 123 STATE_NONE,
141 }; 124 };
142 125
143 void OnIOComplete(int result); 126 void OnIOComplete(int result);
144 127
145 // Runs the state transition loop. 128 // Runs the state transition loop.
146 int DoLoop(int result); 129 int DoLoop(int result);
147 130
148 // Connecting to HTTP Proxy 131 // Connecting to HTTP Proxy
149 int DoTransportConnect(); 132 int DoTransportConnect();
150 int DoTransportConnectComplete(int result); 133 int DoTransportConnectComplete(int result);
151 // Connecting to HTTPS Proxy 134 // Connecting to HTTPS Proxy
152 int DoSSLConnect(); 135 int DoSSLConnect();
153 int DoSSLConnectComplete(int result); 136 int DoSSLConnectComplete(int result);
154 137
155 int DoHttpProxyConnect(); 138 int DoHttpProxyConnect();
156 int DoHttpProxyConnectComplete(int result); 139 int DoHttpProxyConnectComplete(int result);
157 140
158 int DoSpdyProxyCreateStream(); 141 int DoSpdyProxyCreateStream();
159 int DoSpdyProxyCreateStreamComplete(int result); 142 int DoSpdyProxyCreateStreamComplete(int result);
160 143
161 int DoRestartWithAuth();
162 int DoRestartWithAuthComplete(int result);
163
164 void HandleProxyAuthChallenge();
165
166 // Begins the tcp connection and the optional Http proxy tunnel. If the 144 // Begins the tcp connection and the optional Http proxy tunnel. If the
167 // request is not immediately servicable (likely), the request will return 145 // request is not immediately servicable (likely), the request will return
168 // ERR_IO_PENDING. An OK return from this function or the callback means 146 // ERR_IO_PENDING. An OK return from this function or the callback means
169 // that the connection is established; ERR_PROXY_AUTH_REQUESTED means 147 // that the connection is established; ERR_PROXY_AUTH_REQUESTED means
170 // that the tunnel needs authentication credentials, the socket will be 148 // that the tunnel needs authentication credentials, the socket will be
171 // returned in this case, and must be release back to the pool; or 149 // returned in this case, and must be release back to the pool; or
172 // a standard net error code will be returned. 150 // a standard net error code will be returned.
173 virtual int ConnectInternal() OVERRIDE; 151 virtual int ConnectInternal() OVERRIDE;
174 152
175 scoped_refptr<HttpProxySocketParams> params_; 153 scoped_refptr<HttpProxySocketParams> params_;
176 TransportClientSocketPool* const transport_pool_; 154 TransportClientSocketPool* const transport_pool_;
177 SSLClientSocketPool* const ssl_pool_; 155 SSLClientSocketPool* const ssl_pool_;
178 HostResolver* const resolver_; 156 HostResolver* const resolver_;
179 157
180 State next_state_; 158 State next_state_;
181 CompletionCallback callback_; 159 CompletionCallback callback_;
182 scoped_ptr<ClientSocketHandle> transport_socket_handle_; 160 scoped_ptr<ClientSocketHandle> transport_socket_handle_;
183 scoped_ptr<ProxyClientSocket> transport_socket_; 161 scoped_ptr<ProxyClientSocket> transport_socket_;
184 bool using_spdy_; 162 bool using_spdy_;
185 // Protocol negotiated with the server. 163 // Protocol negotiated with the server.
186 SSLClientSocket::NextProto protocol_negotiated_; 164 SSLClientSocket::NextProto protocol_negotiated_;
187 165
188 HttpResponseInfo error_response_info_; 166 HttpResponseInfo error_response_info_;
189 167
190 scoped_refptr<SpdyStream> spdy_stream_; 168 scoped_refptr<SpdyStream> spdy_stream_;
191 169
192 // AuthController to be used for *all* requests when setting up this tunnel.
193 scoped_refptr<HttpAuthController> auth_;
194
195 base::WeakPtrFactory<HttpProxyConnectJob> ptr_factory_;
196
197 DISALLOW_COPY_AND_ASSIGN(HttpProxyConnectJob); 170 DISALLOW_COPY_AND_ASSIGN(HttpProxyConnectJob);
198 }; 171 };
199 172
200 class NET_EXPORT_PRIVATE HttpProxyClientSocketPool : public ClientSocketPool { 173 class NET_EXPORT_PRIVATE HttpProxyClientSocketPool : public ClientSocketPool {
201 public: 174 public:
202 HttpProxyClientSocketPool( 175 HttpProxyClientSocketPool(
203 int max_sockets, 176 int max_sockets,
204 int max_sockets_per_group, 177 int max_sockets_per_group,
205 ClientSocketPoolHistograms* histograms, 178 ClientSocketPoolHistograms* histograms,
206 HostResolver* host_resolver, 179 HostResolver* host_resolver,
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 262
290 DISALLOW_COPY_AND_ASSIGN(HttpProxyClientSocketPool); 263 DISALLOW_COPY_AND_ASSIGN(HttpProxyClientSocketPool);
291 }; 264 };
292 265
293 REGISTER_SOCKET_PARAMS_FOR_POOL(HttpProxyClientSocketPool, 266 REGISTER_SOCKET_PARAMS_FOR_POOL(HttpProxyClientSocketPool,
294 HttpProxySocketParams); 267 HttpProxySocketParams);
295 268
296 } // namespace net 269 } // namespace net
297 270
298 #endif // NET_HTTP_HTTP_PROXY_CLIENT_SOCKET_POOL_H_ 271 #endif // NET_HTTP_HTTP_PROXY_CLIENT_SOCKET_POOL_H_
OLDNEW
« no previous file with comments | « net/http/http_proxy_client_socket.cc ('k') | net/http/http_proxy_client_socket_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698