You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2023/10/25 09:04:55 UTC

[camel] branch camel-4.0.x updated: [CAMEL-20037] camel-http builds StringEntity with wrong contentEncoding (#11828)

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

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


The following commit(s) were added to refs/heads/camel-4.0.x by this push:
     new fddd6f58a1a [CAMEL-20037] camel-http builds StringEntity with wrong contentEncoding (#11828)
fddd6f58a1a is described below

commit fddd6f58a1a16a4cfdda9f50e31071db64dfc6d1
Author: Simo Kivimäki <85...@users.noreply.github.com>
AuthorDate: Wed Oct 25 12:02:33 2023 +0300

    [CAMEL-20037] camel-http builds StringEntity with wrong contentEncoding (#11828)
    
    * CAMEL-20037: camel-http must not create StringEntity having charset as content encoding
    
    * camel-http autoformatted code
---
 .../src/main/java/org/apache/camel/component/http/HttpProducer.java     | 2 +-
 .../camel/component/http/HttpProducerContentTypeWithCharsetTest.java    | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
index da9c7e0d034..b4974b1c5e7 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
@@ -778,7 +778,7 @@ public class HttpProducer extends DefaultProducer {
                             contentType = ContentType.parse(contentType + ";charset=" + charset);
                         }
 
-                        answer = new StringEntity(content, contentType, charset, false);
+                        answer = new StringEntity(content, contentType, false);
                     }
 
                     // fallback as input stream
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerContentTypeWithCharsetTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerContentTypeWithCharsetTest.java
index eef598225ef..7e2f05a2745 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerContentTypeWithCharsetTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerContentTypeWithCharsetTest.java
@@ -51,6 +51,7 @@ public class HttpProducerContentTypeWithCharsetTest extends BaseHttpTest {
                     String contentType = request.getFirstHeader(Exchange.CONTENT_TYPE).getValue();
 
                     assertEquals(CONTENT_TYPE_WITH_CHARSET.replace(";", "; "), contentType);
+                    assertFalse(request.containsHeader(Exchange.CONTENT_ENCODING));
 
                     response.setEntity(new StringEntity(contentType, StandardCharsets.US_ASCII));
                     response.setCode(HttpStatus.SC_OK);