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

Unified Diff: third_party/WebKit/Source/platform/network/ParsedContentHeaderFieldParameters.h

Issue 2880543003: Implement a parser for Content-Disposition header fields (Closed)
Patch Set: License headers Created 3 years, 7 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/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..a7a4622f6a9e7693b79347b9a08d986e013ef638
--- /dev/null
+++ b/third_party/WebKit/Source/platform/network/ParsedContentHeaderFieldParameters.h
@@ -0,0 +1,59 @@
+// 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 ParsedParameterizedContentHeaderField_h
+#define ParsedParameterizedContentHeaderField_h
kinuko 2017/05/22 07:39:45 Things look inconsistent across here, class-level
e_hakkinen 2017/05/22 08:11:59 Yep, old class name from before refactoring. Fixed
+
+#include "platform/PlatformExport.h"
+#include "platform/wtf/Allocator.h"
+#include "platform/wtf/HashMap.h"
+#include "platform/wtf/text/StringHash.h"
+
+namespace blink {
+
+class ContentHeaderFieldInput;
+
+// ParsedParameterizedContentHeaderField parses the constructor argument as
+// specified in RFC2045 and stores the result.
+// 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

Powered by Google App Engine
This is Rietveld 408576698