GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — HttpContentDecompressor maxAllocation is not honored for brotli-encoded content · Issue #17034 · netty/netty

HttpContentDecompressor maxAllocation is not honored for brotli-encoded content #17034

New issue
Copy link
New issue
Copy link
Closed
#17037
Closed
HttpContentDecompressor maxAllocation is not honored for brotli-encoded content#17034
#17037
Copy link

Description

@skyguard1
skyguard1
opened on Jul 2, 2026
Issue body actions

Netty version: 4.2.115
Expected behavior
HttpContentDecompressor(int maxAllocation) documents maxAllocation as "maximum size of the decompression buffer". For gzip, deflate and zstd encodings the value is routed to each decoder's output-cap parameter (ZlibDecoder.maxAllocation, ZstdDecoder.maximumAllocationSize), which correctly bounds the size of each emitted decompressed chunk.
Actual behavior
For br (brotli) encoding, HttpContentDecompressor#newContentDecoder calls:
new BrotliDecoder(maxAllocation)
The single-argument BrotliDecoder(int) constructor treats its parameter as inputBufferSize, not as the decompression output cap:

public BrotliDecoder(int inputBufferSize) {
    this(inputBufferSize == 0 ? DEFAULT_INPUT_BUFFER_SIZE : inputBufferSize,
         DEFAULT_MAX_FORWARD_BYTES);  // outputBufferSize stays at the 64KB default
}

Consequences:
A user setting a large maxAllocation (16 * 1024 * 1024) intending to allow up to 16 MiB of decompressed output actually enlarges brotli's input buffer to 16 MiB while the output cap stays pinned at 64 KiB.
A user setting a small maxAllocation (64 * 1024) does not tighten the output cap for brotli; it silently ends up equal to the default.
The "0 = unlimited" convention (used by the other decoders in the same class) cannot be expressed for brotli — 0 falls back to the 8 KiB input-buffer default.
I have a regression test that shows a 128 KiB payload with HttpContentDecompressor(64) currently emits only 2 large chunks (outputBufferSize = 64 KiB default) instead of many small chunks bounded by 64 bytes.
Steps to reproduce

// Compress 128 KiB with brotli (any compressible content), then:
EmbeddedChannel ch = new EmbeddedChannel(new HttpContentDecompressor(64));
// send response + content...
// Drain HttpContent chunks: chunk count is ~2 instead of ~2000

Full reproducer available.
Proposed fix
Two reasonable options, I can create the PR for whichever the maintainers prefer:
A. Add a factory on BrotliDecoder that mirrors the maxAllocation semantics of the other decoders and route HttpContentDecompressor through it:

public static BrotliDecoder newDecoderWithMaxAllocation(int maxAllocation) {
    return maxAllocation > 0
        ? new BrotliDecoder(DEFAULT_INPUT_BUFFER_SIZE, maxAllocation)
        : new BrotliDecoder();
}

B. Localize the fix in HttpContentDecompressor using a duplicated constant to pick the two-arg brotli constructor (keeps BrotliDecoder's API unchanged).
Option A is cleaner (single source of truth for the input-buffer default), option B is smaller (no codec-compression changes).
Additional notes
Fix is behavior-change-visible for users who currently rely on HttpContentDecompressor(int) to shape brotli's input buffer, though that reliance would already be inconsistent with the parameter's documented meaning.
Related but out of scope: HttpContentDecompressor(int) comment could clarify the "0 = unlimited" semantics.

Activity

  1. normanmaurer commented on Jul 2, 2026

    @normanmaurer
    normanmaurer
    on Jul 2, 2026
    Member
    More actions

    @skyguard1 Fix A sounds better... please create a PR

  2. chrisvest
    added a commit that references this issue on Jul 2, 2026

    Fix maxAllocation for brotli-encoded content in HttpContentDecompress…

    This issue will close once commit 0332676 is merged into the '4.2' branch.
    0332676
  3. chrisvest
    closed this as completedin #17037on Jul 2, 2026
  4. chrisvest
    added 2 commits that reference this issue on Jul 23, 2026

    Fix maxAllocation for brotli-encoded content in HttpContentDecompress… (

    This issue will close once commit b975129 is merged into the '4.2' branch.
    b975129

    Fix maxAllocation for brotli-encoded content in HttpContentDecompress… (

    This issue will close once commit ac9ec25 is merged into the '4.2' branch.
    ac9ec25
  5. normanmaurer
    added 4 commits that reference this issue on Oct 16, 2026

    Honor maxAllocation for brotli in DelegatingDecompressorFrameListener (…

    46ee86b

    Port 4.1: Honor maxAllocation for brotli in DelegatingDecompressorFra…

    b5429bf

    Port 4.1: Honor maxAllocation for brotli in DelegatingDecompressorFra…

    a894e2c

    Auto-port 5.0: Honor maxAllocation for brotli in DelegatingDecompress…

    1d30c7a
  6. lltopk
    added 2 commits that reference this issue on Oct 24, 2026

    Fix maxAllocation for brotli-encoded content in HttpContentDecompress… (

    This issue will close once commit 374eb72 is merged into the '4.2' branch.
    374eb72

    Port 4.1: Honor maxAllocation for brotli in DelegatingDecompressorFra…

    This issue will close once commit 75d417d is merged into the '4.2' branch.
    75d417d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.