Merge pull request #39 from tvolkert/uint8list

Prepare for upcoming change to File.openRead()
This commit is contained in:
Tobe Osakwe 2019-07-08 20:16:57 -04:00 committed by GitHub
commit 1be896288c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View file

@ -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<List<int>> stream;
Stream<Uint8List> 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<List<int>>().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<List<int>>()
.transform(transformer)
.pipe(res);
return false;
}
}

View file

@ -4,7 +4,7 @@ environment:
sdk: ">=2.0.0 <3.0.0"
homepage: https://github.com/angel-dart/static
author: Tobe O <thosakwe@gmail.com>
version: 2.1.3+1
version: 2.1.3+2
dependencies:
angel_framework: ^2.0.0-rc.0
convert: ^2.0.0