summaryrefslogtreecommitdiffstats
path: root/net/http/http_auth.h
diff options
context:
space:
mode:
Diffstat (limited to 'net/http/http_auth.h')
-rw-r--r--net/http/http_auth.h75
1 files changed, 15 insertions, 60 deletions
diff --git a/net/http/http_auth.h b/net/http/http_auth.h
index dc78f0c..a996304 100644
--- a/net/http/http_auth.h
+++ b/net/http/http_auth.h
@@ -129,23 +129,24 @@ class HttpAuth {
const std::set<std::string>& disabled_schemes,
std::string* challenge_used);
- // ChallengeTokenizer breaks up a challenge string into the the auth scheme
- // and parameter list, according to RFC 2617 Sec 1.2:
+ // Breaks up a challenge string into the the auth scheme and parameter list,
+ // according to RFC 2617 Sec 1.2:
// challenge = auth-scheme 1*SP 1#auth-param
//
- // Check valid() after each iteration step in case it was malformed.
- // Also note that value() will give whatever is to the right of the equals
- // sign, quotemarks and all. Use unquoted_value() to get the logical value.
+ // Depending on the challenge scheme, it may be appropriate to interpret the
+ // parameters as either a base-64 encoded string or a comma-delimited list
+ // of name-value pairs. param_pairs() and base64_param() methods are provided
+ // to support either usage.
class ChallengeTokenizer {
public:
ChallengeTokenizer(std::string::const_iterator begin,
std::string::const_iterator end)
- : props_(begin, end, ','),
- valid_(true),
- begin_(begin),
+ : begin_(begin),
end_(end),
- value_is_quoted_(false),
- expect_base64_token_(false) {
+ scheme_begin_(begin),
+ scheme_end_(begin),
+ params_begin_(end),
+ params_end_(end) {
Init(begin, end);
}
@@ -161,67 +162,21 @@ class HttpAuth {
return std::string(scheme_begin_, scheme_end_);
}
- // Returns false if there was a parse error.
- bool valid() const {
- return valid_;
- }
-
- // Advances the iterator to the next name-value pair, if any.
- // Returns true if there is none to consume.
- bool GetNext();
-
- // Inform the tokenizer whether the next token should be treated as a base64
- // encoded value. If |expect_base64_token| is true, |GetNext| will treat the
- // next token as a base64 encoded value, and will include the trailing '='
- // padding rather than attempt to split the token into a name/value pair.
- // In this case, |name| will be empty, and |value| will contain the token.
- // Subsequent calls to |GetNext()| will not treat the token like a base64
- // encoded token unless the caller again calls |set_expect_base64_token|.
- void set_expect_base64_token(bool expect_base64_token) {
- expect_base64_token_ = expect_base64_token;
- }
-
- // The name of the current name-value pair.
- std::string::const_iterator name_begin() const { return name_begin_; }
- std::string::const_iterator name_end() const { return name_end_; }
- std::string name() const {
- return std::string(name_begin_, name_end_);
- }
-
- // The value of the current name-value pair.
- std::string::const_iterator value_begin() const { return value_begin_; }
- std::string::const_iterator value_end() const { return value_end_; }
- std::string value() const {
- return std::string(value_begin_, value_end_);
- }
-
- // If value() has quotemarks, unquote it.
- std::string unquoted_value() const;
-
- // True if the name-value pair's value has quote marks.
- bool value_is_quoted() const { return value_is_quoted_; }
+ HttpUtil::NameValuePairsIterator param_pairs() const;
+ std::string base64_param() const;
private:
void Init(std::string::const_iterator begin,
std::string::const_iterator end);
- HttpUtil::ValuesIterator props_;
- bool valid_;
-
std::string::const_iterator begin_;
std::string::const_iterator end_;
std::string::const_iterator scheme_begin_;
std::string::const_iterator scheme_end_;
- std::string::const_iterator name_begin_;
- std::string::const_iterator name_end_;
-
- std::string::const_iterator value_begin_;
- std::string::const_iterator value_end_;
-
- bool value_is_quoted_;
- bool expect_base64_token_;
+ std::string::const_iterator params_begin_;
+ std::string::const_iterator params_end_;
};
};