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

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

commit 5183d95c4f0bdf4dffab097b9c73b218c7b5d1ff
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Thu Nov 30 10:11:54 2023 -0300

    CAMEL-20163: cleanup content type handling code
---
 .../camel/component/http/HttpEntityConverter.java      | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git 
a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEntityConverter.java
 
b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEntityConverter.java
index b709dc9c928..ca882145385 100644
--- 
a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEntityConverter.java
+++ 
b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEntityConverter.java
@@ -65,10 +65,7 @@ public final class HttpEntityConverter {
         ContentType contentType = null;
         if (exchange != null) {
             contentEncoding = 
exchange.getIn().getHeader(HttpConstants.CONTENT_ENCODING, String.class);
-            String contentTypeAsString = 
ExchangeHelper.getContentType(exchange);
-            if (contentTypeAsString != null) {
-                contentType = ContentType.parse(contentTypeAsString);
-            }
+            contentType = getContentType(exchange, contentType);
         }
 
         InputStreamEntity entity;
@@ -85,6 +82,14 @@ public final class HttpEntityConverter {
         return entity;
     }
 
+    private static ContentType getContentType(Exchange exchange, ContentType 
contentType) {
+        String contentTypeAsString = ExchangeHelper.getContentType(exchange);
+        if (contentTypeAsString != null) {
+            contentType = ContentType.parse(contentTypeAsString);
+        }
+        return contentType;
+    }
+
     private static HttpEntity asHttpEntity(byte[] data, Exchange exchange) 
throws Exception {
         AbstractHttpEntity entity;
 
@@ -92,10 +97,7 @@ public final class HttpEntityConverter {
         ContentType contentType = null;
         if (exchange != null) {
             contentEncoding = 
exchange.getIn().getHeader(HttpConstants.CONTENT_ENCODING, String.class);
-            String contentTypeAsString = 
ExchangeHelper.getContentType(exchange);
-            if (contentTypeAsString != null) {
-                contentType = ContentType.parse(contentTypeAsString);
-            }
+            contentType = getContentType(exchange, contentType);
         }
 
         if (exchange != null && 
!exchange.getProperty(Exchange.SKIP_GZIP_ENCODING, Boolean.FALSE, 
Boolean.class)) {

Reply via email to