Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(726)

Unified Diff: test/http_basic_test.dart

Issue 2962013002: Modify address used in tests to be IPv agnostic and not use 127.0.0.1, to support IPv6 only environ… (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/http_basic_test.dart
diff --git a/test/http_basic_test.dart b/test/http_basic_test.dart
index 02a4455edc06a46a628fc59bd8551ce05da78f11..4a3be09d0e229f556b76a8c5e450a3b7eb633dc0 100644
--- a/test/http_basic_test.dart
+++ b/test/http_basic_test.dart
@@ -3,8 +3,9 @@
// BSD-style license that can be found in the LICENSE file.
import "dart:async";
-import "dart:isolate";
import "dart:io";
+import "dart:isolate";
+
import "package:sync_http/sync_http.dart";
import "package:test/test.dart";
@@ -173,12 +174,13 @@ class TestServer {
SendPort get dispatchSendPort => _dispatchPort.sendPort;
- void dispatch(var message) {
+ dispatch(var message) async {
TestServerCommand command = message[0];
SendPort replyTo = message[1];
if (command.isStart) {
try {
- HttpServer.bind("127.0.0.1", 0).then((server) {
+ var addr = (await InternetAddress.lookup("localhost"))[0];
+ HttpServer.bind(addr, 0).then((server) {
_server = server;
_server.listen(_requestReceivedHandler);
replyTo.send(new TestServerStatus.started(_server.port));
@@ -223,7 +225,7 @@ Future testGET() async {
TestServerMain testServerMain = new TestServerMain();
testServerMain.setServerStartedHandler((int port) {
var request =
- SyncHttpClient.getUrl(new Uri.http("127.0.0.1:$port", "/0123456789"));
+ SyncHttpClient.getUrl(new Uri.http("localhost:$port", "/0123456789"));
var response = request.close();
expect(HttpStatus.OK, equals(response.statusCode));
expect(11, equals(response.contentLength));
@@ -246,7 +248,7 @@ Future testPOST() async {
int count = 0;
void sendRequest() {
var request =
- SyncHttpClient.postUrl(new Uri.http("127.0.0.1:$port", "/echo"));
+ SyncHttpClient.postUrl(new Uri.http("localhost:$port", "/echo"));
request.write(data);
var response = request.close();
expect(HttpStatus.OK, equals(response.statusCode));
@@ -273,7 +275,7 @@ Future test404() async {
TestServerMain testServerMain = new TestServerMain();
testServerMain.setServerStartedHandler((int port) {
var request = SyncHttpClient
- .getUrl(new Uri.http("127.0.0.1:$port", "/thisisnotfound"));
+ .getUrl(new Uri.http("localhost:$port", "/thisisnotfound"));
var response = request.close();
expect(HttpStatus.NOT_FOUND, equals(response.statusCode));
expect("Page not found", equals(response.body));
@@ -289,7 +291,7 @@ Future testReasonPhrase() async {
TestServerMain testServerMain = new TestServerMain();
testServerMain.setServerStartedHandler((int port) {
var request = SyncHttpClient
- .getUrl(new Uri.http("127.0.0.1:$port", "/reasonformoving"));
+ .getUrl(new Uri.http("localhost:$port", "/reasonformoving"));
var response = request.close();
expect(HttpStatus.MOVED_PERMANENTLY, equals(response.statusCode));
expect(
@@ -306,7 +308,7 @@ Future testHuge() async {
TestServerMain testServerMain = new TestServerMain();
testServerMain.setServerStartedHandler((int port) {
var request =
- SyncHttpClient.getUrl(new Uri.http("127.0.0.1:$port", "/huge"));
+ SyncHttpClient.getUrl(new Uri.http("localhost:$port", "/huge"));
var response = request.close();
String expected =
new List<int>.generate((1 << 20), (i) => (i + 1) % 256).toString();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698