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 — fix(netty): stop inflating a suspended HTTP/1.1 response by mkurz · Pull Request #2362 · AsyncHttpClient/async-http-client

fix(netty): stop inflating a suspended HTTP/1.1 response #2362

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.

Sign up for GitHub

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

Merged
hyperxpro merged 10 commits into AsyncHttpClient:main from mkurz:fix/demand-bounded-decompression
Nov 5, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

fix(netty): stop inflating a suspended HTTP/1.1 response #2362

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
10 commits
Select commit Hold shift + click to select a range
aa1fc74
Stop inflating a suspended HTTP/1.1 response
mkurz Nov 3, 2026
c4dc499
Do not inflate a body that is being drained
mkurz Nov 3, 2026
4ae9cca
Keep a failed decoder result on the last chunk
mkurz Nov 3, 2026
7332e64
Decompress br, zstd and snappy on demand too
mkurz Nov 3, 2026
497aad1
Document what suspension holds back
mkurz Nov 3, 2026
b8b8111
Cap inflate buffers at the part size
hyperxpro Nov 4, 2026
3af3a7f
Fall back to Netty's decoders without the pull API
hyperxpro Nov 4, 2026
7ae4ec4
Leave zstd to Netty at a zero forwarding threshold
hyperxpro Nov 4, 2026
d4e74a7
Say when br, zstd and snappy wait for demand
hyperxpro Nov 4, 2026
8838a42
Note when zstd does not wait for demand
mkurz Nov 4, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

6 changes: 6 additions & 0 deletions 6 README.md
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ AsyncHttpClient client = asyncHttpClient(config().setUseNativeTransport(true));
</dependency>
```

AHC decompresses Brotli, Zstd and Snappy response bodies on demand with Netty's pull-based `Decompressor` API, which
exists since Netty 4.2.17. If you override AHC's Netty version with an older one, these codings are still
decompressed, but as soon as they are read, so a suspended response does not hold them back. The same applies to Zstd
if the system property `io.netty.compression.defaultMaxForwardBytes` is set to zero or a negative value. gzip and
deflate are not affected.

</details>

## Quick Start
Expand Down
2 changes: 1 addition & 1 deletion 2 client/src/main/java/org/asynchttpclient/DefaultAsyncHttpClientConfig.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,7 @@ public Builder setCompressionEnforced(boolean compressionEnforced) {
}

/*
* If true (default), AHC will add a Netty HttpContentDecompressor, so compressed
* If true (default), AHC will add a content decompressor, so compressed
* content will automatically get decompressed.
*
* If set to false, response will be delivered as is received. Decompression must
Expand Down
10 changes: 10 additions & 0 deletions 10 client/src/main/java/org/asynchttpclient/ResponseBodyControl.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ public interface ResponseBodyControl {
* delivered to the {@link AsyncHandler}.
* If the final response headers already ended the response, this call has no effect on completion.
* <p>
* For an HTTP/1.1 response whose {@code Content-Encoding} AHC decompresses ({@code gzip}, {@code deflate}, and
* with Netty 4.2.17 or later {@code br}, {@code zstd} or {@code snappy}), a suspension also stops decompression:
* once it has taken effect, no further body part with content is delivered until {@link #resume()}. {@code zstd}
* waits for demand only while the system property {@code io.netty.compression.defaultMaxForwardBytes} is positive,
* as it is by default. Once the body has been decompressed in full, the final empty part, trailing headers and
* completion can still arrive while reads are suspended. If the connection closes while compressed input is held
* back, the rest of it is decompressed and delivered at once, bounded only by
* {@link AsyncHttpClientConfig#getMaxDecompressedResponseSize()}. A transfer coding, such as
* {@code Transfer-Encoding: gzip}, is decompressed as soon as it is read.
* <p>
* While reads are suspended, the read timeout is paused but the request timeout remains active. If the request
* timeout is disabled, failing to resume or cancel the response can retain its transport resources indefinitely.
* <p>
Expand Down
3 changes: 2 additions & 1 deletion 3 client/src/main/java/org/asynchttpclient/netty/channel/ChannelManager.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,8 @@ protected void initChannel(Channel ch) {
* inflates without limit — fails the exchange instead of exhausting the heap. The ceiling comes from
* {@link AsyncHttpClientConfig#getMaxDecompressedResponseSize()} (256 MiB by default, {@code 0} to
* disable); see {@link Http1ContentDecompressor} for why Netty's own {@code maxAllocation} argument
* does not provide this.
* does not provide this. While the response is suspended, it also stops decompressing a body whose
* {@code Content-Encoding} it handles.
*/
private Http1ContentDecompressor newHttpContentDecompressor() {
return new Http1ContentDecompressor(config.isKeepEncodingHeader(), config.getMaxDecompressedResponseSize());
Expand Down
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
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.