Sync static resource mapper with upstream

This commit is contained in:
Bogdan 2026-03-30 12:36:37 +03:00 committed by retrodadson
parent 9907342055
commit 6fca0d0b6c
3 changed files with 5 additions and 5 deletions

View file

@ -7,6 +7,6 @@ public interface IMapHttpRequestsToDisk
{
string Map(string resourceUrl);
bool CanHandle(string resourceUrl);
Task<FileStreamResult> GetResponse(string resourceUrl);
Task<IActionResult> GetResponse(string resourceUrl);
}
}

View file

@ -31,7 +31,7 @@ protected StaticResourceMapperBase(IDiskProvider diskProvider, Logger logger)
public abstract bool CanHandle(string resourceUrl);
public Task<FileStreamResult> GetResponse(string resourceUrl)
public Task<IActionResult> GetResponse(string resourceUrl)
{
var filePath = Map(resourceUrl);
@ -42,7 +42,7 @@ public Task<FileStreamResult> GetResponse(string resourceUrl)
contentType = "application/octet-stream";
}
return Task.FromResult(new FileStreamResult(GetContentStream(filePath), new MediaTypeHeaderValue(contentType)
return Task.FromResult<IActionResult>(new FileStreamResult(GetContentStream(filePath), new MediaTypeHeaderValue(contentType)
{
Encoding = contentType == "text/plain" ? Encoding.UTF8 : null
}));
@ -50,7 +50,7 @@ public Task<FileStreamResult> GetResponse(string resourceUrl)
_logger.Warn("File {0} not found", filePath);
return Task.FromResult<FileStreamResult>(null);
return Task.FromResult<IActionResult>(null);
}
protected virtual Stream GetContentStream(string filePath)

View file

@ -58,7 +58,7 @@ private async Task<IActionResult> MapResource(string path)
if (result != null)
{
if (result.ContentType == "text/html")
if ((result as FileResult)?.ContentType == "text/html")
{
Response.Headers.DisableCache();
}