Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP3 GET requests get forwarded with Transfer-Encoding chunked #2644

Open
nimatt opened this issue Oct 31, 2024 · 1 comment
Open

HTTP3 GET requests get forwarded with Transfer-Encoding chunked #2644

nimatt opened this issue Oct 31, 2024 · 1 comment
Labels
External: AspNetCore This work will mostly be done in the dotnet/aspnetcore repo Type: Tracking Tracking work to be done in other repositories.
Milestone

Comments

@nimatt
Copy link

nimatt commented Oct 31, 2024

Describe the bug

When performing a simple GET request over HTTP3 using Firefox, which gets forwarded using HTTP1.1. The outgoing request gets a StreamCopyHttpContent (with HTTP2 and HTTP1.1 it has null as content) which leads to Transfer-Encoding header being set to chunked. This makes one of our servers behind the proxy throw errors.

To Reproduce

  • Set up a proxy supporting HTTP3
  • Forward data to a HTTP1.1 server
  • Perform a GET request using Firefox

Further technical details

  • .NET 8.0
  • Yarp 2.2.0
  • Linux

Outgoing request
GET / HTTP/1.1
Host: dev.local
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:132.0) Gecko/20100101 Firefox/132.0
Accept-Encoding: gzip, deflate, br, zstd
Accept-Language: en-US,en;q=0.5
Alt-Used: dev.local:8443
Cache-Control: no-cache
Pragma: no-cache
sec-fetch-dest: document
sec-fetch-mode: navigate
sec-fetch-site: none
sec-fetch-user: ?1
priority: u=0, i
X-Forwarded-For: 127.0.0.1
X-Forwarded-Host: dev.local
X-Forwarded-Proto: https
Transfer-Encoding: chunked

@nimatt nimatt added the Type: Bug Something isn't working label Oct 31, 2024
@MihaZupan MihaZupan added Type: Tracking Tracking work to be done in other repositories. External: AspNetCore This work will mostly be done in the dotnet/aspnetcore repo and removed Type: Bug Something isn't working labels Nov 7, 2024
@MihaZupan MihaZupan added this to the Backlog milestone Nov 7, 2024
@MihaZupan
Copy link
Member

That looks like a body detection bug in Kestrel, filed dotnet/aspnetcore#58753.

You should be able to workaround the issue by overriding the IHttpRequestBodyDetectionFeature, e.g.

app.Use((context, next) =>
{
    if (HttpProtocol.IsHttp3(context.Request.Protocol) && HttpMethods.IsGet(context.Request.Method))
    {
        // Workaround https://github.com/microsoft/reverse-proxy/issues/2644
        context.Features.Set<IHttpRequestBodyDetectionFeature>(null);
    }

    return next();
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
External: AspNetCore This work will mostly be done in the dotnet/aspnetcore repo Type: Tracking Tracking work to be done in other repositories.
Projects
None yet
Development

No branches or pull requests

2 participants