OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library http.test.html.streamed_request_test; |
| 6 |
| 7 import 'dart:convert'; |
| 8 |
| 9 import 'package:http/http.dart' as http; |
| 10 import 'package:http/browser_client.dart'; |
| 11 import 'package:unittest/unittest.dart'; |
| 12 |
| 13 import 'utils.dart'; |
| 14 |
| 15 void main() { |
| 16 group('contentLength', () { |
| 17 test("works when it's set", () { |
| 18 var request = new http.StreamedRequest('POST', echoUrl); |
| 19 request.contentLength = 10; |
| 20 request.sink.add([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); |
| 21 request.sink.close(); |
| 22 |
| 23 return new BrowserClient().send(request).then((response) { |
| 24 expect(response.stream.toBytes(), |
| 25 completion(equals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]))); |
| 26 }); |
| 27 }); |
| 28 |
| 29 test("works when it's not set", () { |
| 30 var request = new http.StreamedRequest('POST', echoUrl); |
| 31 request.sink.add([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); |
| 32 request.sink.close(); |
| 33 |
| 34 return new BrowserClient().send(request).then((response) { |
| 35 expect(response.stream.toBytes(), |
| 36 completion(equals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]))); |
| 37 }); |
| 38 }); |
| 39 }); |
| 40 } |
OLD | NEW |