Send content length as a header for files
This commit is contained in:
@@ -12,7 +12,10 @@ public class HttpFileUtil(HttpServerHelper httpServerHelper)
|
||||
var pathSlice = filePath.Split("/");
|
||||
var mimePath = httpServerHelper.GetMimeText(pathSlice[^1].Split(".")[^1]);
|
||||
var type = string.IsNullOrWhiteSpace(mimePath) ? httpServerHelper.GetMimeText("txt") : mimePath;
|
||||
var fileInfo = new FileInfo(filePath);
|
||||
resp.Headers.Append("Content-Type", type);
|
||||
resp.Headers.Append("Content-Length", fileInfo.Length.ToString());
|
||||
|
||||
await resp.SendFileAsync(filePath, CancellationToken.None);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user