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

Side by Side Diff: third_party/WebKit/Source/platform/network/ParsedContentHeaderFieldParameters.h

Issue 2880543003: Implement a parser for Content-Disposition header fields (Closed)
Patch Set: Class comments 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 unified diff | Download patch
OLDNEW
(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 ParsedContentHeaderFieldParameters_h
6 #define ParsedContentHeaderFieldParameters_h
7
8 #include "platform/PlatformExport.h"
9 #include "platform/wtf/Allocator.h"
10 #include "platform/wtf/HashMap.h"
11 #include "platform/wtf/text/StringHash.h"
12
13 namespace blink {
14
15 class ContentHeaderFieldInput;
16
17 // ParsedContentHeaderFieldParameters parses content header field
kinuko 2017/05/23 11:27:31 ditto
e_hakkinen 2017/05/23 20:07:02 Done.
18 // parameters as specified in RFC2045 and stores them. It is used internally by
19 // ParsedContentDisposition and ParsedContentType classes.
20 // FIXME: add support for comments.
21 class PLATFORM_EXPORT ParsedContentHeaderFieldParameters final {
22 STACK_ALLOCATED();
23
24 public:
25 // When |Relaxed| is specified, the parser parses parameter values in a sloppy
26 // manner, i.e., only ';' and '"' are treated as special characters.
27 // See https://chromiumcodereview.appspot.com/23043002.
28 // When |Strict| is specified, the parser does not allow multiple values
29 // for the same parameter. Some RFCs based on RFC2045 (e.g. RFC6838) note that
30 // "It is an error for a specific parameter to be specified more than once."
31 enum class Mode {
32 kNormal,
33 kRelaxed,
34 kStrict,
35 };
36
37 ParsedContentHeaderFieldParameters();
38
39 // Note that in the case of multiple values for the same name, the last value
40 // is returned.
41 String ParameterValueForName(const String&) const;
42 size_t ParameterCount() const;
43
44 bool IsValid() const { return is_valid_; }
45
46 void ParseParameters(ContentHeaderFieldInput, Mode);
47
48 static ParsedContentHeaderFieldParameters CreateForTesting(
49 const String&,
50 Mode = Mode::kNormal);
51
52 private:
53 typedef HashMap<String, String> KeyValuePairs;
54 bool is_valid_;
55 KeyValuePairs parameters_;
56 };
57
58 } // namespace blink
59
60 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698