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 (!base::LowerCaseEqualsASCII(props.scheme(), | 79 if (!LowerCaseEqualsASCII(props.scheme(), current_scheme_name.c_str())) |
80 current_scheme_name.c_str())) | |
81 continue; | 80 continue; |
82 authorization_result = handler->HandleAnotherChallenge(&props); | 81 authorization_result = handler->HandleAnotherChallenge(&props); |
83 if (authorization_result != HttpAuth::AUTHORIZATION_RESULT_INVALID) { | 82 if (authorization_result != HttpAuth::AUTHORIZATION_RESULT_INVALID) { |
84 *challenge_used = challenge; | 83 *challenge_used = challenge; |
85 return authorization_result; | 84 return authorization_result; |
86 } | 85 } |
87 } | 86 } |
88 // Finding no matches is equivalent to rejection. | 87 // Finding no matches is equivalent to rejection. |
89 return HttpAuth::AUTHORIZATION_RESULT_REJECT; | 88 return HttpAuth::AUTHORIZATION_RESULT_REJECT; |
90 } | 89 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 COMPILE_ASSERT(arraysize(kSchemeNames) == AUTH_SCHEME_MAX, | 140 COMPILE_ASSERT(arraysize(kSchemeNames) == AUTH_SCHEME_MAX, |
142 http_auth_scheme_names_incorrect_size); | 141 http_auth_scheme_names_incorrect_size); |
143 if (scheme < AUTH_SCHEME_BASIC || scheme >= AUTH_SCHEME_MAX) { | 142 if (scheme < AUTH_SCHEME_BASIC || scheme >= AUTH_SCHEME_MAX) { |
144 NOTREACHED(); | 143 NOTREACHED(); |
145 return "invalid_scheme"; | 144 return "invalid_scheme"; |
146 } | 145 } |
147 return kSchemeNames[scheme]; | 146 return kSchemeNames[scheme]; |
148 } | 147 } |
149 | 148 |
150 } // namespace net | 149 } // namespace net |
OLD | NEW |