| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 import "dart:async"; |
| 6 import "dart:io"; |
| 7 import "dart:uri"; |
| 8 import "dart:isolate"; |
| 9 |
| 10 // By running tests sequentially, we cover the socket reuse code in HttpClient. |
| 11 |
| 12 void testGoogleUrls() { |
| 13 int testsStarted = 0; |
| 14 int testsFinished = 0; |
| 15 bool allStarted = false; |
| 16 HttpClient client = new HttpClient(); |
| 17 |
| 18 Future testUrl(String url) { |
| 19 testsStarted++; |
| 20 var requestUri = Uri.parse(url); |
| 21 return client.getUrl(requestUri) |
| 22 .then((HttpClientRequest request) => request.close()) |
| 23 .then((HttpClientResponse response) { |
| 24 Expect.isTrue(response.statusCode < 500); |
| 25 if (requestUri.path.length == 0) { |
| 26 Expect.isTrue(response.statusCode != 404); |
| 27 } |
| 28 return response.reduce(null, (previous, element) => null); |
| 29 }) |
| 30 .catchError((error) => Expect.fail("Unexpected IO error: $error")); |
| 31 } |
| 32 |
| 33 // TODO(3593): Use a Dart HTTPS server for this test. |
| 34 testUrl('https://www.google.dk') |
| 35 .then((_) => testUrl('https://www.google.dk')) |
| 36 .then((_) => testUrl('https://www.google.dk/#q=foo')) |
| 37 .then((_) => testUrl('https://www.google.dk/#hl=da&q=foo')) |
| 38 .then((_) { client.close(); }); |
| 39 } |
| 40 |
| 41 void main() { |
| 42 testGoogleUrls(); |
| 43 } |
| OLD | NEW |