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

Unified Diff: pkg/http/lib/src/multipart_file.dart

Issue 12440002: Make instances of HeaderValue and ContentType immutable (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments from nweiz@ Created 7 years, 9 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
« no previous file with comments | « no previous file | pkg/http/lib/src/multipart_request.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« no previous file with comments | « no previous file | pkg/http/lib/src/multipart_request.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698