Index: net/http/http_util.cc |
diff --git a/net/http/http_util.cc b/net/http/http_util.cc |
index 2b3db6dc6d512ef6ebf6fde7b24a0e51b8cee521..08382d9a18a0f2a49f406fc1f330b07c95aee263 100644 |
--- a/net/http/http_util.cc |
+++ b/net/http/http_util.cc |
@@ -344,6 +344,24 @@ bool HttpUtil::IsValidHeaderValue(const std::string& value) { |
} |
// static |
+bool HttpUtil::IsValidHeaderValueRFC7230(const base::StringPiece& value) { |
+ // This empty string is a valid header-value. |
+ if (value.empty()) |
+ return true; |
+ |
+ // Check leading/trailing whitespaces. |
+ if (IsLWS(value[0]) || IsLWS(value[value.size() - 1])) |
+ return false; |
+ |
+ // Check each octet is |field-vchar|, |SP| or |HTAB|. |
+ for (unsigned char c : value) { |
+ if (c == 0x7F || (c < 0x20 && c != '\t')) |
+ 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) { |