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

Unified Diff: sdk/lib/io/http_impl.dart

Issue 14070010: Refactor Future constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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
Index: sdk/lib/io/http_impl.dart
diff --git a/sdk/lib/io/http_impl.dart b/sdk/lib/io/http_impl.dart
index cea3e11e9144c54473916a32031e89736f8b2b0d..aef6a139bb7ef2b6042cc38765485cdcd955743c 100644
--- a/sdk/lib/io/http_impl.dart
+++ b/sdk/lib/io/http_impl.dart
@@ -215,7 +215,7 @@ class _HttpClientResponse
if (followLoops != true) {
for (var redirect in redirects) {
if (redirect.location == url) {
- return new Future.immediateError(
+ return new Future.error(
new RedirectLoopException(redirects));
}
}
@@ -275,7 +275,7 @@ class _HttpClientResponse
// Fall through to here to perform normal response handling if
// there is no sensible authorization handling.
- return new Future.immediate(this);
+ return new Future.value(this);
}
List<String> challenge = headers[HttpHeaders.WWW_AUTHENTICATE];
@@ -316,7 +316,7 @@ class _HttpClientResponse
});
}
// No credentials were found and the callback was not set.
- return new Future.immediate(this);
+ return new Future.value(this);
}
}
@@ -774,13 +774,13 @@ class _HttpClientRequest extends _HttpOutboundMessage<HttpClientResponse>
} else {
// End with exception, too many redirects.
future = response.fold(null, (x, y) {})
- .then((_) => new Future.immediateError(
+ .then((_) => new Future.error(
new RedirectLimitExceededException(response.redirects)));
}
} else if (response._shouldAuthenticate) {
future = response._authenticate();
} else {
- future = new Future<HttpClientResponse>.immediate(response);
+ future = new Future<HttpClientResponse>.value(response);
}
future.then(
(v) => _responseCompleter.complete(v),
@@ -1188,7 +1188,7 @@ class _HttpClient implements HttpClient {
try {
proxyConf = new _ProxyConfiguration(_findProxy(uri));
} catch (error, stackTrace) {
- return new Future.immediateError(error, stackTrace);
+ return new Future.error(error, stackTrace);
}
}
return _getConnection(uri.domain, port, proxyConf, isSecure)
@@ -1254,7 +1254,7 @@ class _HttpClient implements HttpClient {
Iterator<_Proxy> proxies = proxyConf.proxies.iterator;
Future<_ConnnectionInfo> connect(error) {
- if (!proxies.moveNext()) return new Future.immediateError(error);
+ if (!proxies.moveNext()) return new Future.error(error);
_Proxy proxy = proxies.current;
String host = proxy.isDirect ? uriHost: proxy.host;
int port = proxy.isDirect ? uriPort: proxy.port;
@@ -1266,7 +1266,7 @@ class _HttpClient implements HttpClient {
_idleConnections.remove(key);
}
_activeConnections.add(connection);
- return new Future.immediate(new _ConnnectionInfo(connection, proxy));
+ return new Future.value(new _ConnnectionInfo(connection, proxy));
}
return (isSecure && proxy.isDirect
? SecureSocket.connect(host,

Powered by Google App Engine
This is Rietveld 408576698