| OLD | NEW |
| 1 // Copyright (c) 2012, 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:isolate"; | 5 import "dart:isolate"; |
| 6 import "dart:io"; | 6 import "dart:io"; |
| 7 | 7 |
| 8 void testNoBody(int totalConnections, bool explicitContentLength) { | 8 void testNoBody(int totalConnections, bool explicitContentLength) { |
| 9 var errors = 0; | 9 var errors = 0; |
| 10 HttpServer.bind("127.0.0.1", 0, totalConnections).then((server) { | 10 HttpServer.bind("127.0.0.1", 0, totalConnections).then((server) { |
| 11 server.listen( | 11 server.listen( |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 response.addString("x"); | 84 response.addString("x"); |
| 85 Expect.throws(() => response.contentLength = 3, | 85 Expect.throws(() => response.contentLength = 3, |
| 86 (e) => e is HttpException); | 86 (e) => e is HttpException); |
| 87 response.addString("x"); | 87 response.addString("x"); |
| 88 response.addString("x"); | 88 response.addString("x"); |
| 89 response.done | 89 response.done |
| 90 .then((_) { | 90 .then((_) { |
| 91 Expect.fail("Unexpected successful response completion"); | 91 Expect.fail("Unexpected successful response completion"); |
| 92 }) | 92 }) |
| 93 .catchError((e) { | 93 .catchError((e) { |
| 94 Expect.isTrue(e.error is HttpException); | 94 Expect.isTrue(e.error is HttpException, "[$e] [${e.error}]
"); |
| 95 }); | 95 }); |
| 96 response.close(); | 96 response.close(); |
| 97 Expect.throws(() => response.addString("x"), | 97 Expect.throws(() => response.addString("x"), |
| 98 (e) => e is StateError); | 98 (e) => e is StateError); |
| 99 }); | 99 }); |
| 100 }, | 100 }, |
| 101 onError: (e) => Expect.fail("Unexpected error $e")); | 101 onError: (e) => Expect.fail("Unexpected error $e")); |
| 102 | 102 |
| 103 int count = 0; | 103 int count = 0; |
| 104 HttpClient client = new HttpClient(); | 104 HttpClient client = new HttpClient(); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 | 233 |
| 234 void main() { | 234 void main() { |
| 235 testNoBody(5, false); | 235 testNoBody(5, false); |
| 236 testNoBody(5, true); | 236 testNoBody(5, true); |
| 237 testBody(5, false); | 237 testBody(5, false); |
| 238 testBody(5, true); | 238 testBody(5, true); |
| 239 testBodyChunked(5, false); | 239 testBodyChunked(5, false); |
| 240 testBodyChunked(5, true); | 240 testBodyChunked(5, true); |
| 241 testHttp10(); | 241 testHttp10(); |
| 242 } | 242 } |
| OLD | NEW |