Skip to content

Fix Http2 server - compressed and uncompressed responses over same connection#6069

Merged
vietj merged 1 commit intoeclipse-vertx:masterfrom
zyclonite:fix/http2_compression
Apr 21, 2026
Merged

Fix Http2 server - compressed and uncompressed responses over same connection#6069
vietj merged 1 commit intoeclipse-vertx:masterfrom
zyclonite:fix/http2_compression

Conversation

@zyclonite
Copy link
Copy Markdown
Contributor

@zyclonite zyclonite commented Apr 16, 2026

Motivation:

This PR fixes #5896 by allowing multiple concurrent HTTP/2 streams on the same connection to independently select their encoder (compressed vs. plain) based on their own headers, without interfering with each other.
This problem surfaced when different browsers connect via a HTTP/2 enabled proxy that multiplexes multiple connections into one single HTTP/2 connection. If one client supports compression and another not, the server sends the proper headers but the wrong payload, triggering decompression errors.

Changes:

Refactored VertxCompressorHttp2ConnectionEncoder to store the selected encoder (compressed or plain) as a property on each Http2Stream, rather than using a mutable connection-wide delegate field.

Added testResponseCompressionEnabledMixedStreams in Http2ServerTest which verifies that each stream independently receives the correct compression behavior.

Results:

Each HTTP/2 stream now independently selects its encoder at header-write time, and subsequent data frames use that same encoder. Concurrent streams with different compression requirements on the same connection are handled correctly. Stream property lifecycle is managed automatically by Netty when streams are closed.

@vietj
Copy link
Copy Markdown
Member

vietj commented Apr 17, 2026

rebased since I've done fixes to improve test passing more consistently

@zyclonite
Copy link
Copy Markdown
Contributor Author

thank you, with a small assertion fix it was successful

@zyclonite zyclonite marked this pull request as ready for review April 20, 2026 14:27
@zyclonite
Copy link
Copy Markdown
Contributor Author

@vietj based on the last commit (4736fbf) the fix looks way better now

what do you think?

@vietj
Copy link
Copy Markdown
Member

vietj commented Apr 20, 2026

can you make a single commit and explain what has changed and how it solves the issue ?

basically I'm looking for a commit

Motivation:

Changes:

Results:

that helps reviewing :-)

@zyclonite zyclonite force-pushed the fix/http2_compression branch from 4736fbf to 9f3ea51 Compare April 20, 2026 17:31
@zyclonite zyclonite force-pushed the fix/http2_compression branch from 9f3ea51 to 7780a0d Compare April 20, 2026 17:36
@zyclonite
Copy link
Copy Markdown
Contributor Author

fixed the PR based on your input

@vietj vietj added this to the 5.1.0 milestone Apr 21, 2026
@vietj
Copy link
Copy Markdown
Member

vietj commented Apr 21, 2026

excellent @zyclonite

@vietj vietj merged commit 7b530f9 into eclipse-vertx:master Apr 21, 2026
7 checks passed
@vietj vietj added the bug label Apr 21, 2026
@vietj
Copy link
Copy Markdown
Member

vietj commented Apr 21, 2026

can you backport this PR @zyclonite ?

@zyclonite
Copy link
Copy Markdown
Contributor Author

sure, onto the 5.0 branch - in 4.x this was not an issue

@zyclonite
Copy link
Copy Markdown
Contributor Author

@vietj that's the backport PR #6080

@zyclonite zyclonite deleted the fix/http2_compression branch April 21, 2026 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Http2 server - compressed and uncompressed responses over same connection

2 participants