gnodet commented on code in PR #24997:
URL: https://github.com/apache/camel/pull/24997#discussion_r3631552089
##########
components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java:
##########
@@ -548,10 +553,16 @@ protected Object extractResponseBody(
return null;
}
- String contentEncoding = entity.getContentEncoding();
-
- final boolean gzipEncoding =
exchange.getProperty(Exchange.SKIP_GZIP_ENCODING, Boolean.FALSE, Boolean.class);
- if (!gzipEncoding) {
+ final boolean skipGzip =
exchange.getProperty(Exchange.SKIP_GZIP_ENCODING, Boolean.FALSE, Boolean.class);
+ final boolean httpClientDecompresses =
!getEndpoint().getComponent().isContentCompressionDisabled();
Review Comment:
**Concern: component-level flag vs. entity-level check** (high)
`httpClientDecompresses` is derived from
`!getEndpoint().getComponent().isContentCompressionDisabled()` — a
component-level flag. However, HttpClient auto-decompression can be disabled
through at least three other paths that bypass this flag:
1. Endpoint-level `httpClient.contentCompressionEnabled=false` (via
`PropertyBindingSupport`)
2. A user `httpClientConfigurer` calling
`clientBuilder.disableContentCompression()`
3. A user-supplied `HttpClient` via `setHttpClient()`
When any of these bypass the component flag, `httpClientDecompresses` would
be `true` but the body is still gzip-compressed. The code would then skip
`GZIPHelper.uncompressGzip`, delivering raw gzip bytes.
The existing code on `main` avoids this by checking
`entity.getContentEncoding()` — which reflects what HttpClient **actually did**
to the stream, regardless of how it was configured.
##########
components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java:
##########
@@ -548,10 +553,16 @@ protected Object extractResponseBody(
return null;
}
- String contentEncoding = entity.getContentEncoding();
-
- final boolean gzipEncoding =
exchange.getProperty(Exchange.SKIP_GZIP_ENCODING, Boolean.FALSE, Boolean.class);
- if (!gzipEncoding) {
+ final boolean skipGzip =
exchange.getProperty(Exchange.SKIP_GZIP_ENCODING, Boolean.FALSE, Boolean.class);
+ final boolean httpClientDecompresses =
!getEndpoint().getComponent().isContentCompressionDisabled();
+ if (!skipGzip && !httpClientDecompresses) {
+ String contentEncoding = entity.getContentEncoding();
+ if (contentEncoding == null) {
+ Header encodingHeader =
httpResponse.getFirstHeader(Exchange.CONTENT_ENCODING);
Review Comment:
**Dead code path** (medium)
This response-header fallback is unreachable in practice. This branch only
executes when `httpClientDecompresses` is `false` AND
`entity.getContentEncoding()` is `null`. But `removeStaleCompressionHeaders`
runs first (line 266), and when `entity.getContentEncoding()` is `null`, the
broadened condition `httpClientDecompresses || entity.getContentEncoding() ==
null` evaluates to `false || true = true`, so it strips the `Content-Encoding`
response header. Therefore
`httpResponse.getFirstHeader(Exchange.CONTENT_ENCODING)` will always return
`null` in this path.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]