Index: sdk/lib/_internal/pub/lib/src/io.dart |
diff --git a/sdk/lib/_internal/pub/lib/src/io.dart b/sdk/lib/_internal/pub/lib/src/io.dart |
index 6e119735a0b55f2e6b48199d49f36c0d8e88cce5..5ae64c2489f7144a13fd7770deca42c64ab16c70 100644 |
--- a/sdk/lib/_internal/pub/lib/src/io.dart |
+++ b/sdk/lib/_internal/pub/lib/src/io.dart |
@@ -12,6 +12,7 @@ import 'dart:io'; |
import 'package:path/path.dart' as path; |
import 'package:http/http.dart' show ByteStream; |
+import 'package:http_multi_server/http_multi_server.dart'; |
import 'package:stack_trace/stack_trace.dart'; |
import 'exit_codes.dart' as exit_codes; |
@@ -686,6 +687,15 @@ Future withTempDir(Future fn(String path)) { |
}); |
} |
+/// Binds an [HttpServer] to [host] and [port]. |
+/// |
+/// If [host] is "localhost", this will automatically listen on both the IPv4 |
+/// and IPv6 loopback addresses. |
+Future<HttpServer> bindServer(String host, int port) { |
+ if (host == 'localhost') return HttpMultiServer.loopback(port); |
+ return HttpServer.bind(host, port); |
+} |
+ |
/// Extracts a `.tar.gz` file from [stream] to [destination]. Returns whether |
/// or not the extraction was successful. |
Future<bool> extractTarGz(Stream<List<int>> stream, String destination) { |