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

Unified Diff: sdk/lib/_internal/pub/lib/src/io.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 | « sdk/lib/_internal/pub/lib/src/command/build.dart ('k') | sdk/lib/_internal/pub/lib/src/oauth2.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/command/build.dart ('k') | sdk/lib/_internal/pub/lib/src/oauth2.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698