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
This commit is contained in:
Matthias Laroche 2018-12-15 18:29:10 +01:00 committed by Artak
parent 134f28f71d
commit 7af971838e
1 changed files with 1 additions and 0 deletions

View File

@ -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);
}