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

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

Issue 13548002: Add Iterable.fold (and Stream.fold) which replace `reduce`. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 c1272d3e12a7bb28d34e22eef687cb07e2ed1b25..9123dfdce814cf9a0ef04b138575063c586772ec 100644
--- a/sdk/lib/io/http_impl.dart
+++ b/sdk/lib/io/http_impl.dart
@@ -260,7 +260,7 @@ class _HttpClientResponse
// TODO(sgjesse): Support digest.
if (cr.scheme == _AuthenticationScheme.BASIC) {
// Drain body and retry.
- return reduce(null, (x, y) {}).then((_) {
+ return fold(null, (x, y) {}).then((_) {
return _httpClient._openUrlFromRequest(_httpRequest.method,
_httpRequest.uri,
_httpRequest)
@@ -452,7 +452,7 @@ abstract class _HttpOutboundMessage<T> implements IOSink {
int contentLength = headers.contentLength;
if (_ignoreBody) {
ioSink.close();
- return stream.reduce(null, (x, y) {}).then((_) => this);
+ return stream.fold(null, (x, y) {}).then((_) => this);
}
stream = stream.transform(new _BufferTransformer());
if (headers.chunkedTransferEncoding) {
@@ -727,11 +727,11 @@ class _HttpClientRequest extends _HttpOutboundMessage<HttpClientRequest>
if (followRedirects && response.isRedirect) {
if (response.redirects.length < maxRedirects) {
// Redirect and drain response.
- future = response.reduce(null, (x, y) {})
+ future = response.fold(null, (x, y) {})
.then((_) => response.redirect());
} else {
// End with exception, too many redirects.
- future = response.reduce(null, (x, y) {})
+ future = response.fold(null, (x, y) {})
.then((_) => new Future.immediateError(
new RedirectLimitExceededException(response.redirects)));
}
@@ -1089,7 +1089,7 @@ class _HttpClient implements HttpClient {
_closing = true;
// Create flattened copy of _idleConnections, as 'destory' will manipulate
// it.
- var idle = _idleConnections.values.reduce(
+ var idle = _idleConnections.values.fold(
[],
(l, e) {
l.addAll(e);
@@ -1241,7 +1241,7 @@ class _HttpClient implements HttpClient {
_Credentials _findCredentials(Uri url, [_AuthenticationScheme scheme]) {
// Look for credentials.
_Credentials cr =
- _credentials.reduce(null, (_Credentials prev, _Credentials value) {
+ _credentials.fold(null, (_Credentials prev, _Credentials value) {
if (value.applies(url, scheme)) {
if (prev == null) return value;
return value.uri.path.length > prev.uri.path.length ? value : prev;

Powered by Google App Engine
This is Rietveld 408576698