This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new de52a2c49b02 CAMEL-24234: Strengthen gzip auto-decompression test 
coverage
de52a2c49b02 is described below

commit de52a2c49b02a39e0f701855836c7f9b8ab97d18
Author: Omar Atie <[email protected]>
AuthorDate: Wed Jul 22 22:52:56 2026 -0700

    CAMEL-24234: Strengthen gzip auto-decompression test coverage
    
    Add regression tests for HttpClient 5.6+ gzip auto-decompression
    behavior. Remove component-flag guard in favor of entity-level content
    encoding check. Consolidate assertions to AssertJ.
    
    Closes #24997
---
 .../camel/component/http/HttpCompressionTest.java  | 41 +++++++++++++++++-----
 1 file changed, 33 insertions(+), 8 deletions(-)

diff --git 
a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCompressionTest.java
 
b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCompressionTest.java
index a0127fbbd55c..88c83e7ff26d 100644
--- 
a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCompressionTest.java
+++ 
b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpCompressionTest.java
@@ -54,8 +54,7 @@ import static org.apache.camel.http.common.HttpMethods.POST;
 import static org.apache.hc.core5.http.ContentType.TEXT_PLAIN;
 import static org.apache.hc.core5.http.HttpHeaders.CONTENT_ENCODING;
 import static org.apache.hc.core5.http.HttpHeaders.CONTENT_TYPE;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.assertj.core.api.Assertions.assertThat;
 
 public class HttpCompressionTest extends BaseHttpTest {
 
@@ -94,13 +93,39 @@ public class HttpCompressionTest extends BaseHttpTest {
                     exchange1.getIn().setBody(getBody());
                 });
 
-        assertNotNull(exchange);
+        assertThat(exchange).isNotNull();
 
         Message out = exchange.getMessage();
-        assertNotNull(out);
+        assertThat(out).isNotNull();
 
         Map<String, Object> headers = out.getHeaders();
-        assertEquals(HttpStatus.SC_OK, 
headers.get(Exchange.HTTP_RESPONSE_CODE));
+        
assertThat(headers.get(Exchange.HTTP_RESPONSE_CODE)).isEqualTo(HttpStatus.SC_OK);
+        // CAMEL-24234: HttpClient 5.6+ auto-decompresses the body but no 
longer strips the stale gzip
+        // Content-Encoding header. Camel must remove it so downstream readers 
do not attempt a second
+        // decompression (which would fail with a ZipException).
+        assertThat(headers.get(Exchange.CONTENT_ENCODING)).isNull();
+
+        assertBody(out.getBody(String.class));
+    }
+
+    @Test
+    public void compressedHttpPostWithEndpointContentCompressionDisabled() {
+        // CAMEL-24234: decompression can also be disabled per-endpoint via
+        // httpClient.contentCompressionEnabled=false. HttpClient then does 
not decompress, so the raw gzip body
+        // reaches Camel with a "gzip" Content-Encoding on the entity, and 
Camel must decompress it itself.
+        Exchange exchange = template.request(
+                "http://localhost:"; + localServer.getLocalPort() + 
"/?httpClient.contentCompressionEnabled=false",
+                exchange1 -> {
+                    exchange1.getIn().setHeader(Exchange.CONTENT_TYPE, 
"text/plain");
+                    exchange1.getIn().setHeader(Exchange.CONTENT_ENCODING, 
"gzip");
+                    exchange1.getIn().setBody(getBody());
+                });
+
+        assertThat(exchange).isNotNull();
+
+        Message out = exchange.getMessage();
+        assertThat(out).isNotNull();
+        
assertThat(out.getHeader(Exchange.HTTP_RESPONSE_CODE)).isEqualTo(HttpStatus.SC_OK);
 
         assertBody(out.getBody(String.class));
     }
@@ -118,13 +143,13 @@ public class HttpCompressionTest extends BaseHttpTest {
                         exchange1.getIn().setBody(getBody());
                     });
 
-            assertNotNull(exchange);
+            assertThat(exchange).isNotNull();
 
             Message out = exchange.getMessage();
-            assertNotNull(out);
+            assertThat(out).isNotNull();
 
             Map<String, Object> headers = out.getHeaders();
-            assertEquals(HttpStatus.SC_OK, 
headers.get(Exchange.HTTP_RESPONSE_CODE));
+            
assertThat(headers.get(Exchange.HTTP_RESPONSE_CODE)).isEqualTo(HttpStatus.SC_OK);
 
             assertBody(out.getBody(String.class));
         } finally {

Reply via email to