| OLD | NEW |
| 1 // (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // (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 // VMOptions= | 5 // VMOptions= |
| 6 // VMOptions=--short_socket_read | 6 // VMOptions=--short_socket_read |
| 7 // VMOptions=--short_socket_write | 7 // VMOptions=--short_socket_write |
| 8 // VMOptions=--short_socket_read --short_socket_write | 8 // VMOptions=--short_socket_read --short_socket_write |
| 9 | 9 |
| 10 import "dart:async"; |
| 11 import "dart:io"; |
| 12 |
| 13 import "package:async_helper/async_helper.dart"; |
| 10 import "package:expect/expect.dart"; | 14 import "package:expect/expect.dart"; |
| 11 import "dart:async"; | |
| 12 import "dart:isolate"; | |
| 13 import "dart:io"; | |
| 14 | 15 |
| 15 // Client makes a HTTP 1.0 request without connection keep alive. The | 16 // Client makes a HTTP 1.0 request without connection keep alive. The |
| 16 // server sets a content length but still needs to close the | 17 // server sets a content length but still needs to close the |
| 17 // connection as there is no keep alive. | 18 // connection as there is no keep alive. |
| 18 void testHttpIPv6() { | 19 void testHttpIPv6() { |
| 20 asyncStart(); |
| 19 HttpServer.bind("::", 0).then((server) { | 21 HttpServer.bind("::", 0).then((server) { |
| 20 server.listen((HttpRequest request) { | 22 server.listen((HttpRequest request) { |
| 21 Expect.equals(request.headers["host"][0], "[::]:${server.port}"); | 23 Expect.equals(request.headers["host"][0], "[::1]:${server.port}"); |
| 22 Expect.equals(request.requestedUri.host, "::"); | 24 Expect.equals(request.requestedUri.host, "::1"); |
| 23 request.response.close(); | 25 request.response.close(); |
| 24 }); | 26 }); |
| 25 | 27 |
| 26 var client = new HttpClient(); | 28 var client = new HttpClient(); |
| 27 var url = Uri.parse('http://[::]:${server.port}/xxx'); | 29 var url = Uri.parse('http://[::1]:${server.port}/xxx'); |
| 28 Expect.equals(url.host, '::'); | 30 Expect.equals(url.host, '::1'); |
| 29 client.openUrl('GET', url) | 31 client.openUrl('GET', url) |
| 30 .then((request) => request.close()) | 32 .then((request) => request.close()) |
| 31 .then((response) { | 33 .then((response) { |
| 32 Expect.equals(response.statusCode, HttpStatus.OK); | 34 Expect.equals(response.statusCode, HttpStatus.OK); |
| 33 }).whenComplete(() { | 35 }).whenComplete(() { |
| 34 server.close(); | 36 server.close(); |
| 35 client.close(); | 37 client.close(); |
| 38 asyncEnd(); |
| 36 }); | 39 }); |
| 37 }); | 40 }); |
| 38 } | 41 } |
| 39 | 42 |
| 40 | 43 |
| 41 | 44 |
| 42 void main() { | 45 void main() { |
| 43 testHttpIPv6(); | 46 testHttpIPv6(); |
| 44 } | 47 } |
| OLD | NEW |