From 7af971838ec527221f4260bae3bf11e8ae5b035c Mon Sep 17 00:00:00 2001 From: Matthias Laroche Date: Sat, 15 Dec 2018 18:29:10 +0100 Subject: [PATCH] Set Content-Length to 0, when returning an empty body When returning 416 RangeNotSatisfiable in FileResultExecutorBase, set the Content-Length based on the length of the body instead of the length of the original file. Bugfix for : https://github.com/aspnet/AspNetCore/issues/4943 --- src/Mvc/Mvc.Core/src/Infrastructure/FileResultExecutorBase.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Mvc/Mvc.Core/src/Infrastructure/FileResultExecutorBase.cs b/src/Mvc/Mvc.Core/src/Infrastructure/FileResultExecutorBase.cs index bfd5546bed..59fd3eb09c 100644 --- a/src/Mvc/Mvc.Core/src/Infrastructure/FileResultExecutorBase.cs +++ b/src/Mvc/Mvc.Core/src/Infrastructure/FileResultExecutorBase.cs @@ -322,6 +322,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure // the current length of the selected resource. e.g. */length response.StatusCode = StatusCodes.Status416RangeNotSatisfiable; httpResponseHeaders.ContentRange = new ContentRangeHeaderValue(fileLength); + response.ContentLength = 0; return (range: null, rangeLength: 0, serveBody: false); }