| OLD | NEW |
| 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 import "dart:utf"; | 5 import "dart:utf"; |
| 6 part "../../../sdk/lib/io/input_stream.dart"; | 6 part "../../../sdk/lib/io/input_stream.dart"; |
| 7 part "../../../sdk/lib/io/output_stream.dart"; | 7 part "../../../sdk/lib/io/output_stream.dart"; |
| 8 part "../../../sdk/lib/io/chunked_stream.dart"; | 8 part "../../../sdk/lib/io/chunked_stream.dart"; |
| 9 part "../../../sdk/lib/io/string_stream.dart"; | 9 part "../../../sdk/lib/io/string_stream.dart"; |
| 10 part "../../../sdk/lib/io/stream_util.dart"; | 10 part "../../../sdk/lib/io/stream_util.dart"; |
| 11 part "../../../sdk/lib/io/http.dart"; | 11 part "../../../sdk/lib/io/http.dart"; |
| 12 part "../../../sdk/lib/io/http_impl.dart"; | 12 part "../../../sdk/lib/io/http_impl.dart"; |
| 13 part "../../../sdk/lib/io/http_parser.dart"; | 13 part "../../../sdk/lib/io/http_parser.dart"; |
| 14 part "../../../sdk/lib/io/http_utils.dart"; | 14 part "../../../sdk/lib/io/http_utils.dart"; |
| 15 | 15 |
| 16 void testParseEncodedString() { | 16 void testParseEncodedString() { |
| 17 String encodedString = 'foo+bar%20foobar%25%26'; | 17 String encodedString = 'foo+bar%20foobar%25%26'; |
| 18 Expect.equals(_HttpUtils.decodeUrlEncodedString(encodedString), | 18 Expect.equals(_HttpUtils.decodeUrlEncodedString(encodedString), |
| 19 'foo bar foobar%&'); | 19 'foo bar foobar%&'); |
| 20 encodedString = 'A+%2B+B'; |
| 21 Expect.equals(_HttpUtils.decodeUrlEncodedString(encodedString), |
| 22 'A + B'); |
| 20 } | 23 } |
| 21 | 24 |
| 22 void testParseQueryString() { | 25 void testParseQueryString() { |
| 23 // The query string includes escaped "?"s, "&"s, "%"s and "="s. | 26 // The query string includes escaped "?"s, "&"s, "%"s and "="s. |
| 24 // These should not affect the splitting of the string. | 27 // These should not affect the splitting of the string. |
| 25 String queryString = | 28 String queryString = |
| 26 '%3F=%3D&foo=bar&%26=%25&sqrt2=%E2%88%9A2&name=Franti%C5%A1ek'; | 29 '%3F=%3D&foo=bar&%26=%25&sqrt2=%E2%88%9A2&name=Franti%C5%A1ek'; |
| 27 Map<String, String> map = _HttpUtils.splitQueryString(queryString); | 30 Map<String, String> map = _HttpUtils.splitQueryString(queryString); |
| 28 for (String key in map.keys) { | 31 for (String key in map.keys) { |
| 29 Expect.equals(map[key], { '&' : '%', | 32 Expect.equals(map[key], { '&' : '%', |
| 30 'foo' : 'bar', | 33 'foo' : 'bar', |
| 31 '?' : '=', | 34 '?' : '=', |
| 32 'sqrt2' : '\u221A2', | 35 'sqrt2' : '\u221A2', |
| 33 'name' : 'Franti\u0161ek'}[key]); | 36 'name' : 'Franti\u0161ek'}[key]); |
| 34 } | 37 } |
| 35 Expect.setEquals(map.keys, ['&', '?', 'foo', 'sqrt2', 'name']); | 38 Expect.setEquals(map.keys, ['&', '?', 'foo', 'sqrt2', 'name']); |
| 36 } | 39 } |
| 37 | 40 |
| 38 void main() { | 41 void main() { |
| 39 testParseEncodedString(); | 42 testParseEncodedString(); |
| 40 testParseQueryString(); | 43 testParseQueryString(); |
| 41 } | 44 } |
| OLD | NEW |