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

Unified Diff: third_party/WebKit/Source/core/fetch/FetchUtils.cpp

Issue 1364993003: Add FetchUtils::normalizeHeaderValue( ) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/fetch/FetchUtils.cpp
diff --git a/third_party/WebKit/Source/core/fetch/FetchUtils.cpp b/third_party/WebKit/Source/core/fetch/FetchUtils.cpp
index 4139db3f4428bb32a9a66747453e79fd4ffcbf12..72b4429f64535ae6e0a38e8615ddeec5bf046280 100644
--- a/third_party/WebKit/Source/core/fetch/FetchUtils.cpp
+++ b/third_party/WebKit/Source/core/fetch/FetchUtils.cpp
@@ -16,6 +16,11 @@ namespace blink {
namespace {
+bool isHTTPWhitespace(UChar chr)
+{
+ return chr == ' ' || chr == '\n' || chr == '\t' || chr == '\r';
+}
+
class ForbiddenHeaderNames {
WTF_MAKE_NONCOPYABLE(ForbiddenHeaderNames); WTF_MAKE_FAST_ALLOCATED(ForbiddenHeaderNames);
public:
@@ -189,4 +194,13 @@ AtomicString FetchUtils::normalizeMethod(const AtomicString& method)
return method;
}
+String FetchUtils::normalizeHeaderValue(const String& value)
+{
+ // https://fetch.spec.whatwg.org/#concept-header-value-normalize
+ // Strip leading and trailing whitespace from header value.
+ // HTTP whitespace bytes are 0x09, 0x0A, 0x0D, and 0x20.
+
+ return value.stripWhiteSpace(isHTTPWhitespace);
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/fetch/FetchUtils.h ('k') | third_party/WebKit/Source/core/fetch/FetchUtilsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698