| Index: lib/src/io/io.dart
|
| diff --git a/lib/src/io.dart b/lib/src/io/io.dart
|
| similarity index 89%
|
| rename from lib/src/io.dart
|
| rename to lib/src/io/io.dart
|
| index ff8761b7bbb788e1c166e8e8ab1b17ad91c8bbb7..b24244d004686ea7eee694336ed5226a18070097 100644
|
| --- a/lib/src/io.dart
|
| +++ b/lib/src/io/io.dart
|
| @@ -1,14 +1,13 @@
|
| -// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
|
| +// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
|
| // for details. All rights reserved. Use of this source code is governed by a
|
| // BSD-style license that can be found in the LICENSE file.
|
|
|
| -// dart:io based strategy for loading resources.
|
| -
|
| import "dart:async" show Future, Stream;
|
| import "dart:convert" show Encoding, LATIN1, UTF8;
|
| import "dart:io" show
|
| File, HttpClient, HttpClientResponse, HttpClientRequest, HttpHeaders;
|
| import "dart:typed_data" show Uint8List;
|
| +
|
| import "package:typed_data/typed_buffers.dart" show Uint8Buffer;
|
|
|
| /// Read the bytes of a URI as a stream of bytes.
|
| @@ -18,7 +17,7 @@ Stream<List<int>> readAsStream(Uri uri) async* {
|
| return;
|
| }
|
| if (uri.scheme == "http" || uri.scheme == "https") {
|
| - HttpClientResponse response = await _httpGet(uri);
|
| + HttpClientResponse response = await _httpGetBytes(uri);
|
| yield* response;
|
| return;
|
| }
|
| @@ -35,7 +34,7 @@ Future<List<int>> readAsBytes(Uri uri) async {
|
| return new File.fromUri(uri).readAsBytes();
|
| }
|
| if (uri.scheme == "http" || uri.scheme == "https") {
|
| - HttpClientResponse response = await _httpGet(uri);
|
| + HttpClientResponse response = await _httpGetBytes(uri);
|
| int length = response.contentLength;
|
| if (length < 0) length = 0;
|
| var buffer = new Uint8Buffer(length);
|
| @@ -74,7 +73,7 @@ Future<String> readAsString(Uri uri, Encoding encoding) async {
|
| await for (var bytes in response) {
|
| buffer.addAll(bytes);
|
| }
|
| - var byteList = new Uint8List.view(buffer.buffer, 0, buffer.length);
|
| + var byteList = buffer.buffer.asUint8List(0, buffer.length);
|
| return new String.fromCharCodes(byteList);
|
| }
|
| return response.transform(encoding.decoder).join();
|
| @@ -85,7 +84,7 @@ Future<String> readAsString(Uri uri, Encoding encoding) async {
|
| throw new UnsupportedError("Unsupported scheme: $uri");
|
| }
|
|
|
| -Future<HttpClientResponse> _httpGet(Uri uri) async {
|
| +Future<HttpClientResponse> _httpGetBytes(Uri uri) async {
|
| HttpClientRequest request = await new HttpClient().getUrl(uri);
|
| request.headers.set(HttpHeaders.ACCEPT, "application/octet-stream, */*");
|
| return request.close();
|
|
|