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

Side by Side Diff: lib/src/io.dart

Issue 1340043004: Use GZIP on pub servers. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Created 5 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (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 /// Helper functionality to make working with IO easier. 5 /// Helper functionality to make working with IO easier.
6 library pub.io; 6 library pub.io;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:collection'; 9 import 'dart:collection';
10 import 'dart:convert'; 10 import 'dart:convert';
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 var tempDir = createSystemTempDir(); 853 var tempDir = createSystemTempDir();
854 return new Future.sync(() => fn(tempDir)) 854 return new Future.sync(() => fn(tempDir))
855 .whenComplete(() => deleteEntry(tempDir)); 855 .whenComplete(() => deleteEntry(tempDir));
856 }); 856 });
857 } 857 }
858 858
859 /// Binds an [HttpServer] to [host] and [port]. 859 /// Binds an [HttpServer] to [host] and [port].
860 /// 860 ///
861 /// If [host] is "localhost", this will automatically listen on both the IPv4 861 /// If [host] is "localhost", this will automatically listen on both the IPv4
862 /// and IPv6 loopback addresses. 862 /// and IPv6 loopback addresses.
863 Future<HttpServer> bindServer(String host, int port) { 863 Future<HttpServer> bindServer(String host, int port) async {
864 if (host == 'localhost') return HttpMultiServer.loopback(port); 864 var server = host == 'localhost'
865 return HttpServer.bind(host, port); 865 ? await HttpMultiServer.loopback(port)
866 : await HttpServer.bind(host, port);
867 server.autoCompress = true;
868 return server;
866 } 869 }
867 870
868 /// Extracts a `.tar.gz` file from [stream] to [destination]. 871 /// Extracts a `.tar.gz` file from [stream] to [destination].
869 Future extractTarGz(Stream<List<int>> stream, String destination) async { 872 Future extractTarGz(Stream<List<int>> stream, String destination) async {
870 log.fine("Extracting .tar.gz stream to $destination."); 873 log.fine("Extracting .tar.gz stream to $destination.");
871 874
872 if (Platform.operatingSystem == "windows") { 875 if (Platform.operatingSystem == "windows") {
873 return await _extractTarGzWindows(stream, destination); 876 return await _extractTarGzWindows(stream, destination);
874 } 877 }
875 878
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 1063
1061 // TODO(rnystrom): Remove this and change to returning one string. 1064 // TODO(rnystrom): Remove this and change to returning one string.
1062 static List<String> _toLines(String output) { 1065 static List<String> _toLines(String output) {
1063 var lines = splitLines(output); 1066 var lines = splitLines(output);
1064 if (!lines.isEmpty && lines.last == "") lines.removeLast(); 1067 if (!lines.isEmpty && lines.last == "") lines.removeLast();
1065 return lines; 1068 return lines;
1066 } 1069 }
1067 1070
1068 bool get success => exitCode == exit_codes.SUCCESS; 1071 bool get success => exitCode == exit_codes.SUCCESS;
1069 } 1072 }
OLDNEW
« 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