| Index: pkg/http/lib/src/utils.dart
|
| diff --git a/pkg/http/lib/src/utils.dart b/pkg/http/lib/src/utils.dart
|
| index 65c47997b1e6991c5cf460fe4ae8659432901262..b626b1aa203c2cf381c0e36b8e06b5a345a86bf9 100644
|
| --- a/pkg/http/lib/src/utils.dart
|
| +++ b/pkg/http/lib/src/utils.dart
|
| @@ -78,30 +78,20 @@ List<String> split1(String toSplit, String pattern) {
|
| Encoding encodingForCharset(
|
| String charset, [Encoding fallback = Encoding.ISO_8859_1]) {
|
| if (charset == null) return fallback;
|
| - var encoding = _encodingForCharset(charset);
|
| + var encoding = Encoding.fromName(charset);
|
| return encoding == null ? fallback : encoding;
|
| }
|
|
|
| +
|
| /// Returns the [Encoding] that corresponds to [charset]. Throws a
|
| /// [FormatException] if no [Encoding] was found that corresponds to [charset].
|
| /// [charset] may not be null.
|
| Encoding requiredEncodingForCharset(String charset) {
|
| - var encoding = _encodingForCharset(charset);
|
| + var encoding = Encoding.fromName(charset);
|
| if (encoding != null) return encoding;
|
| throw new FormatException('Unsupported encoding "$charset".');
|
| }
|
|
|
| -/// Returns the [Encoding] that corresponds to [charset]. Returns null if no
|
| -/// [Encoding] was found that corresponds to [charset]. [charset] may not be
|
| -/// null.
|
| -Encoding _encodingForCharset(String charset) {
|
| - charset = charset.toLowerCase();
|
| - if (charset == 'ascii' || charset == 'us-ascii') return Encoding.ASCII;
|
| - if (charset == 'utf-8') return Encoding.UTF_8;
|
| - if (charset == 'iso-8859-1') return Encoding.ISO_8859_1;
|
| - return null;
|
| -}
|
| -
|
| /// Converts [bytes] into a [String] according to [encoding].
|
| String decodeString(List<int> bytes, Encoding encoding) {
|
| // TODO(nweiz): implement this once issue 6284 is fixed.
|
|
|