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

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

Issue 2866018: Revert 50647 - Create HttpAuthController.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 6 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_auth_controller.cc ('k') | net/http/http_network_transaction.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) 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 #ifndef NET_HTTP_HTTP_NETWORK_TRANSACTION_H_ 5 #ifndef NET_HTTP_HTTP_NETWORK_TRANSACTION_H_
6 #define NET_HTTP_HTTP_NETWORK_TRANSACTION_H_ 6 #define NET_HTTP_HTTP_NETWORK_TRANSACTION_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/ref_counted.h" 11 #include "base/ref_counted.h"
12 #include "base/scoped_ptr.h" 12 #include "base/scoped_ptr.h"
13 #include "base/time.h" 13 #include "base/time.h"
14 #include "net/base/address_list.h" 14 #include "net/base/address_list.h"
15 #include "net/base/host_resolver.h" 15 #include "net/base/host_resolver.h"
16 #include "net/base/io_buffer.h" 16 #include "net/base/io_buffer.h"
17 #include "net/base/load_flags.h" 17 #include "net/base/load_flags.h"
18 #include "net/base/load_states.h" 18 #include "net/base/load_states.h"
19 #include "net/base/net_log.h" 19 #include "net/base/net_log.h"
20 #include "net/base/ssl_config_service.h" 20 #include "net/base/ssl_config_service.h"
21 #include "net/http/http_alternate_protocols.h" 21 #include "net/http/http_alternate_protocols.h"
22 #include "net/http/http_auth.h" 22 #include "net/http/http_auth.h"
23 #include "net/http/http_auth_controller.h"
24 #include "net/http/http_auth_handler.h" 23 #include "net/http/http_auth_handler.h"
25 #include "net/http/http_response_info.h" 24 #include "net/http/http_response_info.h"
26 #include "net/http/http_transaction.h" 25 #include "net/http/http_transaction.h"
27 #include "net/proxy/proxy_service.h" 26 #include "net/proxy/proxy_service.h"
28 #include "net/socket/client_socket_pool.h" 27 #include "net/socket/client_socket_pool.h"
29 #include "testing/gtest/include/gtest/gtest_prod.h" 28 #include "testing/gtest/include/gtest/gtest_prod.h"
30 29
31 namespace net { 30 namespace net {
32 31
33 class ClientSocketFactory; 32 class ClientSocketFactory;
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 233
235 // Clear the state used to setup the tunnel. 234 // Clear the state used to setup the tunnel.
236 void ClearTunnelState(); 235 void ClearTunnelState();
237 236
238 // Returns true if we should try to add a Proxy-Authorization header 237 // Returns true if we should try to add a Proxy-Authorization header
239 bool ShouldApplyProxyAuth() const; 238 bool ShouldApplyProxyAuth() const;
240 239
241 // Returns true if we should try to add an Authorization header. 240 // Returns true if we should try to add an Authorization header.
242 bool ShouldApplyServerAuth() const; 241 bool ShouldApplyServerAuth() const;
243 242
243 // Adds either the proxy auth header, or the origin server auth header,
244 // as specified by |target|.
245 void AddAuthorizationHeader(
246 HttpAuth::Target target, HttpRequestHeaders* authorization_headers);
247
248 // Returns a log message for all the response headers related to the auth
249 // challenge.
250 std::string AuthChallengeLogMessage() const;
251
244 // Handles HTTP status code 401 or 407. 252 // Handles HTTP status code 401 or 407.
245 // HandleAuthChallenge() returns a network error code, or OK on success. 253 // HandleAuthChallenge() returns a network error code, or OK on success.
246 // May update |pending_auth_target_| or |response_.auth_challenge|. 254 // May update |pending_auth_target_| or |response_.auth_challenge|.
247 int HandleAuthChallenge(bool establishing_tunnel); 255 int HandleAuthChallenge(bool establishing_tunnel);
248 256
257 // Populates response_.auth_challenge with the challenge information, so that
258 // URLRequestHttpJob can prompt for a username/password.
259 void PopulateAuthChallenge(HttpAuth::Target target,
260 const GURL& auth_origin);
261
262 // Invalidates any auth cache entries after authentication has failed.
263 // The identity that was rejected is auth_identity_[target].
264 void InvalidateRejectedAuthFromCache(HttpAuth::Target target,
265 const GURL& auth_origin);
266
267 // Sets auth_identity_[target] to the next identity that the transaction
268 // should try. It chooses candidates by searching the auth cache
269 // and the URL for a username:password. Returns true if an identity
270 // was found.
271 bool SelectNextAuthIdentityToTry(HttpAuth::Target target,
272 const GURL& auth_origin);
273
274 // Searches the auth cache for an entry that encompasses the request's path.
275 // If such an entry is found, updates auth_identity_[target] and
276 // auth_handler_[target] with the cache entry's data and returns true.
277 bool SelectPreemptiveAuth(HttpAuth::Target target);
278
249 bool HaveAuth(HttpAuth::Target target) const { 279 bool HaveAuth(HttpAuth::Target target) const {
250 return auth_controllers_[target].get() && 280 return auth_handler_[target].get() && !auth_identity_[target].invalid;
251 auth_controllers_[target]->HaveAuth();
252 } 281 }
253 282
254 // Get the {scheme, host, path, port} for the authentication target 283 // Get the {scheme, host, port} for the authentication target
255 GURL AuthURL(HttpAuth::Target target) const; 284 GURL AuthOrigin(HttpAuth::Target target) const;
285
286 // Same as AuthOrigin(), but will return an invalid GURL if the target is
287 // invalid.
288 GURL PossiblyInvalidAuthOrigin(HttpAuth::Target target) const;
289
290 // Get the absolute path of the resource needing authentication.
291 // For proxy authentication the path is always empty string.
292 std::string AuthPath(HttpAuth::Target target) const;
293
294 // Generate an authentication token for |target| if necessary. The return
295 // value is a net error code. |OK| will be returned both in the case that
296 // a token is correctly generated synchronously, as well as when no tokens
297 // were necessary.
298 int MaybeGenerateAuthToken(HttpAuth::Target target);
256 299
257 void MarkBrokenAlternateProtocolAndFallback(); 300 void MarkBrokenAlternateProtocolAndFallback();
258 301
302 // Returns a string representation of a HttpAuth::Target value that can be
303 // used in log messages.
304 static std::string AuthTargetString(HttpAuth::Target target);
305
259 static bool g_ignore_certificate_errors; 306 static bool g_ignore_certificate_errors;
260 307
261 scoped_ptr<HttpAuthController> auth_controllers_[HttpAuth::AUTH_NUM_TARGETS]; 308 // |auth_handler_| encapsulates the logic for the particular auth-scheme.
309 // This includes the challenge's parameters. If NULL, then there is no
310 // associated auth handler.
311 scoped_ptr<HttpAuthHandler> auth_handler_[HttpAuth::AUTH_NUM_TARGETS];
312
313 // |auth_identity_| holds the (username/password) that should be used by
314 // the |auth_handler_| to generate credentials. This identity can come from
315 // a number of places (url, cache, prompt).
316 HttpAuth::Identity auth_identity_[HttpAuth::AUTH_NUM_TARGETS];
317
318 // |auth_token_| contains the opaque string to pass to the proxy or
319 // server to authenticate the client.
320 std::string auth_token_[HttpAuth::AUTH_NUM_TARGETS];
262 321
263 // Whether this transaction is waiting for proxy auth, server auth, or is 322 // Whether this transaction is waiting for proxy auth, server auth, or is
264 // not waiting for any auth at all. |pending_auth_target_| is read and 323 // not waiting for any auth at all. |pending_auth_target_| is read and
265 // cleared by RestartWithAuth(). 324 // cleared by RestartWithAuth().
266 HttpAuth::Target pending_auth_target_; 325 HttpAuth::Target pending_auth_target_;
267 326
268 CompletionCallbackImpl<HttpNetworkTransaction> io_callback_; 327 CompletionCallbackImpl<HttpNetworkTransaction> io_callback_;
269 CompletionCallback* user_callback_; 328 CompletionCallback* user_callback_;
270 329
271 scoped_refptr<HttpNetworkSession> session_; 330 scoped_refptr<HttpNetworkSession> session_;
(...skipping 21 matching lines...) Expand all
293 bool using_ssl_; // True if handling a HTTPS request 352 bool using_ssl_; // True if handling a HTTPS request
294 353
295 // True if this network transaction is using SPDY instead of HTTP. 354 // True if this network transaction is using SPDY instead of HTTP.
296 bool using_spdy_; 355 bool using_spdy_;
297 356
298 AlternateProtocolMode alternate_protocol_mode_; 357 AlternateProtocolMode alternate_protocol_mode_;
299 358
300 // Only valid if |alternate_protocol_mode_| == kUsingAlternateProtocol. 359 // Only valid if |alternate_protocol_mode_| == kUsingAlternateProtocol.
301 HttpAlternateProtocols::Protocol alternate_protocol_; 360 HttpAlternateProtocols::Protocol alternate_protocol_;
302 361
362 // True if we've used the username/password embedded in the URL. This
363 // makes sure we use the embedded identity only once for the transaction,
364 // preventing an infinite auth restart loop.
365 bool embedded_identity_used_;
366
367 // True if default credentials have already been tried for this transaction
368 // in response to an HTTP authentication challenge.
369 bool default_credentials_used_;
370
303 SSLConfig ssl_config_; 371 SSLConfig ssl_config_;
304 372
305 std::string request_headers_; 373 std::string request_headers_;
306 374
307 // The size in bytes of the buffer we use to drain the response body that 375 // The size in bytes of the buffer we use to drain the response body that
308 // we want to throw away. The response body is typically a small error 376 // we want to throw away. The response body is typically a small error
309 // page just a few hundred bytes long. 377 // page just a few hundred bytes long.
310 enum { kDrainBodyBufferSize = 1024 }; 378 enum { kDrainBodyBufferSize = 1024 };
311 379
312 // User buffer and length passed to the Read method. 380 // User buffer and length passed to the Read method.
(...skipping 12 matching lines...) Expand all
325 // The hostname and port of the endpoint. This is not necessarily the one 393 // The hostname and port of the endpoint. This is not necessarily the one
326 // specified by the URL, due to Alternate-Protocol or fixed testing ports. 394 // specified by the URL, due to Alternate-Protocol or fixed testing ports.
327 HostPortPair endpoint_; 395 HostPortPair endpoint_;
328 396
329 DISALLOW_COPY_AND_ASSIGN(HttpNetworkTransaction); 397 DISALLOW_COPY_AND_ASSIGN(HttpNetworkTransaction);
330 }; 398 };
331 399
332 } // namespace net 400 } // namespace net
333 401
334 #endif // NET_HTTP_HTTP_NETWORK_TRANSACTION_H_ 402 #endif // NET_HTTP_HTTP_NETWORK_TRANSACTION_H_
OLDNEW
« no previous file with comments | « net/http/http_auth_controller.cc ('k') | net/http/http_network_transaction.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698