Skip to content

Stop appending the compression buffer's unused capacity to the request body - #1342

Open
adwsingh wants to merge 1 commit into
mainfrom
adwsingh/gzip-compressed-body-padding
Open

Stop appending the compression buffer's unused capacity to the request body#1342
adwsingh wants to merge 1 commit into
mainfrom
adwsingh/gzip-compressed-body-padding

Conversation

@adwsingh

Copy link
Copy Markdown
Contributor

What behavior changes?

Stops appending the compression buffer's unused capacity to the request body

Why is this change needed?

Gzip.compress built the compressed body in a ByteBufferOutputStream and then handed the stream's
backing array to DataStream.ofBytes. That array is grown by doubling, so its length is the buffer's
capacity rather than the number of bytes written, and ofBytes(byte[]) wraps the whole thing: every
compressed request carried the unused capacity as trailing zeros appended to the gzip stream. For
small bodies that was 7 to 20 bytes on the wire, and only zero when the byte count happened to land
exactly on a capacity boundary. Passing the ByteBuffer instead uses the count as the limit.

How was this validated?

List tests added, benchmarks run, or manual verification performed.

What should reviewers focus on?

Point reviewers to the files or sections that contain the interesting logic.

Additional Links

Related issues, design docs, or prior art.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@adwsingh
adwsingh marked this pull request as ready for review August 30, 2026 05:04
@adwsingh
adwsingh requested a review from mtdowling August 30, 2026 05:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants