partial request working

This commit is contained in:
Alex
2025-01-09 23:11:57 +00:00
parent 589a5644d2
commit fa22bc8019
19 changed files with 766 additions and 36 deletions
+3 -3
View File
@@ -13,12 +13,12 @@ public class HttpFileUtil
_httpServerHelper = httpServerHelper;
}
public Task SendFileAsync(HttpResponse resp,string filePath) {
public void SendFile(HttpResponse resp,string filePath) {
var pathSlice = filePath.Split("/");
var mimePath = _httpServerHelper.GetMimeText(pathSlice[^1].Split(".")[^1]);
var type = string.IsNullOrWhiteSpace(mimePath) ? _httpServerHelper.GetMimeText("txt") : mimePath;
resp.Headers.Add("Content-Type", type);
return resp.SendFileAsync(filePath, CancellationToken.None);
resp.Headers.Append("Content-Type", type);
resp.SendFileAsync(filePath, CancellationToken.None).Wait();
// maybe the above is correct?
// await pipeline(fs.createReadStream(filePath), resp);
}