dotnet / dotnet/aspnetcore

Http/1.0 keep-alive follow up work

Open
#57,494 0 comments 0 reactions 0 assignees View on GitHub
area-networking
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

From https://github.com/dotnet/aspnetcore/pull/56558#discussion_r1663191600

> it seems like a good idea to play it safe and close the connection in the `responseChunkedSet` case.
>
> I think we should do the same thing in Kestrel:

> https://github.com/dotnet/aspnetcore/blob/59d4050e7a26326764aa0f008b378f0adbc40efa/src/Servers/Kestrel/Core/src/Internal/Http/HttpProtocol.cs#L1145-L1155
>
> We could add the following and a test to keep the behaviors of Http.Sys and Kestrel aligned:
>
> ```csharp
> if (hasTransferEncoding && _httpVersion == Http.HttpVersion.Http10)
> {
> _keepAlive = false;
> }
> ```
>
> It might also be a good idea to have Http.Sys do the `HttpHeaders.GetFinalTransferCoding(responseHeaders.HeaderTransferEncoding) != TransferCoding.Chunked` check that Kestrel does and disable keep-alive connections even for HTTP/1.1 due to RFC 7230 3.3.1.
>
> I also don't think `var responseChunkedSet = Matches(Constants.Chunked, transferEncodingString);` properly handles things like apps that manually set something like `Transfer-Encoding: gzip, chunked`, so it's probably good to call `HttpHeaders.GetFinalTransferCoding` just to fix the other logic that relies on `responseChunkedSet`.

https://github.com/dotnet/aspnetcore/blob/21afee0e9f393222b803893012ed375da0810caf/src/Servers/HttpSys/src/RequestProcessing/Response.cs#L394

cc @halter73

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.