diff options
author | vandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-24 04:31:41 +0000 |
---|---|---|
committer | vandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-24 04:31:41 +0000 |
commit | 228404f535e3fcadc063c0659f1986bf8dc79995 (patch) | |
tree | 4f15241d376f4a7912fa26653abbc0af82a27e53 /net/http/http_network_transaction.h | |
parent | 1152c8fb437bafa8c1f34da72ec088cf7ebbedd3 (diff) | |
download | chromium_src-228404f535e3fcadc063c0659f1986bf8dc79995.zip chromium_src-228404f535e3fcadc063c0659f1986bf8dc79995.tar.gz chromium_src-228404f535e3fcadc063c0659f1986bf8dc79995.tar.bz2 |
Create HttpAuthController. (again)
This packages up the auth state into a single class to enable a HttpProxyClientSocket class (which is needed for SSLClientSocketPool).
Fix memory leak.
BUG=30357
TEST=existing unit tests
Review URL: http://codereview.chromium.org/2808020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50696 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_network_transaction.h')
-rw-r--r-- | net/http/http_network_transaction.h | 80 |
1 files changed, 6 insertions, 74 deletions
diff --git a/net/http/http_network_transaction.h b/net/http/http_network_transaction.h index 147c5e2..f02deb4 100644 --- a/net/http/http_network_transaction.h +++ b/net/http/http_network_transaction.h @@ -20,6 +20,7 @@ #include "net/base/ssl_config_service.h" #include "net/http/http_alternate_protocols.h" #include "net/http/http_auth.h" +#include "net/http/http_auth_controller.h" #include "net/http/http_auth_handler.h" #include "net/http/http_response_info.h" #include "net/http/http_transaction.h" @@ -240,84 +241,24 @@ class HttpNetworkTransaction : public HttpTransaction { // Returns true if we should try to add an Authorization header. bool ShouldApplyServerAuth() const; - // Adds either the proxy auth header, or the origin server auth header, - // as specified by |target|. - void AddAuthorizationHeader( - HttpAuth::Target target, HttpRequestHeaders* authorization_headers); - - // Returns a log message for all the response headers related to the auth - // challenge. - std::string AuthChallengeLogMessage() const; - // Handles HTTP status code 401 or 407. // HandleAuthChallenge() returns a network error code, or OK on success. // May update |pending_auth_target_| or |response_.auth_challenge|. int HandleAuthChallenge(bool establishing_tunnel); - // Populates response_.auth_challenge with the challenge information, so that - // URLRequestHttpJob can prompt for a username/password. - void PopulateAuthChallenge(HttpAuth::Target target, - const GURL& auth_origin); - - // Invalidates any auth cache entries after authentication has failed. - // The identity that was rejected is auth_identity_[target]. - void InvalidateRejectedAuthFromCache(HttpAuth::Target target, - const GURL& auth_origin); - - // Sets auth_identity_[target] to the next identity that the transaction - // should try. It chooses candidates by searching the auth cache - // and the URL for a username:password. Returns true if an identity - // was found. - bool SelectNextAuthIdentityToTry(HttpAuth::Target target, - const GURL& auth_origin); - - // Searches the auth cache for an entry that encompasses the request's path. - // If such an entry is found, updates auth_identity_[target] and - // auth_handler_[target] with the cache entry's data and returns true. - bool SelectPreemptiveAuth(HttpAuth::Target target); - bool HaveAuth(HttpAuth::Target target) const { - return auth_handler_[target].get() && !auth_identity_[target].invalid; + return auth_controllers_[target].get() && + auth_controllers_[target]->HaveAuth(); } - // Get the {scheme, host, port} for the authentication target - GURL AuthOrigin(HttpAuth::Target target) const; - - // Same as AuthOrigin(), but will return an invalid GURL if the target is - // invalid. - GURL PossiblyInvalidAuthOrigin(HttpAuth::Target target) const; - - // Get the absolute path of the resource needing authentication. - // For proxy authentication the path is always empty string. - std::string AuthPath(HttpAuth::Target target) const; - - // Generate an authentication token for |target| if necessary. The return - // value is a net error code. |OK| will be returned both in the case that - // a token is correctly generated synchronously, as well as when no tokens - // were necessary. - int MaybeGenerateAuthToken(HttpAuth::Target target); + // Get the {scheme, host, path, port} for the authentication target + GURL AuthURL(HttpAuth::Target target) const; void MarkBrokenAlternateProtocolAndFallback(); - // Returns a string representation of a HttpAuth::Target value that can be - // used in log messages. - static std::string AuthTargetString(HttpAuth::Target target); - static bool g_ignore_certificate_errors; - // |auth_handler_| encapsulates the logic for the particular auth-scheme. - // This includes the challenge's parameters. If NULL, then there is no - // associated auth handler. - scoped_ptr<HttpAuthHandler> auth_handler_[HttpAuth::AUTH_NUM_TARGETS]; - - // |auth_identity_| holds the (username/password) that should be used by - // the |auth_handler_| to generate credentials. This identity can come from - // a number of places (url, cache, prompt). - HttpAuth::Identity auth_identity_[HttpAuth::AUTH_NUM_TARGETS]; - - // |auth_token_| contains the opaque string to pass to the proxy or - // server to authenticate the client. - std::string auth_token_[HttpAuth::AUTH_NUM_TARGETS]; + scoped_ptr<HttpAuthController> auth_controllers_[HttpAuth::AUTH_NUM_TARGETS]; // Whether this transaction is waiting for proxy auth, server auth, or is // not waiting for any auth at all. |pending_auth_target_| is read and @@ -359,15 +300,6 @@ class HttpNetworkTransaction : public HttpTransaction { // Only valid if |alternate_protocol_mode_| == kUsingAlternateProtocol. HttpAlternateProtocols::Protocol alternate_protocol_; - // True if we've used the username/password embedded in the URL. This - // makes sure we use the embedded identity only once for the transaction, - // preventing an infinite auth restart loop. - bool embedded_identity_used_; - - // True if default credentials have already been tried for this transaction - // in response to an HTTP authentication challenge. - bool default_credentials_used_; - SSLConfig ssl_config_; std::string request_headers_; |