Index: net/base/mime_util.cc |
diff --git a/net/base/mime_util.cc b/net/base/mime_util.cc |
index 67c7242c815b7283ae09d8a65a3713ea9aaa10ff..a23647e6484a043e4913ee47d26ec5537f821f96 100644 |
--- a/net/base/mime_util.cc |
+++ b/net/base/mime_util.cc |
@@ -14,6 +14,7 @@ |
#include "base/lazy_instance.h" |
#include "base/logging.h" |
#include "base/string_util.h" |
+#include "base/stringprintf.h" |
wtc
2013/05/14 18:45:29
I believe this can be avoided. See the comment bel
Henrik Grunell
2013/05/15 11:49:31
Done.
|
#include "base/strings/string_split.h" |
#include "base/utf_string_conversions.h" |
@@ -987,4 +988,24 @@ bool IsSupportedCertificateMimeType(const std::string& mime_type) { |
return file_type != CERTIFICATE_MIME_TYPE_UNKNOWN; |
} |
+void AddMultipartValueForUpload(const std::string& value_name, |
+ const std::string& value, |
+ const std::string& mime_boundary, |
+ const std::string& content_type, |
+ std::string* post_data) { |
+ DCHECK(post_data); |
+ // First line is the boundary |
wtc
2013/05/14 18:45:29
Nit: add periods (.) to the end of sentences in co
Henrik Grunell
2013/05/15 11:49:31
Done.
|
+ post_data->append("--" + mime_boundary + "\r\n"); |
+ // Next line is the Content-disposition |
+ post_data->append(base::StringPrintf("Content-Disposition: form-data; " |
+ "name=\"%s\"\r\n", value_name.c_str())); |
wtc
2013/05/14 18:45:29
The only format specifier this function uses is %s
Henrik Grunell
2013/05/15 11:49:31
Just copied the function over. Agree that's better
|
+ if (!content_type.empty()) { |
+ // If Content-type is specified, the next line is that |
+ post_data->append(base::StringPrintf("Content-Type: %s\r\n", |
+ content_type.c_str())); |
+ } |
+ // Leave an empty line and append the value. |
+ post_data->append(base::StringPrintf("\r\n%s\r\n", value.c_str())); |
+} |
+ |
} // namespace net |