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/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "base/strings/string_tokenizer.h" |
11 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
12 #include "net/http/http_auth_handler.h" | 13 #include "net/http/http_auth_handler.h" |
13 #include "net/http/http_auth_handler_factory.h" | 14 #include "net/http/http_auth_handler_factory.h" |
14 #include "net/http/http_request_headers.h" | 15 #include "net/http/http_request_headers.h" |
15 #include "net/http/http_response_headers.h" | 16 #include "net/http/http_response_headers.h" |
16 #include "net/http/http_util.h" | 17 #include "net/http/http_util.h" |
17 | 18 |
18 namespace net { | 19 namespace net { |
19 | 20 |
20 HttpAuth::Identity::Identity() : source(IDENT_SRC_NONE), invalid(true) {} | 21 HttpAuth::Identity::Identity() : source(IDENT_SRC_NONE), invalid(true) {} |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 --encoded_length; | 115 --encoded_length; |
115 } | 116 } |
116 return std::string(params_begin_, params_begin_ + encoded_length); | 117 return std::string(params_begin_, params_begin_ + encoded_length); |
117 } | 118 } |
118 | 119 |
119 void HttpAuth::ChallengeTokenizer::Init(std::string::const_iterator begin, | 120 void HttpAuth::ChallengeTokenizer::Init(std::string::const_iterator begin, |
120 std::string::const_iterator end) { | 121 std::string::const_iterator end) { |
121 // The first space-separated token is the auth-scheme. | 122 // The first space-separated token is the auth-scheme. |
122 // NOTE: we are more permissive than RFC 2617 which says auth-scheme | 123 // NOTE: we are more permissive than RFC 2617 which says auth-scheme |
123 // is separated by 1*SP. | 124 // is separated by 1*SP. |
124 StringTokenizer tok(begin, end, HTTP_LWS); | 125 base::StringTokenizer tok(begin, end, HTTP_LWS); |
125 if (!tok.GetNext()) { | 126 if (!tok.GetNext()) { |
126 // Default param and scheme iterators provide empty strings | 127 // Default param and scheme iterators provide empty strings |
127 return; | 128 return; |
128 } | 129 } |
129 | 130 |
130 // Save the scheme's position. | 131 // Save the scheme's position. |
131 scheme_begin_ = tok.token_begin(); | 132 scheme_begin_ = tok.token_begin(); |
132 scheme_end_ = tok.token_end(); | 133 scheme_end_ = tok.token_end(); |
133 | 134 |
134 params_begin_ = scheme_end_; | 135 params_begin_ = scheme_end_; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 COMPILE_ASSERT(arraysize(kSchemeNames) == AUTH_SCHEME_MAX, | 189 COMPILE_ASSERT(arraysize(kSchemeNames) == AUTH_SCHEME_MAX, |
189 http_auth_scheme_names_incorrect_size); | 190 http_auth_scheme_names_incorrect_size); |
190 if (scheme < AUTH_SCHEME_BASIC || scheme >= AUTH_SCHEME_MAX) { | 191 if (scheme < AUTH_SCHEME_BASIC || scheme >= AUTH_SCHEME_MAX) { |
191 NOTREACHED(); | 192 NOTREACHED(); |
192 return "invalid_scheme"; | 193 return "invalid_scheme"; |
193 } | 194 } |
194 return kSchemeNames[scheme]; | 195 return kSchemeNames[scheme]; |
195 } | 196 } |
196 | 197 |
197 } // namespace net | 198 } // namespace net |
OLD | NEW |