Fix client supported image formats (#9071)

pull/8783/head
Teo Baranga 1 year ago committed by GitHub
parent 663854bc1e
commit 56ef45ebf0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -28,7 +28,6 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Primitives;
using Microsoft.Net.Http.Headers;
namespace Jellyfin.Api.Controllers
@ -2038,13 +2037,8 @@ namespace Jellyfin.Api.Controllers
}
var acceptParam = Request.Query[HeaderNames.Accept];
if (StringValues.IsNullOrEmpty(acceptParam))
{
return Array.Empty<ImageFormat>();
}
// Can't be null, checked above
var supportsWebP = SupportsFormat(supportedFormats, acceptParam!, ImageFormat.Webp, false);
var supportsWebP = SupportsFormat(supportedFormats, acceptParam, ImageFormat.Webp, false);
if (!supportsWebP)
{
@ -2066,8 +2060,7 @@ namespace Jellyfin.Api.Controllers
formats.Add(ImageFormat.Jpg);
formats.Add(ImageFormat.Png);
// Can't be null, checked above
if (SupportsFormat(supportedFormats, acceptParam!, ImageFormat.Gif, true))
if (SupportsFormat(supportedFormats, acceptParam, ImageFormat.Gif, true))
{
formats.Add(ImageFormat.Gif);
}
@ -2075,7 +2068,7 @@ namespace Jellyfin.Api.Controllers
return formats.ToArray();
}
private bool SupportsFormat(IReadOnlyCollection<string> requestAcceptTypes, string acceptParam, ImageFormat format, bool acceptAll)
private bool SupportsFormat(IReadOnlyCollection<string> requestAcceptTypes, string? acceptParam, ImageFormat format, bool acceptAll)
{
if (requestAcceptTypes.Contains(format.GetMimeType()))
{

Loading…
Cancel
Save