Skip to content
This repository was archived by the owner on Mar 19, 2019. It is now read-only.

Commit 2433448

Browse files
committed
#259 Auto-chunk even for Connection: close responses
1 parent e1ef220 commit 2433448

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/Microsoft.Net.Http.Server/RequestProcessing/Response.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,14 +453,14 @@ internal HttpApi.HTTP_FLAGS ComputeHeaders(long writeCount, bool endOfRequest =
453453
_boundaryType = BoundaryType.ContentLength;
454454
_expectedBodyLength = 0;
455455
}
456-
else if (keepConnectionAlive && requestVersion == Constants.V1_1)
456+
else if (requestVersion == Constants.V1_1)
457457
{
458458
_boundaryType = BoundaryType.Chunked;
459459
Headers[HttpKnownHeaderNames.TransferEncoding] = Constants.Chunked;
460460
}
461461
else
462462
{
463-
// The length cannot be determined, so we must close the connection
463+
// v1.0 and the length cannot be determined, so we must close the connection after writing data
464464
keepConnectionAlive = false;
465465
_boundaryType = BoundaryType.Close;
466466
}

test/Microsoft.AspNetCore.Server.WebListener.FunctionalTests/ResponseHeaderTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ public async Task ResponseHeaders_ServerSendsConnectionClose_Closed()
133133
response.EnsureSuccessStatusCode();
134134
Assert.True(response.Headers.ConnectionClose.Value);
135135
Assert.Equal(new string[] { "close" }, response.Headers.GetValues("Connection"));
136-
Assert.False(response.Headers.TransferEncodingChunked.HasValue);
136+
Assert.True(response.Headers.TransferEncodingChunked.HasValue);
137+
Assert.True(response.Headers.TransferEncodingChunked);
137138
IEnumerable<string> values;
138139
var result = response.Content.Headers.TryGetValues("Content-Length", out values);
139140
Assert.False(result);

0 commit comments

Comments
 (0)