summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-15 17:00:47 +0000
committerwtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-15 17:00:47 +0000
commitf494faec7c25072f57b742991ab73c620fa8395b (patch)
treee393e60dbbac382ef425f95255b11dc0a0debd2c
parent3a0f50259ff3efeb9aa5909777c1066c3c8f00a4 (diff)
downloadchromium_src-f494faec7c25072f57b742991ab73c620fa8395b.zip
chromium_src-f494faec7c25072f57b742991ab73c620fa8395b.tar.gz
chromium_src-f494faec7c25072f57b742991ab73c620fa8395b.tar.bz2
Don't call AuthOrigin(target) multiple times in
HandleAuthChallenge. Add a "const GURL& auth_origin" parameter to PopulateAuthChallenge, InvalidateRejectedAuthFromCache, and SelectNextAuthIdentityToTry to eliminate the AuthOrigin(target) calls in those three functions. R=eroman BUG=22264 TEST=none Review URL: http://codereview.chromium.org/277005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29129 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--net/http/http_network_transaction.cc29
-rw-r--r--net/http/http_network_transaction.h9
2 files changed, 22 insertions, 16 deletions
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc
index c07ef81..6324d7d 100644
--- a/net/http/http_network_transaction.cc
+++ b/net/http/http_network_transaction.cc
@@ -1707,7 +1707,8 @@ std::string HttpNetworkTransaction::AuthTargetString(
}
void HttpNetworkTransaction::InvalidateRejectedAuthFromCache(
- HttpAuth::Target target) {
+ HttpAuth::Target target,
+ const GURL& auth_origin) {
DCHECK(HaveAuth(target));
// TODO(eroman): this short-circuit can be relaxed. If the realm of
@@ -1720,7 +1721,7 @@ void HttpNetworkTransaction::InvalidateRejectedAuthFromCache(
// Clear the cache entry for the identity we just failed on.
// Note: we require the username/password to match before invalidating
// since the entry in the cache may be newer than what we used last time.
- session_->auth_cache()->Remove(AuthOrigin(target),
+ session_->auth_cache()->Remove(auth_origin,
auth_handler_[target]->realm(),
auth_identity_[target].username,
auth_identity_[target].password);
@@ -1757,7 +1758,8 @@ bool HttpNetworkTransaction::SelectPreemptiveAuth(HttpAuth::Target target) {
}
bool HttpNetworkTransaction::SelectNextAuthIdentityToTry(
- HttpAuth::Target target) {
+ HttpAuth::Target target,
+ const GURL& auth_origin) {
DCHECK(auth_handler_[target]);
DCHECK(auth_identity_[target].invalid);
@@ -1778,7 +1780,7 @@ bool HttpNetworkTransaction::SelectNextAuthIdentityToTry(
// Check the auth cache for a realm entry.
HttpAuthCache::Entry* entry = session_->auth_cache()->LookupByRealm(
- AuthOrigin(target), auth_handler_[target]->realm());
+ auth_origin, auth_handler_[target]->realm());
if (entry) {
// Disallow re-using of identity if the scheme of the originating challenge
@@ -1845,9 +1847,10 @@ int HttpNetworkTransaction::HandleAuthChallenge() {
return OK;
HttpAuth::Target target = status == 407 ?
HttpAuth::AUTH_PROXY : HttpAuth::AUTH_SERVER;
+ GURL auth_origin = AuthOrigin(target);
LOG(INFO) << "The " << AuthTargetString(target) << " "
- << AuthOrigin(target) << " requested auth"
+ << auth_origin << " requested auth"
<< AuthChallengeLogMessage();
if (target == HttpAuth::AUTH_PROXY && proxy_info_.is_direct())
@@ -1861,7 +1864,7 @@ int HttpNetworkTransaction::HandleAuthChallenge() {
// determine if the server already failed the auth or wants us to continue.
// See http://crbug.com/21015.
if (HaveAuth(target) && auth_handler_[target]->IsFinalRound()) {
- InvalidateRejectedAuthFromCache(target);
+ InvalidateRejectedAuthFromCache(target, auth_origin);
auth_handler_[target] = NULL;
auth_identity_[target] = HttpAuth::Identity();
}
@@ -1873,15 +1876,14 @@ int HttpNetworkTransaction::HandleAuthChallenge() {
// Find the best authentication challenge that we support.
HttpAuth::ChooseBestChallenge(response_.headers.get(),
target,
- AuthOrigin(target),
+ auth_origin,
&auth_handler_[target]);
}
if (!auth_handler_[target]) {
if (establishing_tunnel_) {
LOG(ERROR) << "Can't perform auth to the " << AuthTargetString(target)
- << " " << AuthOrigin(target)
- << " when establishing a tunnel"
+ << " " << auth_origin << " when establishing a tunnel"
<< AuthChallengeLogMessage();
// We are establishing a tunnel, we can't show the error page because an
@@ -1898,7 +1900,7 @@ int HttpNetworkTransaction::HandleAuthChallenge() {
if (auth_handler_[target]->NeedsIdentity()) {
// Pick a new auth identity to try, by looking to the URL and auth cache.
// If an identity to try is found, it is saved to auth_identity_[target].
- SelectNextAuthIdentityToTry(target);
+ SelectNextAuthIdentityToTry(target, auth_origin);
} else {
// Proceed with the existing identity or a null identity.
//
@@ -1914,18 +1916,19 @@ int HttpNetworkTransaction::HandleAuthChallenge() {
if (auth_identity_[target].invalid) {
// We have exhausted all identity possibilities, all we can do now is
// pass the challenge information back to the client.
- PopulateAuthChallenge(target);
+ PopulateAuthChallenge(target, auth_origin);
}
return OK;
}
-void HttpNetworkTransaction::PopulateAuthChallenge(HttpAuth::Target target) {
+void HttpNetworkTransaction::PopulateAuthChallenge(HttpAuth::Target target,
+ const GURL& auth_origin) {
// Populates response_.auth_challenge with the authentication challenge info.
// This info is consumed by URLRequestHttpJob::GetAuthChallengeInfo().
AuthChallengeInfo* auth_info = new AuthChallengeInfo;
auth_info->is_proxy = target == HttpAuth::AUTH_PROXY;
- auth_info->host_and_port = ASCIIToWide(GetHostAndPort(AuthOrigin(target)));
+ auth_info->host_and_port = ASCIIToWide(GetHostAndPort(auth_origin));
auth_info->scheme = ASCIIToWide(auth_handler_[target]->scheme());
// TODO(eroman): decode realm according to RFC 2047.
auth_info->realm = ASCIIToWide(auth_handler_[target]->realm());
diff --git a/net/http/http_network_transaction.h b/net/http/http_network_transaction.h
index 59685ab5..22acf492 100644
--- a/net/http/http_network_transaction.h
+++ b/net/http/http_network_transaction.h
@@ -248,17 +248,20 @@ class HttpNetworkTransaction : public HttpTransaction {
// Populates response_.auth_challenge with the challenge information, so that
// URLRequestHttpJob can prompt for a username/password.
- void PopulateAuthChallenge(HttpAuth::Target target);
+ 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);
+ 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);
+ 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