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