Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(406)

Side by Side Diff: net/http/http_auth_challenge_tokenizer.cc

Issue 1157333005: [net/http auth] Use strings to identify authentication schemes. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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(&params_begin_, &params_end_); 63 HttpUtil::TrimLWS(&params_begin_, &params_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
OLDNEW
« no previous file with comments | « net/http/http_auth_challenge_tokenizer.h ('k') | net/http/http_auth_challenge_tokenizer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698