Index: pkg/http/lib/src/utils.dart |
diff --git a/pkg/http/lib/src/utils.dart b/pkg/http/lib/src/utils.dart |
index c61733ef0c6f1b342ffa7eca0410443c1a8d056e..a70e9370058b744f7efc11c221b19d7cd6f7e161 100644 |
--- a/pkg/http/lib/src/utils.dart |
+++ b/pkg/http/lib/src/utils.dart |
@@ -309,3 +309,16 @@ Future forEachFuture(Iterable input, Future fn(element)) { |
} |
return nextElement(null); |
} |
+ |
+// TODO(nweiz): remove this when issue 8310 is fixed. |
+/// Returns a [Stream] identical to [stream], but piped through a new |
+/// [StreamController]. This exists to work around issue 8310. |
+Stream wrapStream(Stream stream) { |
+ var controller = stream.isBroadcast |
+ ? new StreamController.broadcast() |
+ : new StreamController(); |
+ stream.listen(controller.add, |
+ onError: (e) => controller.signalError(e), |
+ onDone: controller.close); |
+ return controller.stream; |
+} |