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

Side by Side Diff: pkg/oauth2/lib/src/utils.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 unified diff | Download patch | Annotate | Revision Log
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:uri'; 8 import 'dart:uri';
8 import 'dart:isolate'; 9 import 'dart:isolate';
9 import 'dart:crypto'; 10 import 'dart:crypto';
10 11
11 /// Adds additional query parameters to [url], overwriting the original 12 /// Adds additional query parameters to [url], overwriting the original
12 /// parameters if a name conflict occurs. 13 /// parameters if a name conflict occurs.
13 Uri addQueryParameters(Uri url, Map<String, String> parameters) { 14 Uri addQueryParameters(Uri url, Map<String, String> parameters) {
14 var queryMap = queryToMap(url.query); 15 var queryMap = queryToMap(url.query);
15 mapAddAll(queryMap, parameters); 16 mapAddAll(queryMap, parameters);
16 return url.resolve("?${mapToQuery(queryMap)}"); 17 return url.resolve("?${mapToQuery(queryMap)}");
(...skipping 14 matching lines...) Expand all
31 } 32 }
32 33
33 /// Convert a [Map] from parameter names to values to a URL query string. 34 /// Convert a [Map] from parameter names to values to a URL query string.
34 String mapToQuery(Map<String, String> map) { 35 String mapToQuery(Map<String, String> map) {
35 var pairs = <List<String>>[]; 36 var pairs = <List<String>>[];
36 map.forEach((key, value) { 37 map.forEach((key, value) {
37 key = encodeUriComponent(key); 38 key = encodeUriComponent(key);
38 value = (value == null || value.isEmpty) ? null : encodeUriComponent(value); 39 value = (value == null || value.isEmpty) ? null : encodeUriComponent(value);
39 pairs.add([key, value]); 40 pairs.add([key, value]);
40 }); 41 });
41 return Strings.join(pairs.map((pair) { 42 return Strings.join(pairs.mappedBy((pair) {
42 if (pair[1] == null) return pair[0]; 43 if (pair[1] == null) return pair[0];
43 return "${pair[0]}=${pair[1]}"; 44 return "${pair[0]}=${pair[1]}";
44 }), "&"); 45 }), "&");
45 } 46 }
46 47
47 /// Add all key/value pairs from [source] to [destination], overwriting any 48 /// Add all key/value pairs from [source] to [destination], overwriting any
48 /// pre-existing values. 49 /// pre-existing values.
49 void mapAddAll(Map destination, Map source) => 50 void mapAddAll(Map destination, Map source) =>
50 source.forEach((key, value) => destination[key] = value); 51 source.forEach((key, value) => destination[key] = value);
51 52
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 106
106 if (!paramString.trim().isEmpty) { 107 if (!paramString.trim().isEmpty) {
107 throw new FormatException('Invalid WWW-Authenticate header: "$header"'); 108 throw new FormatException('Invalid WWW-Authenticate header: "$header"');
108 } 109 }
109 110
110 return new AuthenticateHeader(scheme, parameters); 111 return new AuthenticateHeader(scheme, parameters);
111 } 112 }
112 } 113 }
113 114
114 /// Returns a [Future] that asynchronously completes to `null`. 115 /// Returns a [Future] that asynchronously completes to `null`.
115 Future get async { 116 Future get async => new Future.delayed(0, () => null);
116 var completer = new Completer();
117 new Timer(0, (_) => completer.complete(null));
118 return completer.future;
119 }
OLDNEW
« no previous file with comments | « pkg/oauth2/lib/src/handle_access_token_response.dart ('k') | pkg/oauth2/test/authorization_code_grant_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698