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

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: Address comments. 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
« no previous file with comments | « sdk/lib/html/html_common/filtered_element_list.dart ('k') | sdk/lib/svg/dart2js/svg_dart2js.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/http_impl.dart
diff --git a/sdk/lib/io/http_impl.dart b/sdk/lib/io/http_impl.dart
index 1de89c4c762b9e7fb367ceedd342bfbc60b1defc..ea4e1d7ee41a48222a31e7b0aa14e6bb4563cd28 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)
@@ -460,7 +460,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) {
@@ -735,11 +735,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)));
}
@@ -1097,7 +1097,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);
@@ -1249,7 +1249,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;
« no previous file with comments | « sdk/lib/html/html_common/filtered_element_list.dart ('k') | sdk/lib/svg/dart2js/svg_dart2js.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698