Chromium Code Reviews| Index: utils/pub/curl_client.dart |
| diff --git a/utils/pub/curl_client.dart b/utils/pub/curl_client.dart |
| index 71b4701eea672a758076e301fb69357e67fc576a..078e30843b85b8a98e3acb98aef28c97c46c7f5f 100644 |
| --- a/utils/pub/curl_client.dart |
| +++ b/utils/pub/curl_client.dart |
| @@ -106,11 +106,10 @@ class CurlClient extends http.BaseClient { |
| /// expected to send a response body (which is not the case for HEAD |
| /// requests). |
| Future _waitForHeaders(Process process, {bool expectBody}) { |
|
nweiz
2012/11/30 01:19:45
If you're still going to call this "waitForHeaders
Bob Nystrom
2012/11/30 01:42:45
Added a comment explaining.
|
| - var exitCompleter = new Completer<int>(); |
| - var exitFuture = exitCompleter.future; |
| + var completer = new Completer(); |
| process.onExit = (exitCode) { |
| if (exitCode == 0) { |
| - exitCompleter.complete(0); |
| + completer.complete(null); |
| return; |
| } |
| @@ -122,7 +121,7 @@ class CurlClient extends http.BaseClient { |
| } else { |
| throw new HttpException(message); |
| } |
| - }), exitCompleter); |
| + }), completer); |
| }; |
| // If there's not going to be a response body (e.g. for HEAD requests), curl |
| @@ -131,40 +130,10 @@ class CurlClient extends http.BaseClient { |
| if (!expectBody) { |
| return Futures.wait([ |
| consumeInputStream(process.stdout), |
| - exitFuture |
| + completer.future |
| ]); |
| } |
| - // TODO(nweiz): remove this when issue 4061 is fixed. |
| - var stackTrace; |
| - try { |
| - throw ""; |
| - } catch (_, localStackTrace) { |
| - stackTrace = localStackTrace; |
| - } |
| - |
| - var completer = new Completer(); |
| - resetCallbacks() { |
| - process.stdout.onData = null; |
| - process.stdout.onError = null; |
| - process.stdout.onClosed = null; |
| - } |
| - process.stdout.onData = () { |
| - // TODO(nweiz): If an error happens after the body data starts being |
| - // received, it should be piped through Response.stream once issue |
| - // 3657 is fixed. |
| - exitFuture.handleException((e) => true); |
| - resetCallbacks(); |
| - completer.complete(null); |
| - }; |
| - process.stdout.onError = (e) { |
| - resetCallbacks(); |
| - completer.completeException(e, stackTrace); |
| - }; |
| - process.stdout.onClosed = () { |
| - resetCallbacks(); |
| - chainToCompleter(exitFuture, completer); |
| - }; |
| return completer.future; |
| } |