| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef HeaderFieldTokenizer_h |
| 6 #define HeaderFieldTokenizer_h |
| 7 |
| 8 #include "platform/network/ParsedContentHeaderFieldParameters.h" |
| 9 #include "platform/wtf/text/WTFString.h" |
| 10 |
| 11 namespace blink { |
| 12 |
| 13 // Parses header fields into tokens, quoted strings and separators. |
| 14 // Commonly used by ParsedContent* classes. |
| 15 class HeaderFieldTokenizer final { |
| 16 STACK_ALLOCATED(); |
| 17 |
| 18 public: |
| 19 using Mode = ParsedContentHeaderFieldParameters::Mode; |
| 20 |
| 21 explicit HeaderFieldTokenizer(const String& header_field); |
| 22 HeaderFieldTokenizer(HeaderFieldTokenizer&&); |
| 23 |
| 24 // Try to parse a separator character, a token or either a token or a quoted |
| 25 // string from the |header_field| input. Return |true| on success. Return |
| 26 // |false| if the separator character, the token or the quoted string is |
| 27 // missing or invalid. |
| 28 bool Consume(char); |
| 29 bool ConsumeToken(Mode, StringView& output); |
| 30 bool ConsumeTokenOrQuotedString(Mode, String& output); |
| 31 |
| 32 unsigned Index() const { return index_; } |
| 33 bool IsConsumed() const { return index_ >= input_.length(); } |
| 34 void SkipSpaces(); |
| 35 |
| 36 private: |
| 37 bool ConsumeQuotedString(String& output); |
| 38 |
| 39 unsigned index_; |
| 40 const String input_; |
| 41 }; |
| 42 |
| 43 } // namespace blink |
| 44 |
| 45 #endif |
| OLD | NEW |