| 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 // Client that makes HttpClient secure gets from a server that replies with | 5 // Client that makes HttpClient secure gets from a server that replies with |
| 6 // a certificate that can't be authenticated. This checks that all the | 6 // a certificate that can't be authenticated. This checks that all the |
| 7 // futures returned from these connection attempts complete (with errors). | 7 // futures returned from these connection attempts complete (with errors). |
| 8 | 8 |
| 9 import "dart:async"; | 9 import "dart:async"; |
| 10 import "dart:io"; | 10 import "dart:io"; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 } | 21 } |
| 22 } | 22 } |
| 23 | 23 |
| 24 const HOST_NAME = "localhost"; | 24 const HOST_NAME = "localhost"; |
| 25 | 25 |
| 26 Future runClients(int port) { | 26 Future runClients(int port) { |
| 27 HttpClient client = new HttpClient(); | 27 HttpClient client = new HttpClient(); |
| 28 | 28 |
| 29 var testFutures = []; | 29 var testFutures = []; |
| 30 for (int i = 0; i < 20; ++i) { | 30 for (int i = 0; i < 20; ++i) { |
| 31 testFutures.add( | 31 testFutures.add(client.getUrl(Uri.parse('https://$HOST_NAME:$port/')).then( |
| 32 client.getUrl(Uri.parse('https://$HOST_NAME:$port/')) | 32 (HttpClientRequest request) { |
| 33 .then((HttpClientRequest request) { | 33 expect(false, "Request succeeded"); |
| 34 expect(false, "Request succeeded"); | 34 }, onError: (e) { |
| 35 }, onError: (e) { | 35 // Remove ArgumentError once null default context is supported. |
| 36 // Remove ArgumentError once null default context is supported. | 36 expect( |
| 37 expect(e is HandshakeException || | 37 e is HandshakeException || e is SocketException || e is ArgumentError, |
| 38 e is SocketException || | 38 "Error is wrong type: $e"); |
| 39 e is ArgumentError, | 39 })); |
| 40 "Error is wrong type: $e"); | |
| 41 })); | |
| 42 } | 40 } |
| 43 return Future.wait(testFutures); | 41 return Future.wait(testFutures); |
| 44 } | 42 } |
| 45 | 43 |
| 46 void main(List<String> args) { | 44 void main(List<String> args) { |
| 47 runClients(int.parse(args[0])) | 45 runClients(int.parse(args[0])).then((_) => print('SUCCESS')); |
| 48 .then((_) => print('SUCCESS')); | |
| 49 } | 46 } |
| OLD | NEW |