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

Unified Diff: pkg/http/test/client_test.dart

Issue 11363063: Add an HTTP library that wraps dart:io. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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/pubspec.yaml ('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/test/client_test.dart
diff --git a/pkg/http/test/client_test.dart b/pkg/http/test/client_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..e7c3501e8a735f88747f892a88a81ba780c82324
--- /dev/null
+++ b/pkg/http/test/client_test.dart
@@ -0,0 +1,43 @@
+// Copyright (c) 2012, 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.
+
+library client_test;
+
+import 'dart:io';
+
+import '../../unittest/lib/unittest.dart';
+import '../lib/http.dart' as http;
+import '../lib/src/utils.dart';
+import 'utils.dart';
+
+void main() {
+ setUp(startServer);
+ tearDown(stopServer);
+
+ test('#send a StreamedRequest', () {
+ var client = new http.Client();
+ var request = new http.StreamedRequest("POST", serverUrl);
+ request.headers[HttpHeaders.CONTENT_TYPE] =
+ 'application/json; charset=utf-8';
+
+ var future = client.send(request).chain((response) {
+ expect(response.statusCode, equals(200));
+ return consumeInputStream(response.stream);
+ }).transform((bytes) => new String.fromCharCodes(bytes));
+ future.onComplete((_) => client.close());
+
+ expect(future, completion(parse(equals({
+ 'method': 'POST',
+ 'path': '/',
+ 'headers': {
+ 'content-type': ['application/json; charset=utf-8'],
+ 'transfer-encoding': ['chunked']
+ },
+ 'body': '{"hello": "world"}'
+ }))));
+
+ request.stream.writeString('{"hello": "world"}');
+ request.stream.close();
+ });
+}
« no previous file with comments | « pkg/http/pubspec.yaml ('k') | pkg/http/test/http_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698