summaryrefslogtreecommitdiffstats
path: root/net/http/http_auth_handler_digest.cc
diff options
context:
space:
mode:
authorerikwright@chromium.org <erikwright@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-30 13:28:44 +0000
committererikwright@chromium.org <erikwright@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-30 13:28:44 +0000
commite3fe59bfb0912596e8975f9c50b01683c19ee5d9 (patch)
tree04b9c722b6f9db105acfc70bd286cb4f78c7d843 /net/http/http_auth_handler_digest.cc
parentd1cd0715ae8b15982b7ca46f4497eeddb4b73bca (diff)
downloadchromium_src-e3fe59bfb0912596e8975f9c50b01683c19ee5d9.zip
chromium_src-e3fe59bfb0912596e8975f9c50b01683c19ee5d9.tar.gz
chromium_src-e3fe59bfb0912596e8975f9c50b01683c19ee5d9.tar.bz2
Extract name-value pair parsing from http_auth.cc (ChallengeTokenizer) into http_util.cc (NameValuePairsIterator). In preparation for re-use of name-value pair parsing in ChromeFrame (for X-UA-Compatible header).
BUG=None TEST=net_unittests (HttpAuth* and HttpUtilTest.NameValuePairs*) Review URL: http://codereview.chromium.org/3525004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61061 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_auth_handler_digest.cc')
-rw-r--r--net/http/http_auth_handler_digest.cc25
1 files changed, 14 insertions, 11 deletions
diff --git a/net/http/http_auth_handler_digest.cc b/net/http/http_auth_handler_digest.cc
index 7c14a47..a802213 100644
--- a/net/http/http_auth_handler_digest.cc
+++ b/net/http/http_auth_handler_digest.cc
@@ -212,15 +212,16 @@ HttpAuth::AuthorizationResult HttpAuthHandlerDigest::HandleAnotherChallenge(
// to differentiate between stale and rejected responses.
// Note that the state of the current handler is not mutated - this way if
// there is a rejection the realm hasn't changed.
- if (!challenge->valid() ||
- !LowerCaseEqualsASCII(challenge->scheme(), "digest"))
+ if (!LowerCaseEqualsASCII(challenge->scheme(), "digest"))
return HttpAuth::AUTHORIZATION_RESULT_INVALID;
+ HttpUtil::NameValuePairsIterator parameters = challenge->param_pairs();
+
// Try to find the "stale" value.
- while (challenge->GetNext()) {
- if (!LowerCaseEqualsASCII(challenge->name(), "stale"))
+ while (parameters.GetNext()) {
+ if (!LowerCaseEqualsASCII(parameters.name(), "stale"))
continue;
- if (LowerCaseEqualsASCII(challenge->unquoted_value(), "true"))
+ if (LowerCaseEqualsASCII(parameters.unquoted_value(), "true"))
return HttpAuth::AUTHORIZATION_RESULT_STALE;
}
@@ -258,24 +259,26 @@ bool HttpAuthHandlerDigest::ParseChallenge(
realm_ = nonce_ = domain_ = opaque_ = std::string();
// FAIL -- Couldn't match auth-scheme.
- if (!challenge->valid() ||
- !LowerCaseEqualsASCII(challenge->scheme(), "digest"))
+ if (!LowerCaseEqualsASCII(challenge->scheme(), "digest"))
return false;
+ HttpUtil::NameValuePairsIterator parameters = challenge->param_pairs();
+
// Loop through all the properties.
- while (challenge->GetNext()) {
- if (challenge->value().empty()) {
+ while (parameters.GetNext()) {
+ if (parameters.value().empty()) {
DLOG(INFO) << "Invalid digest property";
return false;
}
// FAIL -- couldn't parse a property.
- if (!ParseChallengeProperty(challenge->name(), challenge->unquoted_value()))
+ if (!ParseChallengeProperty(parameters.name(),
+ parameters.unquoted_value()))
return false;
}
// Check if tokenizer failed.
- if (!challenge->valid())
+ if (!parameters.valid())
return false;
// Check that a minimum set of properties were provided.