OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/http/http_auth.h" | 5 #include "net/http/http_auth.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/strings/string_tokenizer.h" | 10 #include "base/strings/string_tokenizer.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 if (disabled_schemes.find(current_scheme) != disabled_schemes.end()) | 69 if (disabled_schemes.find(current_scheme) != disabled_schemes.end()) |
70 return HttpAuth::AUTHORIZATION_RESULT_REJECT; | 70 return HttpAuth::AUTHORIZATION_RESULT_REJECT; |
71 std::string current_scheme_name = SchemeToString(current_scheme); | 71 std::string current_scheme_name = SchemeToString(current_scheme); |
72 const std::string header_name = GetChallengeHeaderName(target); | 72 const std::string header_name = GetChallengeHeaderName(target); |
73 void* iter = NULL; | 73 void* iter = NULL; |
74 std::string challenge; | 74 std::string challenge; |
75 HttpAuth::AuthorizationResult authorization_result = | 75 HttpAuth::AuthorizationResult authorization_result = |
76 HttpAuth::AUTHORIZATION_RESULT_INVALID; | 76 HttpAuth::AUTHORIZATION_RESULT_INVALID; |
77 while (headers->EnumerateHeader(&iter, header_name, &challenge)) { | 77 while (headers->EnumerateHeader(&iter, header_name, &challenge)) { |
78 HttpAuthChallengeTokenizer props(challenge.begin(), challenge.end()); | 78 HttpAuthChallengeTokenizer props(challenge.begin(), challenge.end()); |
79 if (!LowerCaseEqualsASCII(props.scheme(), current_scheme_name.c_str())) | 79 if (!base::LowerCaseEqualsASCII(props.scheme(), |
| 80 current_scheme_name.c_str())) |
80 continue; | 81 continue; |
81 authorization_result = handler->HandleAnotherChallenge(&props); | 82 authorization_result = handler->HandleAnotherChallenge(&props); |
82 if (authorization_result != HttpAuth::AUTHORIZATION_RESULT_INVALID) { | 83 if (authorization_result != HttpAuth::AUTHORIZATION_RESULT_INVALID) { |
83 *challenge_used = challenge; | 84 *challenge_used = challenge; |
84 return authorization_result; | 85 return authorization_result; |
85 } | 86 } |
86 } | 87 } |
87 // Finding no matches is equivalent to rejection. | 88 // Finding no matches is equivalent to rejection. |
88 return HttpAuth::AUTHORIZATION_RESULT_REJECT; | 89 return HttpAuth::AUTHORIZATION_RESULT_REJECT; |
89 } | 90 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 COMPILE_ASSERT(arraysize(kSchemeNames) == AUTH_SCHEME_MAX, | 141 COMPILE_ASSERT(arraysize(kSchemeNames) == AUTH_SCHEME_MAX, |
141 http_auth_scheme_names_incorrect_size); | 142 http_auth_scheme_names_incorrect_size); |
142 if (scheme < AUTH_SCHEME_BASIC || scheme >= AUTH_SCHEME_MAX) { | 143 if (scheme < AUTH_SCHEME_BASIC || scheme >= AUTH_SCHEME_MAX) { |
143 NOTREACHED(); | 144 NOTREACHED(); |
144 return "invalid_scheme"; | 145 return "invalid_scheme"; |
145 } | 146 } |
146 return kSchemeNames[scheme]; | 147 return kSchemeNames[scheme]; |
147 } | 148 } |
148 | 149 |
149 } // namespace net | 150 } // namespace net |
OLD | NEW |