diff --git a/src/Microsoft.Net.Http.Server/RequestProcessing/Response.cs b/src/Microsoft.Net.Http.Server/RequestProcessing/Response.cs index a16d11f..7185d03 100644 --- a/src/Microsoft.Net.Http.Server/RequestProcessing/Response.cs +++ b/src/Microsoft.Net.Http.Server/RequestProcessing/Response.cs @@ -453,14 +453,14 @@ namespace Microsoft.Net.Http.Server _boundaryType = BoundaryType.ContentLength; _expectedBodyLength = 0; } - else if (keepConnectionAlive && requestVersion == Constants.V1_1) + else if (requestVersion == Constants.V1_1) { _boundaryType = BoundaryType.Chunked; Headers[HttpKnownHeaderNames.TransferEncoding] = Constants.Chunked; } else { - // The length cannot be determined, so we must close the connection + // v1.0 and the length cannot be determined, so we must close the connection after writing data keepConnectionAlive = false; _boundaryType = BoundaryType.Close; } diff --git a/test/Microsoft.AspNetCore.Server.WebListener.FunctionalTests/ResponseHeaderTests.cs b/test/Microsoft.AspNetCore.Server.WebListener.FunctionalTests/ResponseHeaderTests.cs index b5f7ba1..8183b52 100644 --- a/test/Microsoft.AspNetCore.Server.WebListener.FunctionalTests/ResponseHeaderTests.cs +++ b/test/Microsoft.AspNetCore.Server.WebListener.FunctionalTests/ResponseHeaderTests.cs @@ -133,7 +133,8 @@ namespace Microsoft.AspNetCore.Server.WebListener response.EnsureSuccessStatusCode(); Assert.True(response.Headers.ConnectionClose.Value); Assert.Equal(new string[] { "close" }, response.Headers.GetValues("Connection")); - Assert.False(response.Headers.TransferEncodingChunked.HasValue); + Assert.True(response.Headers.TransferEncodingChunked.HasValue); + Assert.True(response.Headers.TransferEncodingChunked); IEnumerable values; var result = response.Content.Headers.TryGetValues("Content-Length", out values); Assert.False(result);