diff options
| author | Ben Murdoch <benm@google.com> | 2010-11-18 18:32:45 +0000 |
|---|---|---|
| committer | Ben Murdoch <benm@google.com> | 2010-11-18 18:38:07 +0000 |
| commit | 513209b27ff55e2841eac0e4120199c23acce758 (patch) | |
| tree | aeba30bb08c5f47c57003544e378a377c297eee6 /net/http/http_util.h | |
| parent | 164f7496de0fbee436b385a79ead9e3cb81a50c1 (diff) | |
| download | external_chromium-513209b27ff55e2841eac0e4120199c23acce758.zip external_chromium-513209b27ff55e2841eac0e4120199c23acce758.tar.gz external_chromium-513209b27ff55e2841eac0e4120199c23acce758.tar.bz2 | |
Merge Chromium at r65505: Initial merge by git.
Change-Id: I31d8f1d8cd33caaf7f47ffa7350aef42d5fbdb45
Diffstat (limited to 'net/http/http_util.h')
| -rw-r--r-- | net/http/http_util.h | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/net/http/http_util.h b/net/http/http_util.h index f41c4e4..2f5bd85 100644 --- a/net/http/http_util.h +++ b/net/http/http_util.h @@ -275,6 +275,9 @@ class HttpUtil { // Each pair consists of a token (the name), an equals sign, and either a // token or quoted-string (the value). Arbitrary HTTP LWS is permitted outside // of and between names, values, and delimiters. + // + // String iterators returned from this class' methods may be invalidated upon + // calls to GetNext() or after the NameValuePairsIterator is destroyed. class NameValuePairsIterator { public: NameValuePairsIterator(std::string::const_iterator begin, @@ -295,15 +298,16 @@ class HttpUtil { 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_; } + std::string::const_iterator value_begin() const { + return value_is_quoted_ ? unquoted_value_.begin() : value_begin_; + } + std::string::const_iterator value_end() const { + return value_is_quoted_ ? unquoted_value_.end() : value_end_; + } + std::string value() const { + return value_is_quoted_ ? unquoted_value_ : std::string(value_begin_, + value_end_); + } private: HttpUtil::ValuesIterator props_; @@ -318,6 +322,11 @@ class HttpUtil { std::string::const_iterator value_begin_; std::string::const_iterator value_end_; + // Do not store iterators into this string. The NameValuePairsIterator + // is copyable/assignable, and if copied the copy's iterators would point + // into the original's unquoted_value_ member. + std::string unquoted_value_; + bool value_is_quoted_; }; }; |
