OLD | NEW |
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
13 // limitations under the License. | 13 // limitations under the License. |
14 | 14 |
15 #ifndef CRASHPAD_UTIL_NET_HTTP_MULTIPART_BUILDER_H_ | 15 #ifndef CRASHPAD_UTIL_NET_HTTP_MULTIPART_BUILDER_H_ |
16 #define CRASHPAD_UTIL_NET_HTTP_MULTIPART_BUILDER_H_ | 16 #define CRASHPAD_UTIL_NET_HTTP_MULTIPART_BUILDER_H_ |
17 | 17 |
18 #include <map> | 18 #include <map> |
19 #include <string> | 19 #include <string> |
20 | 20 |
21 #include "base/basictypes.h" | 21 #include "base/basictypes.h" |
22 #include "base/files/file_path.h" | 22 #include "base/files/file_path.h" |
23 #include "base/memory/scoped_ptr.h" | 23 #include "base/memory/scoped_ptr.h" |
| 24 #include "util/net/http_headers.h" |
24 | 25 |
25 namespace crashpad { | 26 namespace crashpad { |
26 | 27 |
27 class HTTPBodyStream; | 28 class HTTPBodyStream; |
28 | 29 |
29 //! \brief This class is used to build a MIME multipart message, conforming to | 30 //! \brief This class is used to build a MIME multipart message, conforming to |
30 //! RFC 2046, for use as a HTTP request body. | 31 //! RFC 2046, for use as a HTTP request body. |
31 class HTTPMultipartBuilder { | 32 class HTTPMultipartBuilder { |
32 public: | 33 public: |
33 HTTPMultipartBuilder(); | 34 HTTPMultipartBuilder(); |
(...skipping 22 matching lines...) Expand all Loading... |
56 const std::string& upload_file_name, | 57 const std::string& upload_file_name, |
57 const base::FilePath& path, | 58 const base::FilePath& path, |
58 const std::string& content_type); | 59 const std::string& content_type); |
59 | 60 |
60 //! \brief Generates the HTTPBodyStream for the data currently supplied to | 61 //! \brief Generates the HTTPBodyStream for the data currently supplied to |
61 //! the builder. | 62 //! the builder. |
62 //! | 63 //! |
63 //! \return A caller-owned HTTPBodyStream object. | 64 //! \return A caller-owned HTTPBodyStream object. |
64 scoped_ptr<HTTPBodyStream> GetBodyStream(); | 65 scoped_ptr<HTTPBodyStream> GetBodyStream(); |
65 | 66 |
66 //! \brief Gets the boundary that will be used in GetBodyStream(). | 67 //! \brief Gets the header pair for `"Content-Type"`. |
67 std::string boundary() const { return boundary_; } | 68 HTTPHeaders::value_type GetContentType() const; |
68 | 69 |
69 private: | 70 private: |
70 struct FileAttachment { | 71 struct FileAttachment { |
71 std::string filename; | 72 std::string filename; |
72 std::string content_type; | 73 std::string content_type; |
73 base::FilePath path; | 74 base::FilePath path; |
74 }; | 75 }; |
75 | 76 |
76 // Removes elements from both data maps at the specified |key|, to ensure | 77 // Removes elements from both data maps at the specified |key|, to ensure |
77 // uniqueness across the entire HTTP body. | 78 // uniqueness across the entire HTTP body. |
78 void EraseKey(const std::string& key); | 79 void EraseKey(const std::string& key); |
79 | 80 |
80 std::string boundary_; | 81 std::string boundary_; |
81 std::map<std::string, std::string> form_data_; | 82 std::map<std::string, std::string> form_data_; |
82 std::map<std::string, FileAttachment> file_attachments_; | 83 std::map<std::string, FileAttachment> file_attachments_; |
83 | 84 |
84 DISALLOW_COPY_AND_ASSIGN(HTTPMultipartBuilder); | 85 DISALLOW_COPY_AND_ASSIGN(HTTPMultipartBuilder); |
85 }; | 86 }; |
86 | 87 |
87 } // namespace crashpad | 88 } // namespace crashpad |
88 | 89 |
89 #endif // CRASHPAD_UTIL_NET_HTTP_MULTIPART_BUILDER_H_ | 90 #endif // CRASHPAD_UTIL_NET_HTTP_MULTIPART_BUILDER_H_ |
OLD | NEW |