| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:io'; | 5 import 'dart:io'; |
| 6 import 'dart:utf'; | 6 import 'dart:utf'; |
| 7 | 7 |
| 8 import 'package:expect/expect.dart'; | 8 import 'package:expect/expect.dart'; |
| 9 | 9 |
| 10 void testHttpClientResponseBody() { | 10 void testHttpClientResponseBody() { |
| 11 new HttpBodyHandler(); | |
| 12 void test(String mimeType, | 11 void test(String mimeType, |
| 13 List<int> content, | 12 List<int> content, |
| 14 dynamic expectedBody, | 13 dynamic expectedBody, |
| 15 String type, | 14 String type, |
| 16 [bool shouldFail = false]) { | 15 [bool shouldFail = false]) { |
| 17 HttpServer.bind().then((server) { | 16 HttpServer.bind().then((server) { |
| 18 server.listen((request) { | 17 server.listen((request) { |
| 19 request.listen( | 18 request.listen( |
| 20 (_) {}, | 19 (_) {}, |
| 21 onDone: () { | 20 onDone: () { |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 "json"); | 157 "json"); |
| 159 test("application/json", | 158 test("application/json", |
| 160 '{ bad json }'.codeUnits, | 159 '{ bad json }'.codeUnits, |
| 161 null, | 160 null, |
| 162 "json", | 161 "json", |
| 163 true); | 162 true); |
| 164 | 163 |
| 165 test(null, "body".codeUnits, "body".codeUnits, "binary"); | 164 test(null, "body".codeUnits, "body".codeUnits, "binary"); |
| 166 } | 165 } |
| 167 | 166 |
| 168 | |
| 169 void main() { | 167 void main() { |
| 170 testHttpClientResponseBody(); | 168 testHttpClientResponseBody(); |
| 171 testHttpServerRequestBody(); | 169 testHttpServerRequestBody(); |
| 172 } | 170 } |
| OLD | NEW |