| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_challenge_tokenizer.h" | 5 #include "net/http/http_auth_challenge_tokenizer.h" |
| 6 | 6 |
| 7 #include "base/strings/string_tokenizer.h" | 7 #include "base/strings/string_tokenizer.h" |
| 8 #include "base/strings/string_util.h" |
| 9 #include "net/http/http_util.h" |
| 8 | 10 |
| 9 namespace net { | 11 namespace net { |
| 10 | 12 |
| 11 HttpAuthChallengeTokenizer::HttpAuthChallengeTokenizer( | 13 HttpAuthChallengeTokenizer::HttpAuthChallengeTokenizer( |
| 12 std::string::const_iterator begin, | 14 std::string::const_iterator begin, |
| 13 std::string::const_iterator end) | 15 std::string::const_iterator end) |
| 14 : begin_(begin), | 16 : begin_(begin), |
| 15 end_(end), | 17 end_(end), |
| 16 scheme_begin_(begin), | 18 scheme_begin_(begin), |
| 17 scheme_end_(begin), | 19 scheme_end_(begin), |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 56 |
| 55 // Save the scheme's position. | 57 // Save the scheme's position. |
| 56 scheme_begin_ = tok.token_begin(); | 58 scheme_begin_ = tok.token_begin(); |
| 57 scheme_end_ = tok.token_end(); | 59 scheme_end_ = tok.token_end(); |
| 58 | 60 |
| 59 params_begin_ = scheme_end_; | 61 params_begin_ = scheme_end_; |
| 60 params_end_ = end; | 62 params_end_ = end; |
| 61 HttpUtil::TrimLWS(¶ms_begin_, ¶ms_end_); | 63 HttpUtil::TrimLWS(¶ms_begin_, ¶ms_end_); |
| 62 } | 64 } |
| 63 | 65 |
| 66 std::string HttpAuthChallengeTokenizer::NormalizedScheme() const { |
| 67 if (!HttpUtil::IsToken(scheme_begin_, scheme_end_)) |
| 68 return std::string(); |
| 69 return base::ToLowerASCII(base::StringPiece(scheme_begin_, scheme_end_)); |
| 70 } |
| 71 |
| 72 bool HttpAuthChallengeTokenizer::SchemeIs( |
| 73 const base::StringPiece& scheme) const { |
| 74 DCHECK(base::ToLowerASCII(scheme) == scheme); |
| 75 return base::LowerCaseEqualsASCII( |
| 76 base::StringPiece(scheme_begin_, scheme_end_), scheme); |
| 77 } |
| 78 |
| 64 } // namespace net | 79 } // namespace net |
| OLD | NEW |