Serve assets with correct content-type header value (#94357)
This commit is contained in:
@@ -455,14 +455,11 @@ class WebAssetServer implements AssetReader {
|
||||
// Attempt to determine the file's mime type. if this is not provided some
|
||||
// browsers will refuse to render images/show video etc. If the tool
|
||||
// cannot determine a mime type, fall back to application/octet-stream.
|
||||
String mimeType;
|
||||
if (length >= 12) {
|
||||
mimeType = mime.lookupMimeType(
|
||||
final String mimeType = mime.lookupMimeType(
|
||||
file.path,
|
||||
headerBytes: await file.openRead(0, 12).first,
|
||||
);
|
||||
}
|
||||
mimeType ??= _kDefaultMimeType;
|
||||
headerBytes: await file.openRead(0, mime.defaultMagicNumbersMaxLength).first,
|
||||
) ?? _kDefaultMimeType;
|
||||
|
||||
headers[HttpHeaders.contentLengthHeader] = length.toString();
|
||||
headers[HttpHeaders.contentTypeHeader] = mimeType;
|
||||
headers[HttpHeaders.etagHeader] = etag;
|
||||
|
||||
Reference in New Issue
Block a user