Index: pkg/http/lib/src/multipart_file.dart |
diff --git a/pkg/http/lib/src/multipart_file.dart b/pkg/http/lib/src/multipart_file.dart |
index aa30fc350989bd82a6a98f7e92e13ae6696ef45b..2f1f10268ee7a54b2408f65be234c835c9d23d18 100644 |
--- a/pkg/http/lib/src/multipart_file.dart |
+++ b/pkg/http/lib/src/multipart_file.dart |
@@ -67,12 +67,15 @@ class MultipartFile { |
/// the future may be inferred from [filename]. |
factory MultipartFile.fromString(String field, String value, |
{String filename, ContentType contentType}) { |
- contentType = contentType == null ? new ContentType("text", "plain") : |
- // Make a copy of the original contentType so we can modify charset. |
- new ContentType.fromString(contentType.toString()); |
+ contentType = contentType == null ? new ContentType("text", "plain") |
+ : contentType; |
var charset = contentType.charset; |
var encoding = encodingForCharset(contentType.charset, Encoding.UTF_8); |
- contentType.charset = encoding.name; |
+ // Make a new contentType with ensured charset. |
+ contentType = new ContentType(contentType.primaryType, |
+ contentType.subType, |
+ charset: encoding.name, |
+ parameters: contentType.parameters); |
return new MultipartFile.fromBytes(field, encodeString(value, encoding), |
filename: filename, |