| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 | 5 |
| 6 #import("dart:isolate"); | 6 #import("dart:isolate"); |
| 7 #import("dart:io"); | 7 #import("dart:io"); |
| 8 #import("dart:uri"); | 8 #import("dart:uri"); |
| 9 | 9 |
| 10 void testHttp10Close(bool closeRequest) { | 10 void testHttp10Close(bool closeRequest) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 var client = new HttpClient(); | 61 var client = new HttpClient(); |
| 62 var connection = | 62 var connection = |
| 63 client.getUrl(new Uri.fromString("http://127.0.0.1:${server.port}")); | 63 client.getUrl(new Uri.fromString("http://127.0.0.1:${server.port}")); |
| 64 connection.onResponse = (resp) { | 64 connection.onResponse = (resp) { |
| 65 int bytes = 0; | 65 int bytes = 0; |
| 66 resp.inputStream.onData = () { | 66 resp.inputStream.onData = () { |
| 67 bytes += resp.inputStream.read().length; | 67 bytes += resp.inputStream.read().length; |
| 68 if (bytes > 100) { | 68 if (bytes > 100) { |
| 69 client.shutdown(); | 69 client.shutdown(force: true); |
| 70 } | 70 } |
| 71 }; | 71 }; |
| 72 }; | 72 }; |
| 73 connection.onError = (e) => Expect.isTrue(e is HttpException); |
| 73 } | 74 } |
| 74 | 75 |
| 75 main() { | 76 main() { |
| 76 testHttp10Close(false); | 77 testHttp10Close(false); |
| 77 testHttp10Close(true); | 78 testHttp10Close(true); |
| 78 testHttp11Close(false); | 79 testHttp11Close(false); |
| 79 testHttp11Close(true); | 80 testHttp11Close(true); |
| 80 testStreamResponse(); | 81 testStreamResponse(); |
| 81 } | 82 } |
| OLD | NEW |