OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NET_HTTP_HTTP_CONTENT_DISPOSITION_H_ | 5 #ifndef NET_HTTP_HTTP_CONTENT_DISPOSITION_H_ |
6 #define NET_HTTP_HTTP_CONTENT_DISPOSITION_H_ | 6 #define NET_HTTP_HTTP_CONTENT_DISPOSITION_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "net/base/net_export.h" | 11 #include "net/base/net_export.h" |
12 | 12 |
13 namespace net { | 13 namespace net { |
14 | 14 |
15 class NET_EXPORT HttpContentDisposition { | 15 class NET_EXPORT HttpContentDisposition { |
16 public: | 16 public: |
17 enum Type { | 17 enum Type { |
18 INLINE, | 18 INLINE, |
19 ATTACHMENT, | 19 ATTACHMENT, |
20 }; | 20 }; |
21 | 21 |
22 // Properties of the Content-Disposition header. Used for UMA. | |
23 struct ParseResult { | |
24 ParseResult(); | |
25 | |
26 // A valid disposition-type was present. | |
27 bool has_disposition_type; | |
28 | |
29 // The disposition-type was not 'inline' or 'attachment'. | |
30 bool has_unknown_disposition_type; | |
31 | |
32 // Has a valid non-empty 'name' attribute. | |
33 bool has_name; | |
34 | |
35 // Has a valid non-empty 'filename' attribute. | |
36 bool has_filename; | |
37 | |
38 // Has a valid non-empty 'filename*' attribute. | |
39 bool has_ext_filename; | |
40 | |
41 // The following fields are properties of the 'filename' attribute: | |
42 | |
43 // quoted-string contained non-ASCII characters. | |
rvargas (doing something else)
2012/12/14 22:49:54
nit: I know why you do it this way, but do you min
asanka
2012/12/15 01:57:32
Done.
| |
44 bool has_non_ascii_strings; | |
45 | |
46 // quoted-string contained percent-encoding. | |
47 bool has_percent_encoded_strings; | |
48 | |
49 // quoted-string contained RFC 2047 encoded words. | |
50 bool has_rfc2047_encoded_strings; | |
51 }; | |
52 | |
22 HttpContentDisposition(const std::string& header, | 53 HttpContentDisposition(const std::string& header, |
23 const std::string& referrer_charset); | 54 const std::string& referrer_charset); |
24 ~HttpContentDisposition(); | 55 ~HttpContentDisposition(); |
25 | 56 |
26 bool is_attachment() const { return type() == ATTACHMENT; } | 57 bool is_attachment() const { return type() == ATTACHMENT; } |
27 | 58 |
28 Type type() const { return type_; } | 59 Type type() const { return type_; } |
29 const std::string& filename() const { return filename_; } | 60 const std::string& filename() const { return filename_; } |
30 | 61 |
62 const ParseResult& parse_result() const { return parse_result_; } | |
63 | |
31 private: | 64 private: |
32 void Parse(const std::string& header, const std::string& referrer_charset); | 65 void Parse(const std::string& header, const std::string& referrer_charset); |
33 std::string::const_iterator ConsumeDispositionType( | 66 std::string::const_iterator ConsumeDispositionType( |
34 std::string::const_iterator begin, std::string::const_iterator end); | 67 std::string::const_iterator begin, std::string::const_iterator end); |
35 | 68 |
36 Type type_; | 69 Type type_; |
37 std::string filename_; | 70 std::string filename_; |
71 ParseResult parse_result_; | |
38 | 72 |
39 DISALLOW_COPY_AND_ASSIGN(HttpContentDisposition); | 73 DISALLOW_COPY_AND_ASSIGN(HttpContentDisposition); |
40 }; | 74 }; |
41 | 75 |
42 } // namespace net | 76 } // namespace net |
43 | 77 |
44 #endif // NET_HTTP_HTTP_CONTENT_DISPOSITION_H_ | 78 #endif // NET_HTTP_HTTP_CONTENT_DISPOSITION_H_ |
OLD | NEW |