#259 Auto-chunk even for Connection: close responses

This commit is contained in:
Chris R 2016-10-05 10:19:20 -07:00
parent e1ef220bf1
commit 2433448bc7
2 changed files with 4 additions and 3 deletions

View File

@ -453,14 +453,14 @@ namespace Microsoft.Net.Http.Server
_boundaryType = BoundaryType.ContentLength; _boundaryType = BoundaryType.ContentLength;
_expectedBodyLength = 0; _expectedBodyLength = 0;
} }
else if (keepConnectionAlive && requestVersion == Constants.V1_1) else if (requestVersion == Constants.V1_1)
{ {
_boundaryType = BoundaryType.Chunked; _boundaryType = BoundaryType.Chunked;
Headers[HttpKnownHeaderNames.TransferEncoding] = Constants.Chunked; Headers[HttpKnownHeaderNames.TransferEncoding] = Constants.Chunked;
} }
else 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; keepConnectionAlive = false;
_boundaryType = BoundaryType.Close; _boundaryType = BoundaryType.Close;
} }

View File

@ -133,7 +133,8 @@ namespace Microsoft.AspNetCore.Server.WebListener
response.EnsureSuccessStatusCode(); response.EnsureSuccessStatusCode();
Assert.True(response.Headers.ConnectionClose.Value); Assert.True(response.Headers.ConnectionClose.Value);
Assert.Equal(new string[] { "close" }, response.Headers.GetValues("Connection")); 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<string> values; IEnumerable<string> values;
var result = response.Content.Headers.TryGetValues("Content-Length", out values); var result = response.Content.Headers.TryGetValues("Content-Length", out values);
Assert.False(result); Assert.False(result);