parent
83c3ac62fb
commit
eeac99985a
|
|
@ -89,7 +89,10 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
|
|||
// Assuming the request is not a range request, the Content-Length header is set to the length of the entire file.
|
||||
// If the request is a valid range request, this header is overwritten with the length of the range as part of the
|
||||
// range processing (see method SetContentLength).
|
||||
response.ContentLength = fileLength.Value;
|
||||
if (serveBody)
|
||||
{
|
||||
response.ContentLength = fileLength.Value;
|
||||
}
|
||||
if (HttpMethods.IsHead(request.Method) || HttpMethods.IsGet(request.Method))
|
||||
{
|
||||
if ((preconditionState == PreconditionState.Unspecified ||
|
||||
|
|
|
|||
|
|
@ -348,7 +348,7 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
var body = streamReader.ReadToEndAsync().Result;
|
||||
Assert.Equal(StatusCodes.Status412PreconditionFailed, httpResponse.StatusCode);
|
||||
Assert.Equal("bytes", httpResponse.Headers[HeaderNames.AcceptRanges]);
|
||||
Assert.Equal(11, httpResponse.ContentLength);
|
||||
Assert.Null(httpResponse.ContentLength);
|
||||
Assert.Empty(httpResponse.Headers[HeaderNames.ContentRange]);
|
||||
Assert.NotEmpty(httpResponse.Headers[HeaderNames.LastModified]);
|
||||
Assert.Empty(body);
|
||||
|
|
@ -390,7 +390,7 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
var body = streamReader.ReadToEndAsync().Result;
|
||||
Assert.Equal(StatusCodes.Status304NotModified, httpResponse.StatusCode);
|
||||
Assert.Equal("bytes", httpResponse.Headers[HeaderNames.AcceptRanges]);
|
||||
Assert.Equal(11, httpResponse.ContentLength);
|
||||
Assert.Null(httpResponse.ContentLength);
|
||||
Assert.Empty(httpResponse.Headers[HeaderNames.ContentRange]);
|
||||
Assert.NotEmpty(httpResponse.Headers[HeaderNames.LastModified]);
|
||||
Assert.Empty(body);
|
||||
|
|
|
|||
|
|
@ -338,7 +338,7 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
var body = streamReader.ReadToEndAsync().Result;
|
||||
Assert.Equal(StatusCodes.Status412PreconditionFailed, httpResponse.StatusCode);
|
||||
Assert.Equal("bytes", httpResponse.Headers[HeaderNames.AcceptRanges]);
|
||||
Assert.Equal(11, httpResponse.ContentLength);
|
||||
Assert.Null(httpResponse.ContentLength);
|
||||
Assert.Empty(httpResponse.Headers[HeaderNames.ContentRange]);
|
||||
Assert.NotEmpty(httpResponse.Headers[HeaderNames.LastModified]);
|
||||
Assert.Empty(body);
|
||||
|
|
@ -381,7 +381,7 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
var body = streamReader.ReadToEndAsync().Result;
|
||||
Assert.Equal(StatusCodes.Status304NotModified, httpResponse.StatusCode);
|
||||
Assert.Equal("bytes", httpResponse.Headers[HeaderNames.AcceptRanges]);
|
||||
Assert.Equal(11, httpResponse.ContentLength);
|
||||
Assert.Null(httpResponse.ContentLength);
|
||||
Assert.Empty(httpResponse.Headers[HeaderNames.ContentRange]);
|
||||
Assert.NotEmpty(httpResponse.Headers[HeaderNames.LastModified]);
|
||||
Assert.Empty(body);
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
var body = streamReader.ReadToEndAsync().Result;
|
||||
Assert.Equal(StatusCodes.Status412PreconditionFailed, httpResponse.StatusCode);
|
||||
Assert.Equal("bytes", httpResponse.Headers[HeaderNames.AcceptRanges]);
|
||||
Assert.Equal(34, httpResponse.ContentLength);
|
||||
Assert.Null(httpResponse.ContentLength);
|
||||
Assert.Empty(httpResponse.Headers[HeaderNames.ContentRange]);
|
||||
Assert.NotEmpty(httpResponse.Headers[HeaderNames.LastModified]);
|
||||
Assert.Empty(body);
|
||||
|
|
@ -272,7 +272,7 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
var body = streamReader.ReadToEndAsync().Result;
|
||||
Assert.Equal(StatusCodes.Status304NotModified, httpResponse.StatusCode);
|
||||
Assert.Equal("bytes", httpResponse.Headers[HeaderNames.AcceptRanges]);
|
||||
Assert.Equal(34, httpResponse.ContentLength);
|
||||
Assert.Null(httpResponse.ContentLength);
|
||||
Assert.Empty(httpResponse.Headers[HeaderNames.ContentRange]);
|
||||
Assert.NotEmpty(httpResponse.Headers[HeaderNames.LastModified]);
|
||||
Assert.Empty(body);
|
||||
|
|
|
|||
|
|
@ -314,7 +314,7 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
var body = streamReader.ReadToEndAsync().Result;
|
||||
Assert.Equal(StatusCodes.Status412PreconditionFailed, httpResponse.StatusCode);
|
||||
Assert.Equal("bytes", httpResponse.Headers[HeaderNames.AcceptRanges]);
|
||||
Assert.Equal(33, httpResponse.ContentLength);
|
||||
Assert.Null(httpResponse.ContentLength);
|
||||
Assert.Empty(httpResponse.Headers[HeaderNames.ContentRange]);
|
||||
Assert.NotEmpty(httpResponse.Headers[HeaderNames.LastModified]);
|
||||
Assert.Empty(body);
|
||||
|
|
@ -356,7 +356,7 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
var body = streamReader.ReadToEndAsync().Result;
|
||||
Assert.Equal(StatusCodes.Status304NotModified, httpResponse.StatusCode);
|
||||
Assert.Equal("bytes", httpResponse.Headers[HeaderNames.AcceptRanges]);
|
||||
Assert.Equal(33, httpResponse.ContentLength);
|
||||
Assert.Null(httpResponse.ContentLength);
|
||||
Assert.Empty(httpResponse.Headers[HeaderNames.ContentRange]);
|
||||
Assert.NotEmpty(httpResponse.Headers[HeaderNames.LastModified]);
|
||||
Assert.Empty(body);
|
||||
|
|
|
|||
Loading…
Reference in New Issue