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

Unified Diff: pkg/http/lib/src/base_request.dart

Issue 11434018: Make pkg/http use HttpClient.shutdown(force: true). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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 | pkg/http/lib/src/io_client.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/http/lib/src/base_request.dart
diff --git a/pkg/http/lib/src/base_request.dart b/pkg/http/lib/src/base_request.dart
index ecf5f7a844561eb8a4478f90e80e412134dc50b5..4a8b5ce4eb1700333616f6eca73d3288ed80ec3f 100644
--- a/pkg/http/lib/src/base_request.dart
+++ b/pkg/http/lib/src/base_request.dart
@@ -5,6 +5,7 @@
library base_request;
import 'dart:io';
+import 'dart:isolate';
import 'dart:uri';
import 'client.dart';
@@ -104,9 +105,19 @@ abstract class BaseRequest {
/// requests.
Future<StreamedResponse> send() {
var client = new Client();
- var future = client.send(this);
- future.onComplete((_) => client.close());
- return future;
+ return client.send(this).transform((response) {
+ // TODO(nweiz): This makes me sick to my stomach, but it's currently the
+ // best way to listen for the response stream being closed. Kill it with
+ // fire once issue 4202 is fixed.
+ new Timer.repeating(100, (timer) {
+ if (response.stream.closed) {
+ client.close();
+ timer.cancel();
+ }
+ });
+
+ return response;
+ });
}
/// Throws an error if this request has been finalized.
« no previous file with comments | « no previous file | pkg/http/lib/src/io_client.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698