Index: tools/gardening/lib/src/util.dart |
diff --git a/tools/gardening/lib/src/util.dart b/tools/gardening/lib/src/util.dart |
index b27614e8a96e9b9b2e4cf526deebb32e02b2f35d..278d4e3c29db43e3ba67ceb562614b2e77a1c319 100644 |
--- a/tools/gardening/lib/src/util.dart |
+++ b/tools/gardening/lib/src/util.dart |
@@ -2,6 +2,10 @@ |
// for details. All rights reserved. Use of this source code is governed by a |
// BSD-style license that can be found in the LICENSE file. |
+import 'dart:async'; |
+import 'dart:convert'; |
+import 'dart:io'; |
+ |
/// Split [text] using [infixes] as infix markers. |
List<String> split(String text, List<String> infixes) { |
List<String> result = <String>[]; |
@@ -28,3 +32,10 @@ const bool LOG = const bool.fromEnvironment('LOG', defaultValue: false); |
void log(String text) { |
if (LOG) print(text); |
} |
+ |
+/// Reads the content of [uri] as text. |
+Future<String> readUriAsText(HttpClient client, Uri uri) async { |
+ HttpClientRequest request = await client.getUrl(uri); |
+ HttpClientResponse response = await request.close(); |
+ return await response.transform(UTF8.decoder).join(); |
+} |