Chromium Code Reviews| Index: third_party/WebKit/Source/platform/network/ParsedContentHeaderFieldParameters.h |
| diff --git a/third_party/WebKit/Source/platform/network/ParsedContentHeaderFieldParameters.h b/third_party/WebKit/Source/platform/network/ParsedContentHeaderFieldParameters.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e63c6d2670956c09aef595cff6d55670abcd0fa5 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/platform/network/ParsedContentHeaderFieldParameters.h |
| @@ -0,0 +1,60 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef ParsedContentHeaderFieldParameters_h |
| +#define ParsedContentHeaderFieldParameters_h |
| + |
| +#include "platform/PlatformExport.h" |
| +#include "platform/wtf/Allocator.h" |
| +#include "platform/wtf/HashMap.h" |
| +#include "platform/wtf/text/StringHash.h" |
| + |
| +namespace blink { |
| + |
| +class ContentHeaderFieldInput; |
| + |
| +// ParsedContentHeaderFieldParameters parses content header field |
|
kinuko
2017/05/23 11:27:31
ditto
e_hakkinen
2017/05/23 20:07:02
Done.
|
| +// parameters as specified in RFC2045 and stores them. It is used internally by |
| +// ParsedContentDisposition and ParsedContentType classes. |
| +// FIXME: add support for comments. |
| +class PLATFORM_EXPORT ParsedContentHeaderFieldParameters final { |
| + STACK_ALLOCATED(); |
| + |
| + public: |
| + // When |Relaxed| is specified, the parser parses parameter values in a sloppy |
| + // manner, i.e., only ';' and '"' are treated as special characters. |
| + // See https://chromiumcodereview.appspot.com/23043002. |
| + // When |Strict| is specified, the parser does not allow multiple values |
| + // for the same parameter. Some RFCs based on RFC2045 (e.g. RFC6838) note that |
| + // "It is an error for a specific parameter to be specified more than once." |
| + enum class Mode { |
| + kNormal, |
| + kRelaxed, |
| + kStrict, |
| + }; |
| + |
| + ParsedContentHeaderFieldParameters(); |
| + |
| + // Note that in the case of multiple values for the same name, the last value |
| + // is returned. |
| + String ParameterValueForName(const String&) const; |
| + size_t ParameterCount() const; |
| + |
| + bool IsValid() const { return is_valid_; } |
| + |
| + void ParseParameters(ContentHeaderFieldInput, Mode); |
| + |
| + static ParsedContentHeaderFieldParameters CreateForTesting( |
| + const String&, |
| + Mode = Mode::kNormal); |
| + |
| + private: |
| + typedef HashMap<String, String> KeyValuePairs; |
| + bool is_valid_; |
| + KeyValuePairs parameters_; |
| +}; |
| + |
| +} // namespace blink |
| + |
| +#endif |