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

Unified Diff: pkg/http/lib/src/io_client.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 | « pkg/http/lib/src/base_request.dart ('k') | pkg/http/lib/src/utils.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/http/lib/src/io_client.dart
diff --git a/pkg/http/lib/src/io_client.dart b/pkg/http/lib/src/io_client.dart
index 48416cea5b809ae3de94d6946be5d0cc65536e85..ce5722490397f72b679f418ef0a10a96caf0d12b 100644
--- a/pkg/http/lib/src/io_client.dart
+++ b/pkg/http/lib/src/io_client.dart
@@ -29,8 +29,22 @@ class IOClient extends BaseClient {
connection.maxRedirects = request.maxRedirects;
connection.onError = (e) {
async.then((_) {
- // TODO(nweiz): remove this when issue 4974 is fixed
- if (completer.future.isComplete) throw e;
+ if (completer.future.isComplete) {
+ // TODO(nweiz): issue 7014 means that connection errors may be routed
+ // here even after onResponse has been called. Since these errors are
+ // also routed to the response input stream, we want to silently
+ // ignore them.
+ //
+ // We test if they're HTTP exceptions to distinguish them from errors
+ // caused by issue 4974 (see below).
+ if (e is HttpException) return;
+
+ // TODO(nweiz): issue 4974 means that any errors that appear in the
+ // onRequest or onResponse callbacks get passed to onError. If the
+ // completer has already fired, we want to re-throw those exceptions
+ // to the top level so that they aren't silently ignored.
+ throw e;
+ }
completer.completeException(e);
});
@@ -55,7 +69,7 @@ class IOClient extends BaseClient {
response.headers.forEach((key, value) => headers[key] = value);
completer.complete(new StreamedResponse(
- response.inputStream,
+ wrapInputStream(response.inputStream),
response.statusCode,
response.contentLength,
headers: headers,
@@ -70,7 +84,7 @@ class IOClient extends BaseClient {
/// Closes the client. This terminates all active connections. If a client
/// remains unclosed, the Dart process may not terminate.
void close() {
- if (_inner != null) _inner.shutdown();
+ if (_inner != null) _inner.shutdown(force: true);
_inner = null;
}
}
« no previous file with comments | « pkg/http/lib/src/base_request.dart ('k') | pkg/http/lib/src/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698