Skip to content

clear response body length after gzip/deflate decode#3445

Open
alhudz wants to merge 1 commit into
OpenFeign:masterfrom
alhudz:decompressed-body-length
Open

clear response body length after gzip/deflate decode#3445
alhudz wants to merge 1 commit into
OpenFeign:masterfrom
alhudz:decompressed-body-length

Conversation

@alhudz

@alhudz alhudz commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Repro: return a response with Content-Encoding: gzip (or deflate) and a Content-Length (the compressed size); response.body().length() then reports that compressed length even though feign has already decompressed the body.
Cause: Http2Client.toFeignResponse and DefaultClient.convertResponse wrap the stream in GZIPInputStream/InflaterInputStream but keep the on-the-wire Content-Length, so the stale value no longer matches the readable body and still gates the MAX_RESPONSE_BUFFER_SIZE check in InvocationContext.disconnectResponseBodyIfNeeded that decides whether to buffer the whole body into a byte[].
Fix: report the length as null once a decompressing wrapper is applied, since the decompressed length is unknown per the Body.length() contract. The other clients leave decompression to their underlying library, so only these two build a Response from a manually decompressed stream.

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.

1 participant