Chromium Code Reviews| Index: pkg/http_multi_server/test/http_multi_server_test.dart |
| diff --git a/pkg/http_multi_server/test/http_multi_server_test.dart b/pkg/http_multi_server/test/http_multi_server_test.dart |
| index a3d9062067bced9da28b8452eccec18c0212a906..3e6f73b5bc1ab0c1fa5fe53cf536b3e0c3b835ea 100644 |
| --- a/pkg/http_multi_server/test/http_multi_server_test.dart |
| +++ b/pkg/http_multi_server/test/http_multi_server_test.dart |
| @@ -108,7 +108,7 @@ void main() { |
| expect(http.read("http://127.0.0.1:${server.port}/"), |
| completion(equals("got request"))); |
| - return supportsIpV6.then((supportsIpV6) { |
| + return _supportsIpV6.then((supportsIpV6) { |
| if (!supportsIpV6) return; |
| expect(http.read("http://[::1]:${server.port}/"), |
| completion(equals("got request"))); |
| @@ -117,6 +117,24 @@ void main() { |
| }); |
| } |
| +/// A cache for [supportsIpV6]. |
| +bool _supportsIpV6Cache; |
| + |
| +/// Returns whether this computer supports binding to IPv6 addresses. |
| +Future<bool> get _supportsIpV6 { |
| + if (_supportsIpV6Cache != null) return new Future.value(_supportsIpV6Cache); |
| + |
| + return ServerSocket.bind(InternetAddress.LOOPBACK_IP_V6, 0).then((socket) { |
| + _supportsIpV6Cache = true; |
| + socket.close(); |
| + return true; |
| + }).catchError((error) { |
| + if (error is! SocketException) throw error; |
| + _supportsIpV6Cache = false; |
| + return false; |
| + }); |
| +} |
|
nweiz
2014/07/09 02:02:01
I'm kind of uncomfortable about using different IP
|
| + |
| /// Makes a GET request to the root of [server] and returns the response. |
| Future<http.Response> _get(HttpServer server) => http.get(_urlFor(server)); |