Skip to content

Add BrotliDecompressionOptions to support Large Window Brotli decompression - #135846

Open
iremyux wants to merge 13 commits into
dotnet:mainfrom
iremyux:133018-brotli-decomp-options
Open

iremyux wants to merge 13 commits into
dotnet:mainfrom
iremyux:133018-brotli-decomp-options

Conversation

@iremyux

@iremyux iremyux commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Adds opt-in support for decompressing Brotli streams with window sizes beyond default range, via a new BrotliDecompressionOptions type.

Resolves #133018

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @karelz, @dotnet/area-system-io-compression
See info in area-owners.md if you want to be subscribed.

@iremyux iremyux changed the title  Add BrotliDecompressionOptions to support Large Window Brotli decompression  Add BrotliDecompressionOptions to support Large Window Brotli decompression  Oct 15, 2026
@iremyux iremyux changed the title Add BrotliDecompressionOptions to support Large Window Brotli decompression  Add BrotliDecompressionOptions to support Large Window Brotli decompression Oct 15, 2026
@iremyux
iremyux requested a balanced review from Copilot October 15, 2026 09:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Decoder validation can bypass the configured window ceiling, and header handling and argument validation have correctness regressions.

3 open findings
What changed in this PR

Adds configurable Brotli decompression window limits to support opt-in Large Window Brotli in the existing compression library.

Changes:

  • Adds BrotliDecompressionOptions and decoder/stream overloads.
  • Extends encoding windows to 30 bits and validates compatible quality settings.
  • Adds native decoder configuration bindings and window-limit tests.

Validation was limited to source inspection; no builds or tests were run.

File Description
src/​native/​libs/​System.IO.Compression.Native/​System.IO.Compression.Native.def Exports decoder parameter configuration on Windows.
src/​native/​libs/​System.IO.Compression.Native/​System.IO.Compression.Native_unixexports.src Exports decoder parameter configuration on Unix.
src/​native/​libs/​System.IO.Compression.Native/​entrypoints.c Registers the decoder configuration entry point.
src/​libraries/​System.IO.Compression.Brotli/​tests/​CompressionStreamUnitTests.Brotli.cs Adds window-limit and large-window tests.
src/​libraries/​System.IO.Compression.Brotli/​tests/​BrotliEncoderDecoderTests.cs Updates the invalid window boundary.
src/​libraries/​System.IO.Compression.Brotli/​src/​System/​IO/​Compression/​enc/​BrotliStream.Compress.cs Validates large-window quality combinations.
src/​libraries/​System.IO.Compression.Brotli/​src/​System/​IO/​Compression/​enc/​BrotliEncoderParameter.cs Adds the large-window encoder parameter.
src/​libraries/​System.IO.Compression.Brotli/​src/​System/​IO/​Compression/​enc/​BrotliEncoder.cs Enables larger encoding windows.
src/​libraries/​System.IO.Compression.Brotli/​src/​System/​IO/​Compression/​enc/​BrotliCompressionOptions.cs Expands the supported window range.
src/​libraries/​System.IO.Compression.Brotli/​src/​System/​IO/​Compression/​dec/​BrotliStream.Decompress.cs Adds the decompression-options constructor.
src/​libraries/​System.IO.Compression.Brotli/​src/​System/​IO/​Compression/​dec/​BrotliDecompressionOptions.cs Defines configurable window limits.
src/​libraries/​System.IO.Compression.Brotli/​src/​System/​IO/​Compression/​dec/​BrotliDecoderParameter.cs Defines native decoder parameters.
src/​libraries/​System.IO.Compression.Brotli/​src/​System/​IO/​Compression/​dec/​BrotliDecoder.cs Configures decoding and validates declared windows.
src/​libraries/​System.IO.Compression.Brotli/​src/​System/​IO/​Compression/​BrotliUtils.cs Adds header parsing and quality validation.
src/​libraries/​System.IO.Compression.Brotli/​src/​System.IO.Compression.Brotli.csproj Includes the new source files.
src/​libraries/​System.IO.Compression.Brotli/​src/​Resources/​Strings.resx Adds configuration error messages.
src/​libraries/​System.IO.Compression.Brotli/​ref/​System.IO.Compression.Brotli.cs Declares the new public API surface.
src/​libraries/​Common/​src/​Interop/​Interop.Brotli.cs Adds decoder parameter interop.

🧠 Review effort: Balanced

@rzikm rzikm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM in general, see comments

/// </summary>
public sealed class BrotliDecompressionOptions
{
private int _maxWindowLog2 = BrotliUtils.WindowBits_Max;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this Max is the "safe" Max that is currently the default?

Maybe we should update the Max to be the large window Max and have a separate Default constant.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, WindowBits_Max is the safe ceiling.

I added a separate BrotliUtils.WindowBits_DefaultLarge constant, we alredy have BrotliUtils.WindowBits_MaxLarge.

I wouldn't change WindowBits_Max to be the large max, so that nothing changes on the encoder side.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Native integration and incremental decoding need human validation; continuation coverage remains incomplete, and builds and tests were not run.

1 open issue
3 resolved since last review

Review effort: Balanced

default:
// A malformed header is reported by the native decoder, so that the error matches what callers that did not
// specify any decompression options would observe.
_windowValidated = true;

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[API Proposal]: Add support for Brotli Large Window decompression

3 participants