Serve assets with correct content-type header value (#94357)
This commit is contained in:
@@ -539,7 +539,21 @@ void main() {
|
||||
expect((await response.read().toList()).first, source.readAsBytesSync());
|
||||
}));
|
||||
|
||||
test('serves asset files files from in filesystem with unknown mime type and length > 12', () => testbed.run(() async {
|
||||
test('serves asset files from in filesystem with known mime type and empty content', () => testbed.run(() async {
|
||||
final File source = globals.fs.file(globals.fs.path.join('web', 'foo.js'))
|
||||
..createSync(recursive: true);
|
||||
|
||||
final Response response = await webAssetServer
|
||||
.handleRequest(Request('GET', Uri.parse('http://foobar/foo.js')));
|
||||
|
||||
expect(response.headers, allOf(<Matcher>[
|
||||
containsPair(HttpHeaders.contentLengthHeader, '0'),
|
||||
containsPair(HttpHeaders.contentTypeHeader, 'application/javascript'),
|
||||
]));
|
||||
expect((await response.read().toList()).first, source.readAsBytesSync());
|
||||
}));
|
||||
|
||||
test('serves asset files files from in filesystem with unknown mime type', () => testbed.run(() async {
|
||||
final File source = globals.fs.file(globals.fs.path.join('build', 'flutter_assets', 'foo'))
|
||||
..createSync(recursive: true)
|
||||
..writeAsBytesSync(List<int>.filled(100, 0));
|
||||
@@ -554,21 +568,6 @@ void main() {
|
||||
expect((await response.read().toList()).first, source.readAsBytesSync());
|
||||
}));
|
||||
|
||||
test('serves asset files files from in filesystem with unknown mime type and length < 12', () => testbed.run(() async {
|
||||
final File source = globals.fs.file(globals.fs.path.join('build', 'flutter_assets', 'foo'))
|
||||
..createSync(recursive: true)
|
||||
..writeAsBytesSync(<int>[1, 2, 3]);
|
||||
|
||||
final Response response = await webAssetServer
|
||||
.handleRequest(Request('GET', Uri.parse('http://foobar/assets/foo')));
|
||||
|
||||
expect(response.headers, allOf(<Matcher>[
|
||||
containsPair(HttpHeaders.contentLengthHeader, '3'),
|
||||
containsPair(HttpHeaders.contentTypeHeader, 'application/octet-stream'),
|
||||
]));
|
||||
expect((await response.read().toList()).first, source.readAsBytesSync());
|
||||
}));
|
||||
|
||||
test('serves valid etag header for asset files with non-ascii characters', () => testbed.run(() async {
|
||||
globals.fs.file(globals.fs.path.join('build', 'flutter_assets', 'fooπ'))
|
||||
..createSync(recursive: true)
|
||||
@@ -594,7 +593,7 @@ void main() {
|
||||
|
||||
expect(response.headers, allOf(<Matcher>[
|
||||
containsPair(HttpHeaders.contentLengthHeader, '3'),
|
||||
containsPair(HttpHeaders.contentTypeHeader, 'application/octet-stream'),
|
||||
containsPair(HttpHeaders.contentTypeHeader, 'text/x-dart'),
|
||||
]));
|
||||
expect((await response.read().toList()).first, source.readAsBytesSync());
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user