From e3c291d913571b4e97feee98a4f0592877610806 Mon Sep 17 00:00:00 2001 From: Todd Volkert Date: Tue, 25 Jun 2019 12:59:00 -0700 Subject: [PATCH] Prepare for upcoming change to File.openRead() An upcoming change to the Dart SDK will change the signature of `File.openRead()` from returning `Stream>` to returning `Stream`. This forwards-compatible change prepares for that SDK breaking change by casting the Stream to `List` before transforming it. https://github.com/dart-lang/sdk/issues/36900 --- lib/src/virtual_directory.dart | 11 ++++++++--- pubspec.yaml | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/src/virtual_directory.dart b/lib/src/virtual_directory.dart index ff2ed4e5..c36a5659 100644 --- a/lib/src/virtual_directory.dart +++ b/lib/src/virtual_directory.dart @@ -1,4 +1,5 @@ import 'dart:async'; +import 'dart:typed_data'; import 'package:angel_framework/angel_framework.dart'; import 'package:file/file.dart'; import 'package:http_parser/http_parser.dart'; @@ -284,7 +285,7 @@ class VirtualDirectory { statusCode: 416, message: '`Range` header may not be empty.'); } else if (header.items.length == 1) { var item = header.items[0]; - Stream> stream; + Stream stream; int len = 0, total = totalFileSize; if (item.start == -1) { @@ -311,7 +312,7 @@ class VirtualDirectory { res.statusCode = 206; res.headers['content-length'] = len.toString(); res.headers['content-range'] = 'bytes ' + item.toContentRange(total); - await stream.pipe(res); + await stream.cast>().pipe(res); return false; } else { var transformer = RangeHeaderTransformer( @@ -324,7 +325,11 @@ class VirtualDirectory { transformer.computeContentLength(totalFileSize).toString(); res.contentType = MediaType( 'multipart', 'byteranges', {'boundary': transformer.boundary}); - await file.openRead().transform(transformer).pipe(res); + await file + .openRead() + .cast>() + .transform(transformer) + .pipe(res); return false; } } diff --git a/pubspec.yaml b/pubspec.yaml index f18bdd8d..33d4a02e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ environment: sdk: ">=2.0.0 <3.0.0" homepage: https://github.com/angel-dart/static author: Tobe O -version: 2.1.3+1 +version: 2.1.3+2 dependencies: angel_framework: ^2.0.0-rc.0 convert: ^2.0.0