Index: net/http/http_auth_handler_basic.cc |
diff --git a/net/http/http_auth_handler_basic.cc b/net/http/http_auth_handler_basic.cc |
index 4c509f46bb2d7b2e42bd7f4511575258adc567a3..7525cb982e1d6beeab8e15ddb6ded009d6765838 100644 |
--- a/net/http/http_auth_handler_basic.cc |
+++ b/net/http/http_auth_handler_basic.cc |
@@ -54,32 +54,32 @@ bool ParseRealm(const HttpAuthChallengeTokenizer& tokenizer, |
} // namespace |
-bool HttpAuthHandlerBasic::Init(HttpAuthChallengeTokenizer* challenge) { |
+int HttpAuthHandlerBasic::Init(const HttpAuthChallengeTokenizer& challenge) { |
auth_scheme_ = kBasicSchemeName; |
return ParseChallenge(challenge); |
} |
-bool HttpAuthHandlerBasic::ParseChallenge( |
- HttpAuthChallengeTokenizer* challenge) { |
+int HttpAuthHandlerBasic::ParseChallenge( |
+ const HttpAuthChallengeTokenizer& challenge) { |
// Verify the challenge's auth-scheme. |
- if (!challenge->SchemeIs(kBasicSchemeName)) |
- return false; |
+ if (!challenge.SchemeIs(kBasicSchemeName)) |
+ return ERR_INVALID_RESPONSE; |
std::string realm; |
- if (!ParseRealm(*challenge, &realm)) |
- return false; |
+ if (!ParseRealm(challenge, &realm)) |
+ return ERR_INVALID_RESPONSE; |
realm_ = realm; |
- return true; |
+ return OK; |
} |
HttpAuth::AuthorizationResult HttpAuthHandlerBasic::HandleAnotherChallenge( |
- HttpAuthChallengeTokenizer* challenge) { |
+ const HttpAuthChallengeTokenizer& challenge) { |
// Basic authentication is always a single round, so any responses |
// should be treated as a rejection. However, if the new challenge |
// is for a different realm, then indicate the realm change. |
std::string realm; |
- if (!ParseRealm(*challenge, &realm)) |
+ if (!ParseRealm(challenge, &realm)) |
return HttpAuth::AUTHORIZATION_RESULT_INVALID; |
return (realm_ != realm)? |
HttpAuth::AUTHORIZATION_RESULT_DIFFERENT_REALM: |
@@ -87,8 +87,10 @@ HttpAuth::AuthorizationResult HttpAuthHandlerBasic::HandleAnotherChallenge( |
} |
int HttpAuthHandlerBasic::GenerateAuthTokenImpl( |
- const AuthCredentials* credentials, const HttpRequestInfo*, |
- const CompletionCallback&, std::string* auth_token) { |
+ const AuthCredentials* credentials, |
+ const HttpRequestInfo&, |
+ const CompletionCallback&, |
+ std::string* auth_token) { |
DCHECK(credentials); |
// TODO(eroman): is this the right encoding of username/password? |
std::string base64_username_password; |
@@ -106,7 +108,7 @@ HttpAuthHandlerBasic::Factory::~Factory() { |
} |
int HttpAuthHandlerBasic::Factory::CreateAuthHandler( |
- HttpAuthChallengeTokenizer* challenge, |
+ const HttpAuthChallengeTokenizer& challenge, |
HttpAuth::Target target, |
const GURL& origin, |
CreateReason reason, |
@@ -116,10 +118,11 @@ int HttpAuthHandlerBasic::Factory::CreateAuthHandler( |
// TODO(cbentzel): Move towards model of parsing in the factory |
// method and only constructing when valid. |
scoped_ptr<HttpAuthHandler> tmp_handler(new HttpAuthHandlerBasic()); |
- if (!tmp_handler->InitFromChallenge(challenge, target, origin, net_log)) |
- return ERR_INVALID_RESPONSE; |
- handler->swap(tmp_handler); |
- return OK; |
+ int result = |
+ tmp_handler->HandleInitialChallenge(challenge, target, origin, net_log); |
+ if (result == OK) |
+ handler->swap(tmp_handler); |
+ return result; |
} |
} // namespace net |