Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Commit 67fc0f3

Browse files
committed
Don't set TE header for non-body responses
Resolves #952
1 parent efa37e5 commit 67fc0f3

File tree

1 file changed

+8
-3
lines changed
  • src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http

1 file changed

+8
-3
lines changed

src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http/Frame.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ private void CreateResponseHeader(
731731
{
732732
if (appCompleted)
733733
{
734-
// Don't set the Content-Length or Transfer-Encoding headers
734+
// Don't set the Content-Length header
735735
// automatically for HEAD requests or 101, 204, 205, 304 responses.
736736
if (Method != "HEAD" && StatusCanHaveBody(StatusCode))
737737
{
@@ -751,8 +751,13 @@ private void CreateResponseHeader(
751751
// request indicates HTTP/1.1 (or later).
752752
if (_httpVersion == HttpVersionType.Http11)
753753
{
754-
_autoChunk = true;
755-
responseHeaders.SetRawTransferEncoding("chunked", _bytesTransferEncodingChunked);
754+
// Don't set the Transfer-Encoding header
755+
// automatically for HEAD requests or 101, 204, 205, 304 responses.
756+
if (Method != "HEAD" && StatusCanHaveBody(StatusCode))
757+
{
758+
_autoChunk = true;
759+
responseHeaders.SetRawTransferEncoding("chunked", _bytesTransferEncodingChunked);
760+
}
756761
}
757762
else
758763
{

0 commit comments

Comments
 (0)