Remove isHeadRequest from GetStaticFile method signatures

pull/7137/head
SenorSmartyPants 3 years ago
parent bd2bec4d4a
commit 3ea54a8009

@ -1954,7 +1954,7 @@ namespace Jellyfin.Api.Controllers
return Task.CompletedTask; return Task.CompletedTask;
}); });
return FileStreamResponseHelpers.GetStaticFileResult(segmentPath, MimeTypes.GetMimeType(segmentPath), false, HttpContext); return FileStreamResponseHelpers.GetStaticFileResult(segmentPath, MimeTypes.GetMimeType(segmentPath), HttpContext);
} }
private long GetEndPositionTicks(StreamState state, int requestedIndex) private long GetEndPositionTicks(StreamState state, int requestedIndex)

@ -69,7 +69,7 @@ namespace Jellyfin.Api.Controllers
return BadRequest("Invalid segment."); return BadRequest("Invalid segment.");
} }
return FileStreamResponseHelpers.GetStaticFileResult(file, MimeTypes.GetMimeType(file), false, HttpContext); return FileStreamResponseHelpers.GetStaticFileResult(file, MimeTypes.GetMimeType(file), HttpContext);
} }
/// <summary> /// <summary>
@ -186,7 +186,7 @@ namespace Jellyfin.Api.Controllers
return Task.CompletedTask; return Task.CompletedTask;
}); });
return FileStreamResponseHelpers.GetStaticFileResult(path, MimeTypes.GetMimeType(path), false, HttpContext); return FileStreamResponseHelpers.GetStaticFileResult(path, MimeTypes.GetMimeType(path), HttpContext);
} }
} }
} }

@ -559,8 +559,7 @@ namespace Jellyfin.Api.Controllers
blur, blur,
backgroundColor, backgroundColor,
foregroundLayer, foregroundLayer,
item, item)
Request.Method.Equals(HttpMethods.Head, StringComparison.OrdinalIgnoreCase))
.ConfigureAwait(false); .ConfigureAwait(false);
} }
@ -643,8 +642,7 @@ namespace Jellyfin.Api.Controllers
blur, blur,
backgroundColor, backgroundColor,
foregroundLayer, foregroundLayer,
item, item)
Request.Method.Equals(HttpMethods.Head, StringComparison.OrdinalIgnoreCase))
.ConfigureAwait(false); .ConfigureAwait(false);
} }
@ -727,8 +725,7 @@ namespace Jellyfin.Api.Controllers
blur, blur,
backgroundColor, backgroundColor,
foregroundLayer, foregroundLayer,
item, item)
Request.Method.Equals(HttpMethods.Head, StringComparison.OrdinalIgnoreCase))
.ConfigureAwait(false); .ConfigureAwait(false);
} }
@ -811,8 +808,7 @@ namespace Jellyfin.Api.Controllers
blur, blur,
backgroundColor, backgroundColor,
foregroundLayer, foregroundLayer,
item, item)
Request.Method.Equals(HttpMethods.Head, StringComparison.OrdinalIgnoreCase))
.ConfigureAwait(false); .ConfigureAwait(false);
} }
@ -895,8 +891,7 @@ namespace Jellyfin.Api.Controllers
blur, blur,
backgroundColor, backgroundColor,
foregroundLayer, foregroundLayer,
item, item)
Request.Method.Equals(HttpMethods.Head, StringComparison.OrdinalIgnoreCase))
.ConfigureAwait(false); .ConfigureAwait(false);
} }
@ -979,8 +974,7 @@ namespace Jellyfin.Api.Controllers
blur, blur,
backgroundColor, backgroundColor,
foregroundLayer, foregroundLayer,
item, item)
Request.Method.Equals(HttpMethods.Head, StringComparison.OrdinalIgnoreCase))
.ConfigureAwait(false); .ConfigureAwait(false);
} }
@ -1063,8 +1057,7 @@ namespace Jellyfin.Api.Controllers
blur, blur,
backgroundColor, backgroundColor,
foregroundLayer, foregroundLayer,
item, item)
Request.Method.Equals(HttpMethods.Head, StringComparison.OrdinalIgnoreCase))
.ConfigureAwait(false); .ConfigureAwait(false);
} }
@ -1147,8 +1140,7 @@ namespace Jellyfin.Api.Controllers
blur, blur,
backgroundColor, backgroundColor,
foregroundLayer, foregroundLayer,
item, item)
Request.Method.Equals(HttpMethods.Head, StringComparison.OrdinalIgnoreCase))
.ConfigureAwait(false); .ConfigureAwait(false);
} }
@ -1231,8 +1223,7 @@ namespace Jellyfin.Api.Controllers
blur, blur,
backgroundColor, backgroundColor,
foregroundLayer, foregroundLayer,
item, item)
Request.Method.Equals(HttpMethods.Head, StringComparison.OrdinalIgnoreCase))
.ConfigureAwait(false); .ConfigureAwait(false);
} }
@ -1315,8 +1306,7 @@ namespace Jellyfin.Api.Controllers
blur, blur,
backgroundColor, backgroundColor,
foregroundLayer, foregroundLayer,
item, item)
Request.Method.Equals(HttpMethods.Head, StringComparison.OrdinalIgnoreCase))
.ConfigureAwait(false); .ConfigureAwait(false);
} }
@ -1399,8 +1389,7 @@ namespace Jellyfin.Api.Controllers
blur, blur,
backgroundColor, backgroundColor,
foregroundLayer, foregroundLayer,
item, item)
Request.Method.Equals(HttpMethods.Head, StringComparison.OrdinalIgnoreCase))
.ConfigureAwait(false); .ConfigureAwait(false);
} }
@ -1483,8 +1472,7 @@ namespace Jellyfin.Api.Controllers
blur, blur,
backgroundColor, backgroundColor,
foregroundLayer, foregroundLayer,
item, item)
Request.Method.Equals(HttpMethods.Head, StringComparison.OrdinalIgnoreCase))
.ConfigureAwait(false); .ConfigureAwait(false);
} }
@ -1585,7 +1573,6 @@ namespace Jellyfin.Api.Controllers
backgroundColor, backgroundColor,
foregroundLayer, foregroundLayer,
null, null,
Request.Method.Equals(HttpMethods.Head, StringComparison.OrdinalIgnoreCase),
info) info)
.ConfigureAwait(false); .ConfigureAwait(false);
} }
@ -1687,7 +1674,6 @@ namespace Jellyfin.Api.Controllers
backgroundColor, backgroundColor,
foregroundLayer, foregroundLayer,
null, null,
Request.Method.Equals(HttpMethods.Head, StringComparison.OrdinalIgnoreCase),
info) info)
.ConfigureAwait(false); .ConfigureAwait(false);
} }
@ -1772,7 +1758,6 @@ namespace Jellyfin.Api.Controllers
string? backgroundColor, string? backgroundColor,
string? foregroundLayer, string? foregroundLayer,
BaseItem? item, BaseItem? item,
bool isHeadRequest,
ItemImageInfo? imageInfo = null) ItemImageInfo? imageInfo = null)
{ {
if (percentPlayed.HasValue) if (percentPlayed.HasValue)
@ -1843,8 +1828,7 @@ namespace Jellyfin.Api.Controllers
imageInfo, imageInfo,
outputFormats, outputFormats,
cacheDuration, cacheDuration,
responseHeaders, responseHeaders).ConfigureAwait(false);
isHeadRequest).ConfigureAwait(false);
} }
private ImageFormat[] GetOutputFormats(ImageFormat? format) private ImageFormat[] GetOutputFormats(ImageFormat? format)
@ -1941,8 +1925,7 @@ namespace Jellyfin.Api.Controllers
ItemImageInfo imageInfo, ItemImageInfo imageInfo,
IReadOnlyCollection<ImageFormat> supportedFormats, IReadOnlyCollection<ImageFormat> supportedFormats,
TimeSpan? cacheDuration, TimeSpan? cacheDuration,
IDictionary<string, string> headers, IDictionary<string, string> headers)
bool isHeadRequest)
{ {
if (!imageInfo.IsLocalFile && item != null) if (!imageInfo.IsLocalFile && item != null)
{ {

@ -470,7 +470,7 @@ namespace Jellyfin.Api.Controllers
StreamingHelpers.AddDlnaHeaders(state, Response.Headers, true, state.Request.StartTimeTicks, Request, _dlnaManager); StreamingHelpers.AddDlnaHeaders(state, Response.Headers, true, state.Request.StartTimeTicks, Request, _dlnaManager);
var httpClient = _httpClientFactory.CreateClient(NamedClient.Default); var httpClient = _httpClientFactory.CreateClient(NamedClient.Default);
return await FileStreamResponseHelpers.GetStaticRemoteStreamResult(state, isHeadRequest, httpClient, HttpContext).ConfigureAwait(false); return await FileStreamResponseHelpers.GetStaticRemoteStreamResult(state, httpClient, HttpContext).ConfigureAwait(false);
} }
if (@static.HasValue && @static.Value && state.InputProtocol != MediaProtocol.File) if (@static.HasValue && @static.Value && state.InputProtocol != MediaProtocol.File)
@ -500,7 +500,6 @@ namespace Jellyfin.Api.Controllers
return FileStreamResponseHelpers.GetStaticFileResult( return FileStreamResponseHelpers.GetStaticFileResult(
state.MediaPath, state.MediaPath,
contentType, contentType,
isHeadRequest,
HttpContext); HttpContext);
} }

@ -138,7 +138,7 @@ namespace Jellyfin.Api.Helpers
StreamingHelpers.AddDlnaHeaders(state, _httpContextAccessor.HttpContext.Response.Headers, true, streamingRequest.StartTimeTicks, _httpContextAccessor.HttpContext.Request, _dlnaManager); StreamingHelpers.AddDlnaHeaders(state, _httpContextAccessor.HttpContext.Response.Headers, true, streamingRequest.StartTimeTicks, _httpContextAccessor.HttpContext.Request, _dlnaManager);
var httpClient = _httpClientFactory.CreateClient(NamedClient.Default); var httpClient = _httpClientFactory.CreateClient(NamedClient.Default);
return await FileStreamResponseHelpers.GetStaticRemoteStreamResult(state, isHeadRequest, httpClient, _httpContextAccessor.HttpContext).ConfigureAwait(false); return await FileStreamResponseHelpers.GetStaticRemoteStreamResult(state, httpClient, _httpContextAccessor.HttpContext).ConfigureAwait(false);
} }
if (streamingRequest.Static && state.InputProtocol != MediaProtocol.File) if (streamingRequest.Static && state.InputProtocol != MediaProtocol.File)
@ -168,7 +168,6 @@ namespace Jellyfin.Api.Helpers
return FileStreamResponseHelpers.GetStaticFileResult( return FileStreamResponseHelpers.GetStaticFileResult(
state.MediaPath, state.MediaPath,
contentType, contentType,
isHeadRequest,
_httpContextAccessor.HttpContext); _httpContextAccessor.HttpContext);
} }

@ -22,14 +22,12 @@ namespace Jellyfin.Api.Helpers
/// Returns a static file from a remote source. /// Returns a static file from a remote source.
/// </summary> /// </summary>
/// <param name="state">The current <see cref="StreamState"/>.</param> /// <param name="state">The current <see cref="StreamState"/>.</param>
/// <param name="isHeadRequest">Whether the current request is a HTTP HEAD request so only the headers get returned.</param>
/// <param name="httpClient">The <see cref="HttpClient"/> making the remote request.</param> /// <param name="httpClient">The <see cref="HttpClient"/> making the remote request.</param>
/// <param name="httpContext">The current http context.</param> /// <param name="httpContext">The current http context.</param>
/// <param name="cancellationToken">A cancellation token that can be used to cancel the operation.</param> /// <param name="cancellationToken">A cancellation token that can be used to cancel the operation.</param>
/// <returns>A <see cref="Task{ActionResult}"/> containing the API response.</returns> /// <returns>A <see cref="Task{ActionResult}"/> containing the API response.</returns>
public static async Task<ActionResult> GetStaticRemoteStreamResult( public static async Task<ActionResult> GetStaticRemoteStreamResult(
StreamState state, StreamState state,
bool isHeadRequest,
HttpClient httpClient, HttpClient httpClient,
HttpContext httpContext, HttpContext httpContext,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
@ -53,17 +51,13 @@ namespace Jellyfin.Api.Helpers
/// </summary> /// </summary>
/// <param name="path">The path to the file.</param> /// <param name="path">The path to the file.</param>
/// <param name="contentType">The content type of the file.</param> /// <param name="contentType">The content type of the file.</param>
/// <param name="isHeadRequest">Whether the current request is a HTTP HEAD request so only the headers get returned.</param>
/// <param name="httpContext">The current http context.</param> /// <param name="httpContext">The current http context.</param>
/// <returns>An <see cref="ActionResult"/> the file.</returns> /// <returns>An <see cref="ActionResult"/> the file.</returns>
public static ActionResult GetStaticFileResult( public static ActionResult GetStaticFileResult(
string path, string path,
string contentType, string contentType,
bool isHeadRequest,
HttpContext httpContext) HttpContext httpContext)
{ {
httpContext.Response.ContentType = contentType;
return new PhysicalFileResult(path, contentType) { EnableRangeProcessing = true }; return new PhysicalFileResult(path, contentType) { EnableRangeProcessing = true };
} }

Loading…
Cancel
Save