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

Unified Diff: pkg/http/lib/src/utils.dart

Issue 102973002: Stop working around issue 12780 in pkg/http. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/http/lib/src/utils.dart
diff --git a/pkg/http/lib/src/utils.dart b/pkg/http/lib/src/utils.dart
index 838395984a690af559bddb3d95b506839e6762a3..6a801e194097fd05441b96ba35804b5b1c8a42de 100644
--- a/pkg/http/lib/src/utils.dart
+++ b/pkg/http/lib/src/utils.dart
@@ -36,32 +36,11 @@ Map<String, String> queryToMap(String queryList, {Encoding encoding}) {
String mapToQuery(Map<String, String> map, {Encoding encoding}) {
var pairs = <List<String>>[];
map.forEach((key, value) =>
- pairs.add([urlEncode(key, encoding: encoding),
- urlEncode(value, encoding: encoding)]));
+ pairs.add([Uri.encodeQueryComponent(key, encoding: encoding),
+ Uri.encodeQueryComponent(value, encoding: encoding)]));
return pairs.map((pair) => "${pair[0]}=${pair[1]}").join("&");
}
-// TODO(nweiz): get rid of this when issue 12780 is fixed.
-/// URL-encodes [source] using [encoding].
-String urlEncode(String source, {Encoding encoding}) {
- if (encoding == null) encoding = UTF8;
- return encoding.encode(source).map((byte) {
- // Convert spaces to +, like encodeQueryComponent.
- if (byte == 0x20) return '+';
- // Pass through digits.
- if ((byte >= 0x30 && byte < 0x3A) ||
- // Pass through uppercase letters.
- (byte >= 0x41 && byte < 0x5B) ||
- // Pass through lowercase letters.
- (byte >= 0x61 && byte < 0x7B) ||
- // Pass through `-._~`.
- (byte == 0x2D || byte == 0x2E || byte == 0x5F || byte == 0x7E)) {
- return new String.fromCharCode(byte);
- }
- return '%' + byte.toRadixString(16).toUpperCase();
- }).join();
-}
-
/// Like [String.split], but only splits on the first occurrence of the pattern.
/// This will always return an array of two elements or fewer.
///
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698