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 #include <algorithm> | 5 #include <algorithm> |
6 #include <iterator> | 6 #include <iterator> |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "net/base/mime_util.h" | 10 #include "net/base/mime_util.h" |
11 #include "net/base/platform_mime_util.h" | 11 #include "net/base/platform_mime_util.h" |
12 | 12 |
13 #include "base/hash_tables.h" | 13 #include "base/hash_tables.h" |
14 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
17 #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.
| |
17 #include "base/strings/string_split.h" | 18 #include "base/strings/string_split.h" |
18 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
19 | 20 |
20 using std::string; | 21 using std::string; |
21 | 22 |
22 namespace { | 23 namespace { |
23 | 24 |
24 struct MediaType { | 25 struct MediaType { |
25 const char name[12]; | 26 const char name[12]; |
26 const char matcher[13]; | 27 const char matcher[13]; |
(...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
980 } | 981 } |
981 return CERTIFICATE_MIME_TYPE_UNKNOWN; | 982 return CERTIFICATE_MIME_TYPE_UNKNOWN; |
982 } | 983 } |
983 | 984 |
984 bool IsSupportedCertificateMimeType(const std::string& mime_type) { | 985 bool IsSupportedCertificateMimeType(const std::string& mime_type) { |
985 CertificateMimeType file_type = | 986 CertificateMimeType file_type = |
986 GetCertificateMimeTypeForMimeType(mime_type); | 987 GetCertificateMimeTypeForMimeType(mime_type); |
987 return file_type != CERTIFICATE_MIME_TYPE_UNKNOWN; | 988 return file_type != CERTIFICATE_MIME_TYPE_UNKNOWN; |
988 } | 989 } |
989 | 990 |
991 void AddMultipartValueForUpload(const std::string& value_name, | |
992 const std::string& value, | |
993 const std::string& mime_boundary, | |
994 const std::string& content_type, | |
995 std::string* post_data) { | |
996 DCHECK(post_data); | |
997 // 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.
| |
998 post_data->append("--" + mime_boundary + "\r\n"); | |
999 // Next line is the Content-disposition | |
1000 post_data->append(base::StringPrintf("Content-Disposition: form-data; " | |
1001 "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
| |
1002 if (!content_type.empty()) { | |
1003 // If Content-type is specified, the next line is that | |
1004 post_data->append(base::StringPrintf("Content-Type: %s\r\n", | |
1005 content_type.c_str())); | |
1006 } | |
1007 // Leave an empty line and append the value. | |
1008 post_data->append(base::StringPrintf("\r\n%s\r\n", value.c_str())); | |
1009 } | |
1010 | |
990 } // namespace net | 1011 } // namespace net |
OLD | NEW |