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

Unified Diff: Source/platform/network/HTTPParsers.cpp

Issue 961773002: Add a comma delimited syntax parser and use it for Accept-CH (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added layout test Created 5 years, 10 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
« no previous file with comments | « Source/platform/network/HTTPParsers.h ('k') | Source/platform/network/HTTPParsersTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/network/HTTPParsers.cpp
diff --git a/Source/platform/network/HTTPParsers.cpp b/Source/platform/network/HTTPParsers.cpp
index 71ac44138112cc6e93430fe5327d71da43b2db2c..79406a0beca78d1d0d685373991be4fae7c18828 100644
--- a/Source/platform/network/HTTPParsers.cpp
+++ b/Source/platform/network/HTTPParsers.cpp
@@ -44,6 +44,11 @@ using namespace WTF;
namespace blink {
+static bool isWhitespace(UChar chr)
+{
+ return (chr == ' ') || (chr == '\t');
+}
+
// true if there is more to parse, after incrementing pos past whitespace.
// Note: Might return pos == str.length()
static inline bool skipWhiteSpace(const String& str, unsigned& pos, bool fromHttpEquivMeta)
@@ -54,7 +59,7 @@ static inline bool skipWhiteSpace(const String& str, unsigned& pos, bool fromHtt
while (pos < len && str[pos] <= ' ')
++pos;
} else {
- while (pos < len && (str[pos] == '\t' || str[pos] == ' '))
+ while (pos < len && isWhitespace(str[pos]))
++pos;
}
@@ -851,4 +856,12 @@ CacheControlHeader parseCacheControlDirectives(const AtomicString& cacheControlV
return cacheControlHeader;
}
+void parseCommaDelimitedHeader(const String& headerValue, CommaDelimitedHeaderSet& headerSet)
+{
+ Vector<String> results;
+ headerValue.split(",", results);
+ for (auto& value : results)
+ headerSet.add(value.stripWhiteSpace(isWhitespace));
+}
+
}
« no previous file with comments | « Source/platform/network/HTTPParsers.h ('k') | Source/platform/network/HTTPParsersTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698