3using System.Threading.Tasks;
5using Microsoft.AspNetCore.Http.Extensions;
6using Microsoft.AspNetCore.Mvc;
7using Microsoft.AspNetCore.Mvc.Infrastructure;
8using Microsoft.Extensions.Logging;
29 ArgumentNullException.ThrowIfNull(context);
31 ArgumentNullException.ThrowIfNull(result);
35 var cancellationToken = context.HttpContext.RequestAborted;
36 var stream = await result.
GetResult(cancellationToken);
37 var contentLength = stream.Length;
38 var (range, rangeLength, serveBody) = SetHeadersAndLog(context, result, contentLength, result.EnableRangeProcessing);
44 var outputStream = context.HttpContext.Response.Body;
47 await StreamCopyOperation.CopyToAsync(
56 stream.Seek(range.From.Value, SeekOrigin.Begin);
57 await StreamCopyOperation.CopyToAsync(
65 catch (OperationCanceledException)
69 context.HttpContext.Abort();
IActionResultExecutor<TResult> for LimitedStreamResults.
LimitedStreamResultExecutor(ILogger< LimitedStreamResultExecutor > logger)
Initializes a new instance of the LimitedStreamResultExecutor class.
async Task ExecuteAsync(ActionContext context, LimitedStreamResult result)
Very similar to FileStreamResult except it's IActionResultExecutor<TResult> contains a fix for https:...
Task< Stream > GetResult(CancellationToken cancellationToken)
Gets the provided Stream. May be called multiple times, though cancelling any may cause all calls to ...