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: pkg/http/test/utils.dart

Issue 12504006: Make IOSink implement StringSink (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed second round of review comments 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/utils.dart ('k') | runtime/bin/socket_patch.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/http/test/utils.dart
diff --git a/pkg/http/test/utils.dart b/pkg/http/test/utils.dart
index 8b404a581386cbaa2af8ba7c238a738b21af2d04..a3960975ecb3387139b70588e66ffb3029a96c9a 100644
--- a/pkg/http/test/utils.dart
+++ b/pkg/http/test/utils.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,9 +57,18 @@ Future startServer() {
}
new ByteStream(request).toBytes().then((requestBodyBytes) {
- response.statusCode = 200;
- response.headers.contentType = new ContentType("application", "json");
- response.headers.set('single', 'value');
+ var outputEncoding;
+ var encodingName = request.queryParameters['response-encoding'];
+ if (encodingName != null) {
+ outputEncoding = requiredEncodingForCharset(encodingName);
+ } else {
+ outputEncoding = Encoding.ASCII;
+ }
+
+ response.headers.contentType =
+ new ContentType(
+ "application", "json", charset: outputEncoding.name);
+ response.headers.set('single', 'value');
var requestBody;
if (requestBodyBytes.isEmpty) {
@@ -86,17 +95,9 @@ Future startServer() {
content['headers'][name] = values;
});
- var outputEncoding;
- var encodingName = request.queryParameters['response-encoding'];
- if (encodingName != null) {
- outputEncoding = requiredEncodingForCharset(encodingName);
- } else {
- outputEncoding = Encoding.ASCII;
- }
-
var body = json.stringify(content);
response.contentLength = body.length;
- response.addString(body, outputEncoding);
+ response.write(body);
response.close();
});
});
« no previous file with comments | « pkg/http/lib/src/utils.dart ('k') | runtime/bin/socket_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698