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

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

Issue 12316036: Merge IO v2 branch to bleeding edge (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased to r18818 Created 7 years, 10 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/test/client_test.dart
diff --git a/pkg/http/test/client_test.dart b/pkg/http/test/client_test.dart
index fd056c9c4233b18b8f8571bff339d73751ebe9ad..e101f282762beaf932ba5dbf3bd3c7865e60d1b5 100644
--- a/pkg/http/test/client_test.dart
+++ b/pkg/http/test/client_test.dart
@@ -13,48 +13,51 @@ import 'package:http/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';
-
- expect(client.send(request).then((response) {
- expect(response.request, equals(request));
- expect(response.statusCode, equals(200));
- expect(response.headers['single'], equals('value'));
- // dart:io internally normalizes outgoing headers so that they never have
- // multiple headers with the same name, so there's no way to test whether
- // we handle that case correctly.
-
- return response.stream.bytesToString();
- }).whenComplete(client.close), completion(parse(equals({
- 'method': 'POST',
- 'path': '/',
- 'headers': {
- 'content-type': ['application/json; charset=utf-8'],
- 'transfer-encoding': ['chunked']
- },
- 'body': '{"hello": "world"}'
- }))));
-
- request.sink.add('{"hello": "world"}'.charCodes);
- request.sink.close();
- });
-
- test('#send with an invalid URL', () {
- var client = new http.Client();
- var url = Uri.parse('http://http.invalid');
- var request = new http.StreamedRequest("POST", url);
- request.headers[HttpHeaders.CONTENT_TYPE] =
+ expect(startServer().then((_) {
+ var client = new http.Client();
+ var request = new http.StreamedRequest("POST", serverUrl);
+ request.headers[HttpHeaders.CONTENT_TYPE] =
'application/json; charset=utf-8';
- expect(client.send(request), throwsSocketIOException);
+ expect(client.send(request).then((response) {
+ expect(response.request, equals(request));
+ expect(response.statusCode, equals(200));
+ expect(response.headers['single'], equals('value'));
+ // dart:io internally normalizes outgoing headers so that they never
+ // have multiple headers with the same name, so there's no way to test
+ // whether we handle that case correctly.
+
+ return response.stream.bytesToString();
+ }).whenComplete(client.close), completion(parse(equals({
+ 'method': 'POST',
+ 'path': '/',
+ 'headers': {
+ 'content-type': ['application/json; charset=utf-8'],
+ 'transfer-encoding': ['chunked']
+ },
+ 'body': '{"hello": "world"}'
+ }))));
+
+ request.sink.add('{"hello": "world"}'.charCodes);
+ request.sink.close();
+ }), completes);
+ });
- request.sink.add('{"hello": "world"}'.charCodes);
- request.sink.close();
+ test('#send with an invalid URL', () {
+ expect(startServer().then((_) {
+ var client = new http.Client();
+ var url = Uri.parse('http://http.invalid');
+ var request = new http.StreamedRequest("POST", url);
+ request.headers[HttpHeaders.CONTENT_TYPE] =
+ 'application/json; charset=utf-8';
+
+ expect(client.send(request), throwsSocketIOException);
+
+ request.sink.add('{"hello": "world"}'.charCodes);
+ request.sink.close();
+ }), completes);
});
}
« 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