Allow custom response body streaming of HTTP Responses without Transfer-Encoding or Content-Length set #59055
Labels
area-networking
Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
Is there an existing issue for this?
Is your feature request related to a problem? Please describe the problem.
I am trying to do a plain HTTP response streaming without chunked HTTP encoding but using an own framing logic. Unfortunately Kestrel automatically switches to chunked encoding based on whether a custom
Transfer-Encoding
orContent-Length
is set.aspnetcore/src/Servers/Kestrel/Core/src/Internal/Http/HttpProtocol.cs
Lines 1198 to 1228 in 6359c76
Setting the Transfer-Encoding to something custom (e.g. the outdated
identity
) breaks compatibliity with reverse proxies like Traeffik. Hence I want to be able to "stream" an endless (no Content-Length known) raw byte response without setting a Transfer-Encoding header.Describe the solution you'd like
Kestrel should give some control on whether the automatic switch to chunked encoding is done or not allowing me to disable it. This could happen either via a new
IFeature
or as extension to an existing feature.Additional context
While this automatic switching might be OK for most standard browser use-cases, it breaks any usecases where HTTP is used as foundation for alternative communication systems. The HTTP/1.1 spec mentions that Transfer-Encodings need to be registered in the HTTP Transfer Coding Registry
so it is better to not send anything than an wrong/unsupported value.
My main real-world usecase is:
The text was updated successfully, but these errors were encountered: