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: utils/pub/io.dart

Issue 12211052: Drain HTTP request input streams before responding. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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 | « no previous file | utils/tests/pub/pub_lish_test.dart » ('j') | utils/tests/pub/pub_lish_test.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/pub/io.dart
diff --git a/utils/pub/io.dart b/utils/pub/io.dart
index 60f6d77f75f299afb905f98554dbfcd218228245..1ab274c3626447853ccefe0cab4382c116263f69 100644
--- a/utils/pub/io.dart
+++ b/utils/pub/io.dart
@@ -425,6 +425,21 @@ Future<bool> confirm(String message) {
.then((line) => new RegExp(r"^[yY]").hasMatch(line));
}
+/// Reads and discards all output from [inputStream]. Returns a [Future] that
+/// completes when the stream is closed.
+Future drainInputStream(InputStream inputStream) {
+ var completer = new Completer();
+ if (inputStream.closed) {
+ completer.complete();
+ return completer.future;
+ }
+
+ inputStream.onClosed = () => completer.complete();
+ inputStream.onData = inputStream.read;
+ inputStream.onError = (error) => completer.completeError(error);
+ return completer.future;
+}
+
/// Wraps [stream] in a single-subscription [Stream] that emits the same data.
ByteStream wrapInputStream(InputStream stream) {
var controller = new StreamController();
« no previous file with comments | « no previous file | utils/tests/pub/pub_lish_test.dart » ('j') | utils/tests/pub/pub_lish_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698