diff --git a/src/Mvc/Mvc.Core/test/FileContentResultTest.cs b/src/Mvc/Mvc.Core/test/FileContentResultTest.cs index 378422388b..64337a02a0 100644 --- a/src/Mvc/Mvc.Core/test/FileContentResultTest.cs +++ b/src/Mvc/Mvc.Core/test/FileContentResultTest.cs @@ -361,6 +361,7 @@ namespace Microsoft.AspNetCore.Mvc Assert.Equal(StatusCodes.Status416RangeNotSatisfiable, httpResponse.StatusCode); Assert.Equal("bytes", httpResponse.Headers[HeaderNames.AcceptRanges]); Assert.Equal(contentRange.ToString(), httpResponse.Headers[HeaderNames.ContentRange]); + Assert.Equal(0, httpResponse.ContentLength); Assert.Empty(body); } diff --git a/src/Mvc/Mvc.Core/test/FileStreamResultTest.cs b/src/Mvc/Mvc.Core/test/FileStreamResultTest.cs index bfb001a9bc..d879d65f6c 100644 --- a/src/Mvc/Mvc.Core/test/FileStreamResultTest.cs +++ b/src/Mvc/Mvc.Core/test/FileStreamResultTest.cs @@ -348,7 +348,7 @@ namespace Microsoft.AspNetCore.Mvc Assert.Equal(StatusCodes.Status416RangeNotSatisfiable, httpResponse.StatusCode); Assert.Equal("bytes", httpResponse.Headers[HeaderNames.AcceptRanges]); Assert.Equal(contentRange.ToString(), httpResponse.Headers[HeaderNames.ContentRange]); - Assert.Equal(11, httpResponse.ContentLength); + Assert.Equal(0, httpResponse.ContentLength); Assert.Empty(body); Assert.False(readStream.CanSeek); } @@ -486,6 +486,7 @@ namespace Microsoft.AspNetCore.Mvc Assert.Equal(StatusCodes.Status416RangeNotSatisfiable, httpResponse.StatusCode); Assert.Equal("bytes", httpResponse.Headers[HeaderNames.AcceptRanges]); Assert.Equal(contentRange.ToString(), httpResponse.Headers[HeaderNames.ContentRange]); + Assert.Equal(0, httpResponse.ContentLength); Assert.Empty(body); Assert.False(readStream.CanSeek); } diff --git a/src/Mvc/Mvc.Core/test/PhysicalFileResultTest.cs b/src/Mvc/Mvc.Core/test/PhysicalFileResultTest.cs index e6173fd070..2788f186c7 100644 --- a/src/Mvc/Mvc.Core/test/PhysicalFileResultTest.cs +++ b/src/Mvc/Mvc.Core/test/PhysicalFileResultTest.cs @@ -244,6 +244,7 @@ namespace Microsoft.AspNetCore.Mvc Assert.Equal("bytes", httpResponse.Headers[HeaderNames.AcceptRanges]); Assert.Equal(contentRange.ToString(), httpResponse.Headers[HeaderNames.ContentRange]); Assert.NotEmpty(httpResponse.Headers[HeaderNames.LastModified]); + Assert.Equal(0, httpResponse.ContentLength); Assert.Empty(body); } diff --git a/src/Mvc/Mvc.Core/test/VirtualFileResultTest.cs b/src/Mvc/Mvc.Core/test/VirtualFileResultTest.cs index e9aed292ab..899b0a5404 100644 --- a/src/Mvc/Mvc.Core/test/VirtualFileResultTest.cs +++ b/src/Mvc/Mvc.Core/test/VirtualFileResultTest.cs @@ -317,6 +317,7 @@ namespace Microsoft.AspNetCore.Mvc Assert.Equal("bytes", httpResponse.Headers[HeaderNames.AcceptRanges]); Assert.Equal(contentRange.ToString(), httpResponse.Headers[HeaderNames.ContentRange]); Assert.NotEmpty(httpResponse.Headers[HeaderNames.LastModified]); + Assert.Equal(0, httpResponse.ContentLength); Assert.Empty(body); } diff --git a/src/Mvc/test/Mvc.FunctionalTests/FileResultTests.cs b/src/Mvc/test/Mvc.FunctionalTests/FileResultTests.cs index 88c8c293ae..35a57dbbe5 100644 --- a/src/Mvc/test/Mvc.FunctionalTests/FileResultTests.cs +++ b/src/Mvc/test/Mvc.FunctionalTests/FileResultTests.cs @@ -97,6 +97,7 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests Assert.Equal(HttpStatusCode.RequestedRangeNotSatisfiable, response.StatusCode); Assert.NotNull(response.Content.Headers.ContentType); Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); + Assert.Equal(0, response.Content.Headers.ContentLength); var body = await response.Content.ReadAsStringAsync(); Assert.Empty(body); } @@ -160,6 +161,7 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests Assert.Equal(HttpStatusCode.RequestedRangeNotSatisfiable, response.StatusCode); Assert.NotNull(response.Content.Headers.ContentType); Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); + Assert.Equal(0, response.Content.Headers.ContentLength); var body = await response.Content.ReadAsStringAsync(); Assert.Empty(body); } @@ -255,8 +257,8 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests [InlineData("0-6", (int)HttpStatusCode.OK, 26)] [InlineData("bytes = ", (int)HttpStatusCode.OK, 26)] [InlineData("bytes = 1-4, 5-11", (int)HttpStatusCode.OK, 26)] - [InlineData("bytes = 35-36", (int)HttpStatusCode.RequestedRangeNotSatisfiable, 26)] - [InlineData("bytes = -0", (int)HttpStatusCode.RequestedRangeNotSatisfiable, 26)] + [InlineData("bytes = 35-36", (int)HttpStatusCode.RequestedRangeNotSatisfiable, 0)] + [InlineData("bytes = -0", (int)HttpStatusCode.RequestedRangeNotSatisfiable, 0)] public async Task FileFromDisk_ReturnsFileWithFileName_DoesNotServeBody_ForHeadRequest_WithLastModifiedAndEtag( string rangeString, int httpStatusCode, @@ -365,6 +367,7 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests Assert.Equal(HttpStatusCode.RequestedRangeNotSatisfiable, response.StatusCode); Assert.NotNull(response.Content.Headers.ContentType); Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); + Assert.Equal(0, response.Content.Headers.ContentLength); Assert.Empty(body); } @@ -455,8 +458,8 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests [InlineData("0-6", (int)HttpStatusCode.OK, 33)] [InlineData("bytes = ", (int)HttpStatusCode.OK, 33)] [InlineData("bytes = 1-4, 5-11", (int)HttpStatusCode.OK, 33)] - [InlineData("bytes = 35-36", (int)HttpStatusCode.RequestedRangeNotSatisfiable, 33)] - [InlineData("bytes = -0", (int)HttpStatusCode.RequestedRangeNotSatisfiable, 33)] + [InlineData("bytes = 35-36", (int)HttpStatusCode.RequestedRangeNotSatisfiable, 0)] + [InlineData("bytes = -0", (int)HttpStatusCode.RequestedRangeNotSatisfiable, 0)] public async Task FileFromStream_ReturnsFileWithFileName_DoesNotServeBody_ForHeadRequest( string rangeString, int httpStatusCode, @@ -568,6 +571,7 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests Assert.Equal(HttpStatusCode.RequestedRangeNotSatisfiable, response.StatusCode); Assert.NotNull(response.Content.Headers.ContentType); Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); + Assert.Equal(0, response.Content.Headers.ContentLength); Assert.Empty(body); } @@ -660,8 +664,8 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests [InlineData("0-6", (int)HttpStatusCode.OK, 41)] [InlineData("bytes = ", (int)HttpStatusCode.OK, 41)] [InlineData("bytes = 1-4, 5-11", (int)HttpStatusCode.OK, 41)] - [InlineData("bytes = 45-46", (int)HttpStatusCode.RequestedRangeNotSatisfiable, 41)] - [InlineData("bytes = -0", (int)HttpStatusCode.RequestedRangeNotSatisfiable, 41)] + [InlineData("bytes = 45-46", (int)HttpStatusCode.RequestedRangeNotSatisfiable, 0)] + [InlineData("bytes = -0", (int)HttpStatusCode.RequestedRangeNotSatisfiable, 0)] public async Task FileFromBinaryData_ReturnsFileWithFileName_DoesNotServeBody_ForHeadRequest( string rangeString, int httpStatusCode, @@ -847,6 +851,7 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests Assert.Equal(HttpStatusCode.RequestedRangeNotSatisfiable, response.StatusCode); Assert.NotNull(response.Content.Headers.ContentType); Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); + Assert.Equal(0, response.Content.Headers.ContentLength); var body = await response.Content.ReadAsStringAsync(); Assert.Empty(body); var contentDisposition = response.Content.Headers.ContentDisposition.ToString(); @@ -863,8 +868,8 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests [InlineData("0-6", (int)HttpStatusCode.OK, 38)] [InlineData("bytes = ", (int)HttpStatusCode.OK, 38)] [InlineData("bytes = 1-4, 5-11", (int)HttpStatusCode.OK, 38)] - [InlineData("bytes = 45-46", (int)HttpStatusCode.RequestedRangeNotSatisfiable, 38)] - [InlineData("bytes = -0", (int)HttpStatusCode.RequestedRangeNotSatisfiable, 38)] + [InlineData("bytes = 45-46", (int)HttpStatusCode.RequestedRangeNotSatisfiable, 0)] + [InlineData("bytes = -0", (int)HttpStatusCode.RequestedRangeNotSatisfiable, 0)] public async Task FileFromEmbeddedResources_ReturnsFileWithFileName_DoesNotServeBody_ForHeadRequest( string rangeString, int httpStatusCode,