Chromium Code Reviews| Index: net/http/http_util.cc |
| diff --git a/net/http/http_util.cc b/net/http/http_util.cc |
| index f1e5143e701a5334499dccc9a814ae4c96d2023b..16e32b57b9bf39bdccd2c30354773e4e8b173d31 100644 |
| --- a/net/http/http_util.cc |
| +++ b/net/http/http_util.cc |
| @@ -346,6 +346,28 @@ bool HttpUtil::IsValidHeaderValue(const std::string& value) { |
| } |
| // static |
| +bool HttpUtil::IsValidHeaderValueRFC7230(base::StringPiece value) { |
|
davidben
2015/09/30 16:38:18
Optional: Now that you have a base::StringPiece, I
hiroshige
2015/12/15 12:00:26
Done.
|
| + base::StringPiece::const_iterator value_begin = value.begin(); |
| + base::StringPiece::const_iterator value_end = value.end(); |
| + |
| + // Empty string is a valid header-value. |
|
davidben
2015/09/30 16:38:18
Nit: "This empty string is a valid header-value.
hiroshige
2015/12/15 12:00:26
Done.
|
| + if (value_begin == value_end) |
| + return true; |
| + |
| + // Check leading/trailing whitespaces. |
| + if (IsLWS(*value_begin) || IsLWS(*(value_end - 1))) |
| + return false; |
| + |
| + // Check each octet is |field-vchar|, |SP| or |HTAB|. |
| + for (; value_begin != value_end; ++value_begin) { |
| + unsigned char c = *value_begin; |
| + if (c == 0x7F || c > 0xFF || (c < 0x20 && c != '\t')) |
|
davidben
2015/09/30 16:38:18
c > 0xFF isn't possible. char's are one byte.
hiroshige
2015/12/15 12:00:26
Done.
|
| + return false; |
| + } |
| + return true; |
| +} |
| + |
| +// static |
| std::string HttpUtil::StripHeaders(const std::string& headers, |
| const char* const headers_to_remove[], |
| size_t headers_to_remove_len) { |