dotnet / dotnet/aspnetcore

Brotli compressor not working when compressing small text output

Open
#54,827 2 comments 0 reactions 0 assignees View on GitHub
area-middleware
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

### Description

In a Microsoft.NET.Sdk.Web project, having one controller having one view with little text, there is NO output when navigating with a browser (Chrome or Firefox), to an url which is served by this controller. (Using .NET 8.0.3)

### Reproduction Steps

Program.cs
```c#
var builder = WebApplication.CreateBuilder();

builder.Services.AddRazorPages();
builder.Services.AddResponseCompression();

var app = builder.Build();

app.MapControllers();
app.UseResponseCompression();
app.Run();
```
/Index.cshtml.cs (controller)
```C#
using Microsoft.AspNetCore.Mvc;
namespace AspNetCoreNotEmpty1;
public class PopController : Controller
{
[HttpGet("~/")]
public IActionResult Index()
{
return View("/Index.cshtml");
}
}
```
/Index.cshtml

```html

Index Test 123

```
[SolutionBugDemo.zip](https://github.com/dotnet/runtime/files/14786334/SolutionBugDemo.zip)

### Expected behavior

When starting (debugging) the project, here should be the text 'Index Test 123' on a browser.

### Actual behavior

Starting the project, browser is navigating to its debug localhost url.
When doing a reload of the localhost url, **nothing appears**.
Chrome debug console shows 'Failed' request, however, headers seems to be normal.
FireFox shows 'Content encoding error'.

### Regression?

_No response_

### Known Workarounds

Changing text from 'Index Test 123' to 'Index Test 1234'
Simply adding more text. there is output, as expected.

It seems that when using small text messages, the Brotli compressor, or the framework calling the compressor does not function correctly. However the headers (Chrome) are intact.

![Knipsel](https://github.com/dotnet/runtime/assets/2096186/fbf1189b-2040-4175-a797-51e670572973)

### Configuration

_No response_

### Other information

_No response_

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.