summaryrefslogtreecommitdiffstats
path: root/net/http/http_auth.cc
diff options
context:
space:
mode:
authorericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-08 06:46:23 +0000
committerericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-08 06:46:23 +0000
commitf9ee6b5a5925d8496f05309963c42bfdd3ec1a8b (patch)
tree7867cc64559bf86408da5a744e918d2861bf3889 /net/http/http_auth.cc
parentf6028ee8661996ba41763a6601469ebd599480f5 (diff)
downloadchromium_src-f9ee6b5a5925d8496f05309963c42bfdd3ec1a8b.zip
chromium_src-f9ee6b5a5925d8496f05309963c42bfdd3ec1a8b.tar.gz
chromium_src-f9ee6b5a5925d8496f05309963c42bfdd3ec1a8b.tar.bz2
- Add preemptive authorization (new http stack only)
- Check for auth identity in URL (new http stack only) - Move auth cache logic out of url request job, and hide it in the url request ftp job and http transaction classes. Note: Somehow the original codereview thread got corrupted so it was recreated. The real review comments should be under (http://codereview.chromium.org/6481) Review URL: http://codereview.chromium.org/8231 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5064 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_auth.cc')
-rw-r--r--net/http/http_auth.cc38
1 files changed, 20 insertions, 18 deletions
diff --git a/net/http/http_auth.cc b/net/http/http_auth.cc
index 324f901..c3764cc 100644
--- a/net/http/http_auth.cc
+++ b/net/http/http_auth.cc
@@ -16,42 +16,44 @@
namespace net {
// static
-HttpAuthHandler* HttpAuth::ChooseBestChallenge(
- const HttpResponseHeaders* headers, Target target) {
+void HttpAuth::ChooseBestChallenge(const HttpResponseHeaders* headers,
+ Target target,
+ scoped_refptr<HttpAuthHandler>* handler) {
// Choose the challenge whose authentication handler gives the maximum score.
- scoped_ptr<HttpAuthHandler> best;
+ scoped_refptr<HttpAuthHandler> best;
const std::string header_name = GetChallengeHeaderName(target);
std::string cur_challenge;
void* iter = NULL;
while (headers->EnumerateHeader(&iter, header_name, &cur_challenge)) {
- scoped_ptr<HttpAuthHandler> cur(
- CreateAuthHandler(cur_challenge, target));
- if (cur.get() && (!best.get() || best->score() < cur->score()))
- best.reset(cur.release());
+ scoped_refptr<HttpAuthHandler> cur;
+ CreateAuthHandler(cur_challenge, target, &cur);
+ if (cur && (!best || best->score() < cur->score()))
+ best.swap(cur);
}
- return best.release();
+ handler->swap(best);
}
// static
-HttpAuthHandler* HttpAuth::CreateAuthHandler(const std::string& challenge,
- Target target) {
+void HttpAuth::CreateAuthHandler(const std::string& challenge,
+ Target target,
+ scoped_refptr<HttpAuthHandler>* handler) {
// Find the right auth handler for the challenge's scheme.
ChallengeTokenizer props(challenge.begin(), challenge.end());
- scoped_ptr<HttpAuthHandler> handler;
+ scoped_refptr<HttpAuthHandler> tmp_handler;
if (LowerCaseEqualsASCII(props.scheme(), "basic")) {
- handler.reset(new HttpAuthHandlerBasic());
+ tmp_handler = new HttpAuthHandlerBasic();
} else if (LowerCaseEqualsASCII(props.scheme(), "digest")) {
- handler.reset(new HttpAuthHandlerDigest());
+ tmp_handler = new HttpAuthHandlerDigest();
}
- if (handler.get()) {
- if (!handler->InitFromChallenge(challenge.begin(), challenge.end(),
- target)) {
+ if (tmp_handler) {
+ if (!tmp_handler->InitFromChallenge(challenge.begin(), challenge.end(),
+ target)) {
// Invalid/unsupported challenge.
- return NULL;
+ tmp_handler = NULL;
}
}
- return handler.release();
+ handler->swap(tmp_handler);
}
void HttpAuth::ChallengeTokenizer::Init(std::string::const_iterator begin,