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

Unified Diff: pkg/http/lib/src/request.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 | « pkg/http/lib/src/multipart_request.dart ('k') | pkg/http/test/http_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/http/lib/src/request.dart
diff --git a/pkg/http/lib/src/request.dart b/pkg/http/lib/src/request.dart
index 670bc4837228ec756b1caf6ae70ac963d80003b3..525f1aed6e58fa8923592c4807f51f9dfbd01b5a 100644
--- a/pkg/http/lib/src/request.dart
+++ b/pkg/http/lib/src/request.dart
@@ -1,4 +1,4 @@
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
@@ -57,7 +57,10 @@ class Request extends BaseRequest {
_defaultEncoding = value;
var contentType = _contentType;
if (contentType != null) {
- contentType.charset = value.name;
+ contentType = new ContentType(contentType.primaryType,
+ contentType.subType,
+ charset: value.name,
+ parameters: contentType.parameters);
_contentType = contentType;
}
}
@@ -87,8 +90,14 @@ class Request extends BaseRequest {
set body(String value) {
bodyBytes = encodeString(value, encoding);
var contentType = _contentType;
- if (contentType == null) contentType = new ContentType("text", "plain");
- if (contentType.charset == null) contentType.charset = encoding.name;
+ if (contentType == null) {
+ contentType = new ContentType("text", "plain", charset: encoding.name);
+ } else if (contentType.charset == null) {
+ contentType = new ContentType(contentType.primaryType,
+ contentType.subType,
+ charset: encoding.name,
+ parameters: contentType.parameters);
+ }
_contentType = contentType;
}
« no previous file with comments | « pkg/http/lib/src/multipart_request.dart ('k') | pkg/http/test/http_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698