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

Unified Diff: net/base/mime_util.cc

Issue 15076008: Move AddMultipartValueForUpload to net/base/mime_util.h/cc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Again (same as patch 1), hopefully diffs are OK now. Created 7 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
« chrome/browser/chrome_to_mobile_service.cc ('K') | « net/base/mime_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« chrome/browser/chrome_to_mobile_service.cc ('K') | « net/base/mime_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698