Serve plain text files (e.g. logs) as UTF-8.

pull/1386/head
Martin Häger 1 year ago committed by Qstick
parent d4f22f3596
commit e8dc5b3206

@ -1,7 +1,9 @@
using System;
using System.IO;
using System.Text;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.StaticFiles;
using Microsoft.Net.Http.Headers;
using NLog;
using NzbDrone.Common.Disk;
using NzbDrone.Common.EnvironmentInfo;
@ -39,7 +41,10 @@ namespace Prowlarr.Http.Frontend.Mappers
contentType = "application/octet-stream";
}
return new FileStreamResult(GetContentStream(filePath), contentType);
return new FileStreamResult(GetContentStream(filePath), new MediaTypeHeaderValue(contentType)
{
Encoding = contentType == "text/plain" ? Encoding.UTF8 : null
});
}
_logger.Warn("File {0} not found", filePath);

Loading…
Cancel
Save