dotnet / dotnet/aspnetcore

HTTP Trailers Causing Response Truncation in FireFox when Served from IIS on Windows Server 2022

Open
#44,944 19 comments 1 reaction 0 assignees View on GitHub
area-networking External
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 5h
Merged PRs (30d)
276

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Describe the bug

When serving a ASP.NET 6 MVC application using HTTP Trailers from IIS on Windows Server 2022 and accessing the application using FireFox on Windows (version 106.0.5), the responses are getting truncated.

Running in Visual Studio, served with Kestrel, and accessed via FireFox shows the trailers ("Server-Timing").

### Expected Behavior

The response content should not get truncated, and the Server-Timing information should be available in the browser dev tools.

### Steps To Reproduce

See https://github.com/eajhnsn1/net6-trailers-problem

OR

1. Create a new ASP.NET 6 MVC application
2. Add the following middleware function to the pipeline:
```cs
app.Use(async (context, next) =>
{
if (AllowsTrailers(context.Request) && context.Response.SupportsTrailers())
{
// Declare that there will be a trailer after the response body.
context.Response.DeclareTrailer("Server-Timing");

// Continue
await next(context);

// Output trailer
context.Response.AppendTrailer(
"Server-Timing",
"total;dur=123.4");
}
else
{
await next(context);
}
static bool AllowsTrailers(HttpRequest request)
{
return request.Headers.ContainsKey("TE") &&
request.Headers["TE"].Contains("trailers");
}
});
```
3. Serve the application from IIS on Windows Server 2022 (with HTTP/2 support), access it with Firefox

The page will load without correct styling, because the response content is truncated. The out-of-the-box sample application (for me) ends up missing a single character in the response (the last > on the html closing tag). In a real application, only the first portion of the response is actually downloaded. Confirm with View Page Source. If you add HTML content to the views in the sample page, more content gets truncated.

### Exceptions (if any)

_No response_

### .NET Version

6.0.402

### Anything else?

See https://github.com/eajhnsn1/net6-trailers-problem/blob/main/Program.cs

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.