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

Unified Diff: third_party/WebKit/Source/platform/network/ParsedContentType.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/ParsedContentType.h
diff --git a/third_party/WebKit/Source/platform/network/ParsedContentType.h b/third_party/WebKit/Source/platform/network/ParsedContentType.h
index a014b6df29e96afdd1f980bc9a05e4d54e79c728..f0ab012882d52f217a327733dc27ad812b5956fe 100644
--- a/third_party/WebKit/Source/platform/network/ParsedContentType.h
+++ b/third_party/WebKit/Source/platform/network/ParsedContentType.h
@@ -33,6 +33,7 @@
#define ParsedContentType_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"
@@ -46,17 +47,8 @@ class PLATFORM_EXPORT ParsedContentType 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,
- };
+ using Mode = ParsedContentHeaderFieldParameters::Mode;
+
explicit ParsedContentType(const String&, Mode = Mode::kNormal);
String MimeType() const { return mime_type_; }
@@ -64,20 +56,16 @@ class PLATFORM_EXPORT ParsedContentType final {
// 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;
+ String ParameterValueForName(const String& name) const {
+ return parameters_.ParameterValueForName(name);
+ }
+ size_t ParameterCount() const { return parameters_.ParameterCount(); }
- bool IsValid() const { return is_valid_; }
+ bool IsValid() const { return parameters_.IsValid(); }
private:
- bool Parse(const String&);
-
- const Mode mode_;
- bool is_valid_;
-
- typedef HashMap<String, String> KeyValuePairs;
- KeyValuePairs parameters_;
String mime_type_;
+ ParsedContentHeaderFieldParameters parameters_;
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698