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(); |
}); |
}); |