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

Unified Diff: pkg/scheduled_test/lib/scheduled_server.dart

Issue 311253005: Bind to all available loopback addresses in pub. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 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 | « pkg/scheduled_test/CHANGELOG.md ('k') | pkg/scheduled_test/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/scheduled_test/lib/scheduled_server.dart
diff --git a/pkg/scheduled_test/lib/scheduled_server.dart b/pkg/scheduled_test/lib/scheduled_server.dart
index e04817af771efc4ad2baa5719dfa776bb865d19c..2d9aba0ba5f5906eb1a95aa45b6f485062297ca8 100644
--- a/pkg/scheduled_test/lib/scheduled_server.dart
+++ b/pkg/scheduled_test/lib/scheduled_server.dart
@@ -8,6 +8,7 @@ import 'dart:async';
import 'dart:collection';
import 'dart:io';
+import 'package:http_multi_server/http_multi_server.dart';
import 'package:shelf/shelf.dart' as shelf;
import 'package:shelf/shelf_io.dart' as shelf_io;
@@ -39,16 +40,17 @@ class ScheduledServer {
ScheduledServer._(this._server, this.description);
/// Creates a new server listening on an automatically-allocated port on
- /// 127.0.0.1. [description] is used to refer to the server in debugging
- /// messages.
+ /// localhost (both IPv4 and IPv6, if available).
+ ///
+ /// [description] is used to refer to the server in debugging messages.
factory ScheduledServer([String description]) {
var id = _count++;
if (description == null) description = 'scheduled server $id';
var scheduledServer;
scheduledServer = new ScheduledServer._(schedule(() {
- return shelf_io.serve(scheduledServer._handleRequest, "127.0.0.1", 0)
- .then((server) {
+ return HttpMultiServer.loopback(0).then((server) {
+ shelf_io.serveRequests(server, scheduledServer._handleRequest);
currentSchedule.onComplete.schedule(() => server.close(force: true));
return server;
});
@@ -60,7 +62,7 @@ class ScheduledServer {
Future<int> get port => _server.then((s) => s.port);
/// The base URL of the server, including its port.
- Future<Uri> get url => port.then((p) => Uri.parse("http://127.0.0.1:$p"));
+ Future<Uri> get url => port.then((p) => Uri.parse("http://localhost:$p"));
/// Schedules [handler] to handle a request to the server with [method] and
/// [path]. The schedule will wait until an HTTP request is received. If that
« no previous file with comments | « pkg/scheduled_test/CHANGELOG.md ('k') | pkg/scheduled_test/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698