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

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

Issue 2880543003: Implement a parser for Content-Disposition header fields (Closed)
Patch Set: Rebase 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/ParsedContentDisposition.h
diff --git a/third_party/WebKit/Source/platform/network/ParsedContentDisposition.h b/third_party/WebKit/Source/platform/network/ParsedContentDisposition.h
new file mode 100644
index 0000000000000000000000000000000000000000..7cb7686cf820f62db93cbc7865ade65e96704aae
--- /dev/null
+++ b/third_party/WebKit/Source/platform/network/ParsedContentDisposition.h
@@ -0,0 +1,45 @@
+// 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 ParsedContentDisposition_h
+#define ParsedContentDisposition_h
+
+#include "platform/PlatformExport.h"
+#include "platform/network/ParsedContentHeaderFieldParameters.h"
+#include "platform/wtf/Allocator.h"
+#include "platform/wtf/HashMap.h"
+#include "platform/wtf/text/StringHash.h"
+
+namespace blink {
+
+// Parses the content of a Content-Disposition header field into disposition
+// type and parameters and stores them.
+class PLATFORM_EXPORT ParsedContentDisposition final {
+ STACK_ALLOCATED();
+
+ public:
+ using Mode = ParsedContentHeaderFieldParameters::Mode;
+
+ explicit ParsedContentDisposition(const String&, Mode = Mode::kNormal);
+
+ String Type() const { return type_; }
+ String Filename() const;
+
+ // Note that in the case of multiple values for the same name, the last value
+ // is returned.
+ String ParameterValueForName(const String& name) const {
+ return parameters_.ParameterValueForName(name);
+ }
+ size_t ParameterCount() const { return parameters_.ParameterCount(); }
+
+ bool IsValid() const { return parameters_.IsValid(); }
+
+ private:
+ String type_;
+ ParsedContentHeaderFieldParameters parameters_;
+};
+
+} // namespace blink
+
+#endif

Powered by Google App Engine
This is Rietveld 408576698