| Index: tests/standalone/io/http_client_socket_reuse_test.dart
|
| diff --git a/tests/standalone/io/http_client_socket_reuse_test.dart b/tests/standalone/io/http_client_socket_reuse_test.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..715624a8d95f7f73b7cb0dc9d93c77ec24bc8b91
|
| --- /dev/null
|
| +++ b/tests/standalone/io/http_client_socket_reuse_test.dart
|
| @@ -0,0 +1,43 @@
|
| +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
| +// for details. All rights reserved. Use of this source code is governed by a
|
| +// BSD-style license that can be found in the LICENSE file.
|
| +
|
| +import "dart:async";
|
| +import "dart:io";
|
| +import "dart:uri";
|
| +import "dart:isolate";
|
| +
|
| +// By running tests sequentially, we cover the socket reuse code in HttpClient.
|
| +
|
| +void testGoogleUrls() {
|
| + int testsStarted = 0;
|
| + int testsFinished = 0;
|
| + bool allStarted = false;
|
| + HttpClient client = new HttpClient();
|
| +
|
| + Future testUrl(String url) {
|
| + testsStarted++;
|
| + var requestUri = Uri.parse(url);
|
| + return client.getUrl(requestUri)
|
| + .then((HttpClientRequest request) => request.close())
|
| + .then((HttpClientResponse response) {
|
| + Expect.isTrue(response.statusCode < 500);
|
| + if (requestUri.path.length == 0) {
|
| + Expect.isTrue(response.statusCode != 404);
|
| + }
|
| + return response.reduce(null, (previous, element) => null);
|
| + })
|
| + .catchError((error) => Expect.fail("Unexpected IO error: $error"));
|
| + }
|
| +
|
| + // TODO(3593): Use a Dart HTTP server for this test.
|
| + testUrl('http://www.google.dk')
|
| + .then((_) => testUrl('http://www.google.dk'))
|
| + .then((_) => testUrl('http://www.google.dk/#q=foo'))
|
| + .then((_) => testUrl('http://www.google.dk/#hl=da&q=foo'))
|
| + .then((_) { client.close(); });
|
| +}
|
| +
|
| +void main() {
|
| + testGoogleUrls();
|
| +}
|
|
|