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

Side by Side Diff: pkg/http/lib/src/utils.dart

Issue 12045024: Fix map literals from change 17410 (Closed) Base URL: http://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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/http/lib/src/streamed_response.dart ('k') | pkg/http/test/utils.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library utils; 5 library utils;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:crypto'; 8 import 'dart:crypto';
9 import 'dart:io'; 9 import 'dart:io';
10 import 'dart:scalarlist'; 10 import 'dart:scalarlist';
11 import 'dart:uri'; 11 import 'dart:uri';
12 import 'dart:utf'; 12 import 'dart:utf';
13 13
14 import 'byte_stream.dart'; 14 import 'byte_stream.dart';
15 15
16 /// Converts a URL query string (or `application/x-www-form-urlencoded` body) 16 /// Converts a URL query string (or `application/x-www-form-urlencoded` body)
17 /// into a [Map] from parameter names to values. 17 /// into a [Map] from parameter names to values.
18 /// 18 ///
19 /// queryToMap("foo=bar&baz=bang&qux"); 19 /// queryToMap("foo=bar&baz=bang&qux");
20 /// //=> {"foo": "bar", "baz": "bang", "qux": ""} 20 /// //=> {"foo": "bar", "baz": "bang", "qux": ""}
21 Map<String, String> queryToMap(String queryList) { 21 Map<String, String> queryToMap(String queryList) {
22 var map = <String, String>{}; 22 var map = {};
23 for (var pair in queryList.split("&")) { 23 for (var pair in queryList.split("&")) {
24 var split = split1(pair, "="); 24 var split = split1(pair, "=");
25 if (split.isEmpty) continue; 25 if (split.isEmpty) continue;
26 var key = urlDecode(split[0]); 26 var key = urlDecode(split[0]);
27 var value = urlDecode(split.length > 1 ? split[1] : ""); 27 var value = urlDecode(split.length > 1 ? split[1] : "");
28 map[key] = value; 28 map[key] = value;
29 } 29 }
30 return map; 30 return map;
31 } 31 }
32 32
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 /// The return values of all [Future]s are discarded. Any errors will cause the 302 /// The return values of all [Future]s are discarded. Any errors will cause the
303 /// iteration to stop and will be piped through the return value. 303 /// iteration to stop and will be piped through the return value.
304 Future forEachFuture(Iterable input, Future fn(element)) { 304 Future forEachFuture(Iterable input, Future fn(element)) {
305 var iterator = input.iterator; 305 var iterator = input.iterator;
306 Future nextElement(_) { 306 Future nextElement(_) {
307 if (!iterator.moveNext()) return new Future.immediate(null); 307 if (!iterator.moveNext()) return new Future.immediate(null);
308 return fn(iterator.current).then(nextElement); 308 return fn(iterator.current).then(nextElement);
309 } 309 }
310 return nextElement(null); 310 return nextElement(null);
311 } 311 }
OLDNEW
« no previous file with comments | « pkg/http/lib/src/streamed_response.dart ('k') | pkg/http/test/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698