octet stream
This commit is contained in:
parent
6df23c7fee
commit
21f031c207
4 changed files with 12 additions and 4 deletions
|
@ -26,7 +26,7 @@ abstract class FileInfo {
|
||||||
factory FileInfo.fromFile(File file) => new _FileInfoImpl(
|
factory FileInfo.fromFile(File file) => new _FileInfoImpl(
|
||||||
() => file.openRead(),
|
() => file.openRead(),
|
||||||
file.absolute.path,
|
file.absolute.path,
|
||||||
lookupMimeType(file.path),
|
lookupMimeType(file.path) ?? 'application/octet-stream',
|
||||||
file.statSync().modified);
|
file.statSync().modified);
|
||||||
|
|
||||||
/// Creates a [FileInfo] describing a file that might not even exists to begin with.
|
/// Creates a [FileInfo] describing a file that might not even exists to begin with.
|
||||||
|
|
|
@ -262,8 +262,8 @@ class VirtualDirectory implements AngelPlugin {
|
||||||
void _ensureContentTypeAllowed(String mimeType, RequestContext req) {
|
void _ensureContentTypeAllowed(String mimeType, RequestContext req) {
|
||||||
var value = req.headers.value(HttpHeaders.ACCEPT);
|
var value = req.headers.value(HttpHeaders.ACCEPT);
|
||||||
bool acceptable = value == null ||
|
bool acceptable = value == null ||
|
||||||
value.isEmpty ||
|
value?.isNotEmpty != true ||
|
||||||
value?.contains(mimeType) == true ||
|
(mimeType?.isNotEmpty == true && value?.contains(mimeType) == true) ||
|
||||||
value?.contains('*/*') == true;
|
value?.contains('*/*') == true;
|
||||||
if (!acceptable)
|
if (!acceptable)
|
||||||
throw new AngelHttpException(
|
throw new AngelHttpException(
|
||||||
|
|
|
@ -4,7 +4,7 @@ environment:
|
||||||
sdk: ">=1.19.0"
|
sdk: ">=1.19.0"
|
||||||
homepage: https://github.com/angel-dart/static
|
homepage: https://github.com/angel-dart/static
|
||||||
author: Tobe O <thosakwe@gmail.com>
|
author: Tobe O <thosakwe@gmail.com>
|
||||||
version: 1.2.2+1
|
version: 1.2.2+3
|
||||||
dependencies:
|
dependencies:
|
||||||
angel_framework: ^1.0.0-dev
|
angel_framework: ^1.0.0-dev
|
||||||
cli_util: ^0.1.1
|
cli_util: ^0.1.1
|
||||||
|
|
|
@ -64,4 +64,12 @@ main() {
|
||||||
var response = await client.get("$url/virtual");
|
var response = await client.get("$url/virtual");
|
||||||
expect(response.body, equals("index!"));
|
expect(response.body, equals("index!"));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('chrome accept', () async {
|
||||||
|
var response = await client.get("$url/virtual", headers: {
|
||||||
|
HttpHeaders.ACCEPT:
|
||||||
|
'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'
|
||||||
|
});
|
||||||
|
expect(response.body, equals("index!"));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue