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

Side by Side 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, 9 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 unified diff | Download patch
« no previous file with comments | « Source/platform/network/HTTPParsers.h ('k') | Source/platform/network/HTTPParsersTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 2 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
3 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 3 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
4 * Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ 4 * Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/
5 * Copyright (C) 2009 Google Inc. All rights reserved. 5 * Copyright (C) 2009 Google Inc. All rights reserved.
6 * Copyright (C) 2011 Apple Inc. All Rights Reserved. 6 * Copyright (C) 2011 Apple Inc. All Rights Reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
(...skipping 26 matching lines...) Expand all
37 #include "wtf/MathExtras.h" 37 #include "wtf/MathExtras.h"
38 #include "wtf/text/CString.h" 38 #include "wtf/text/CString.h"
39 #include "wtf/text/StringBuilder.h" 39 #include "wtf/text/StringBuilder.h"
40 #include "wtf/text/WTFString.h" 40 #include "wtf/text/WTFString.h"
41 #include "wtf/unicode/CharacterNames.h" 41 #include "wtf/unicode/CharacterNames.h"
42 42
43 using namespace WTF; 43 using namespace WTF;
44 44
45 namespace blink { 45 namespace blink {
46 46
47 static bool isWhitespace(UChar chr)
48 {
49 return (chr == ' ') || (chr == '\t');
50 }
51
47 // true if there is more to parse, after incrementing pos past whitespace. 52 // true if there is more to parse, after incrementing pos past whitespace.
48 // Note: Might return pos == str.length() 53 // Note: Might return pos == str.length()
49 static inline bool skipWhiteSpace(const String& str, unsigned& pos, bool fromHtt pEquivMeta) 54 static inline bool skipWhiteSpace(const String& str, unsigned& pos, bool fromHtt pEquivMeta)
50 { 55 {
51 unsigned len = str.length(); 56 unsigned len = str.length();
52 57
53 if (fromHttpEquivMeta) { 58 if (fromHttpEquivMeta) {
54 while (pos < len && str[pos] <= ' ') 59 while (pos < len && str[pos] <= ' ')
55 ++pos; 60 ++pos;
56 } else { 61 } else {
57 while (pos < len && (str[pos] == '\t' || str[pos] == ' ')) 62 while (pos < len && isWhitespace(str[pos]))
58 ++pos; 63 ++pos;
59 } 64 }
60 65
61 return pos < len; 66 return pos < len;
62 } 67 }
63 68
64 // Returns true if the function can match the whole token (case insensitive) 69 // Returns true if the function can match the whole token (case insensitive)
65 // incrementing pos on match, otherwise leaving pos unchanged. 70 // incrementing pos on match, otherwise leaving pos unchanged.
66 // Note: Might return pos == str.length() 71 // Note: Might return pos == str.length()
67 static inline bool skipToken(const String& str, unsigned& pos, const char* token ) 72 static inline bool skipToken(const String& str, unsigned& pos, const char* token )
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 849
845 if (!cacheControlHeader.containsNoCache) { 850 if (!cacheControlHeader.containsNoCache) {
846 // Handle Pragma: no-cache 851 // Handle Pragma: no-cache
847 // This is deprecated and equivalent to Cache-control: no-cache 852 // This is deprecated and equivalent to Cache-control: no-cache
848 // Don't bother tokenizing the value, it is not important 853 // Don't bother tokenizing the value, it is not important
849 cacheControlHeader.containsNoCache = pragmaValue.lower().contains(noCach eDirective); 854 cacheControlHeader.containsNoCache = pragmaValue.lower().contains(noCach eDirective);
850 } 855 }
851 return cacheControlHeader; 856 return cacheControlHeader;
852 } 857 }
853 858
859 void parseCommaDelimitedHeader(const String& headerValue, CommaDelimitedHeaderSe t& headerSet)
860 {
861 Vector<String> results;
862 headerValue.split(",", results);
863 for (auto& value : results)
864 headerSet.add(value.stripWhiteSpace(isWhitespace));
854 } 865 }
866
867 }
OLDNEW
« 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