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

Unified Diff: sdk/lib/io/io_stream_consumer.dart

Issue 12317147: Implement addStream for HttpClientRequest/HttpResponse and propegate all write-errors from the sock… (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
Index: sdk/lib/io/io_stream_consumer.dart
diff --git a/sdk/lib/io/io_stream_consumer.dart b/sdk/lib/io/io_stream_consumer.dart
index b2c76ac37445527395fa11c00325be424d1bdecb..4134454ed8f81448f901f4f30c82b0c1efa459de 100644
--- a/sdk/lib/io/io_stream_consumer.dart
+++ b/sdk/lib/io/io_stream_consumer.dart
@@ -139,15 +139,22 @@ class IOSink<T> implements StreamConsumer<List<int>, T> {
if (unbind) {
unbindCompleter = new Completer<T>();
}
+ completeUnbind([error]) {
+ if (unbindCompleter == null) return;
+ var tmp = unbindCompleter;
+ unbindCompleter = null;
+ if (error == null) {
+ _bindSubscription = null;
+ tmp.complete();
+ } else {
+ tmp.completeError(error);
+ }
+ }
_bindSubscription = stream.listen(
_controller.add,
onDone: () {
- _bindSubscription = null;
if (unbind) {
- if (unbindCompleter != null) {
- unbindCompleter.complete(null);
- unbindCompleter = null;
- }
+ completeUnbind();
} else {
_controller.close();
}
@@ -155,12 +162,9 @@ class IOSink<T> implements StreamConsumer<List<int>, T> {
onError: _controller.signalError);
if (_paused) _pause();
if (unbind) {
- _pipeFuture.catchError((error) {
- if (unbindCompleter != null) {
- unbindCompleter.completeError(error);
- unbindCompleter = null;
- }
- });
+ _pipeFuture
+ .then((_) => completeUnbind(),
+ onError: (error) => completeUnbind(error));
return unbindCompleter.future;
} else {
return _pipeFuture;

Powered by Google App Engine
This is Rietveld 408576698