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

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

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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
« no previous file with comments | « pkg/http/lib/src/client.dart ('k') | pkg/http/lib/src/mock_client.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 e3f141352a7b7f46788e5a12f8ec253416a6f2f7..d5b40cba517ace3c10b1c6ca0d1b4ee450abdcc5 100644
--- a/pkg/http/lib/src/io_client.dart
+++ b/pkg/http/lib/src/io_client.dart
@@ -4,6 +4,7 @@
library io_client;
+import 'dart:async';
import 'dart:io';
import 'base_client.dart';
@@ -25,6 +26,7 @@ class IOClient extends BaseClient {
var completer = new Completer<StreamedResponse>();
var connection = _inner.openUrl(request.method, request.url);
+ bool completed = false;
connection.followRedirects = request.followRedirects;
connection.maxRedirects = request.maxRedirects;
connection.onError = (e) {
@@ -33,9 +35,10 @@ class IOClient extends BaseClient {
// 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.
- if (completer.future.isComplete) throw e;
+ if (completed) throw e;
- completer.completeException(e);
+ completed = true;
+ completer.completeError(e);
});
};
@@ -57,6 +60,9 @@ class IOClient extends BaseClient {
var headers = <String>{};
response.headers.forEach((key, value) => headers[key] = value);
+ if (completed) return;
+
+ completed = true;
completer.complete(new StreamedResponse(
response.inputStream,
response.statusCode,
« no previous file with comments | « pkg/http/lib/src/client.dart ('k') | pkg/http/lib/src/mock_client.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698