1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-04-20 21:54:58 -04:00

Optionally show mini profiler

This commit is contained in:
Mark McDowall
2025-12-25 18:33:31 -08:00
parent 8fcab2d321
commit c3706c3c92
19 changed files with 137 additions and 25 deletions
@@ -2,6 +2,7 @@ using System;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.StaticFiles;
using Microsoft.Net.Http.Headers;
@@ -31,7 +32,7 @@ namespace Sonarr.Http.Frontend.Mappers
public abstract bool CanHandle(string resourceUrl);
public Task<IActionResult> GetResponse(string resourceUrl)
public Task<IActionResult> GetResponse(HttpContext context, string resourceUrl)
{
var filePath = Map(resourceUrl);
@@ -42,7 +43,7 @@ namespace Sonarr.Http.Frontend.Mappers
contentType = "application/octet-stream";
}
return Task.FromResult<IActionResult>(new FileStreamResult(GetContentStream(filePath), new MediaTypeHeaderValue(contentType)
return Task.FromResult<IActionResult>(new FileStreamResult(GetContentStream(context, filePath), new MediaTypeHeaderValue(contentType)
{
Encoding = contentType == "text/plain" ? Encoding.UTF8 : null
}));
@@ -53,7 +54,7 @@ namespace Sonarr.Http.Frontend.Mappers
return Task.FromResult<IActionResult>(null);
}
protected virtual Stream GetContentStream(string filePath)
protected virtual Stream GetContentStream(HttpContext context, string filePath)
{
return File.OpenRead(filePath);
}