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

Unified Diff: utils/pub/io.dart

Issue 11464015: Revert "Stop working around issue 6984." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Base files Created 8 years 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 | « pkg/http/test/utils.dart ('k') | utils/pub/oauth2.dart » ('j') | no next file with comments »
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 94e575e1c38cb0b5d0487a72ecd743bda1a1668d..5f5f70ce4046f7ae14bd554e26743e8359378fe9 100644
--- a/utils/pub/io.dart
+++ b/utils/pub/io.dart
@@ -666,6 +666,31 @@ Future _doProcess(Function fn, String executable, List<String> args, workingDir,
return fn(executable, args, options);
}
+/// Closes [response] while ignoring the body of [request]. Returns a Future
+/// that completes once the response is closed.
+///
+/// Due to issue 6984, it's necessary to drain the request body before closing
+/// the response.
+Future closeHttpResponse(HttpRequest request, HttpResponse response) {
+ // TODO(nweiz): remove this when issue 4061 is fixed.
+ var stackTrace;
+ try {
+ throw "";
+ } catch (_, localStackTrace) {
+ stackTrace = localStackTrace;
+ }
+
+ var completer = new Completer();
+ request.inputStream.onError = (e) =>
+ completer.completeException(e, stackTrace);
+ request.inputStream.onData = request.inputStream.read;
+ request.inputStream.onClosed = () {
+ response.outputStream.close();
+ completer.complete(null);
+ };
+ return completer.future;
+}
+
/**
* Wraps [input] to provide a timeout. If [input] completes before
* [milliseconds] have passed, then the return value completes in the same way.
« no previous file with comments | « pkg/http/test/utils.dart ('k') | utils/pub/oauth2.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698