| 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() { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 }); | 25 }); |
| 26 }); | 26 }); |
| 27 | 27 |
| 28 var client = new HttpClient(); | 28 var client = new HttpClient(); |
| 29 client.get("127.0.0.1", server.port, "/") | 29 client.get("127.0.0.1", server.port, "/") |
| 30 .then((request) => request.close()) | 30 .then((request) => request.close()) |
| 31 .then(HttpBodyHandler.processResponse) | 31 .then(HttpBodyHandler.processResponse) |
| 32 .then((body) { | 32 .then((body) { |
| 33 if (shouldFail) Expect.fail("Error expected"); | 33 if (shouldFail) Expect.fail("Error expected"); |
| 34 Expect.equals(type, body.type); | 34 Expect.equals(type, body.type); |
| 35 Expect.isNotNull(body.response); |
| 35 switch (type) { | 36 switch (type) { |
| 36 case "text": | 37 case "text": |
| 37 Expect.equals(expectedBody, body.body); | 38 Expect.equals(expectedBody, body.body); |
| 38 break; | 39 break; |
| 39 | 40 |
| 40 case "json": | 41 case "json": |
| 41 Expect.mapEquals(expectedBody, body.body); | 42 Expect.mapEquals(expectedBody, body.body); |
| 42 break; | 43 break; |
| 43 | 44 |
| 44 default: | 45 default: |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 "json", | 162 "json", |
| 162 true); | 163 true); |
| 163 | 164 |
| 164 test(null, "body".codeUnits, "body".codeUnits, "binary"); | 165 test(null, "body".codeUnits, "body".codeUnits, "binary"); |
| 165 } | 166 } |
| 166 | 167 |
| 167 void main() { | 168 void main() { |
| 168 testHttpClientResponseBody(); | 169 testHttpClientResponseBody(); |
| 169 testHttpServerRequestBody(); | 170 testHttpServerRequestBody(); |
| 170 } | 171 } |
| OLD | NEW |