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

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


The following commit(s) were added to refs/heads/camel-3.7.x by this push:
     new 92a1bd0  CAMEL-16199: camel-http - Optimize headers added as request 
headers in producer
92a1bd0 is described below

commit 92a1bd0ff1bafade924d8c81d736bb34810de7c6
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Sun Feb 14 13:05:06 2021 +0100

    CAMEL-16199: camel-http - Optimize headers added as request headers in 
producer
---
 .../java/org/apache/camel/component/http/HttpProducer.java   | 12 +++++++++++-
 1 file changed, 11 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 85d3d98..24db37e 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
@@ -133,9 +133,19 @@ public class HttpProducer extends DefaultProducer {
         final TypeConverter tc = exchange.getContext().getTypeConverter();
         for (Map.Entry<String, Object> entry : in.getHeaders().entrySet()) {
             String key = entry.getKey();
-            Object headerValue = in.getHeader(key);
+            Object headerValue = entry.getValue();
 
             if (headerValue != null) {
+
+                if (headerValue instanceof String) {
+                    // optimise for string values
+                    String value = (String) headerValue;
+                    if (strategy == null || 
!strategy.applyFilterToCamelHeaders(key, value, exchange)) {
+                        httpRequest.addHeader(key, value);
+                    }
+                    continue;
+                }
+
                 // use an iterator as there can be multiple values. (must not 
use a delimiter, and allow empty values)
                 final Iterator<?> it = 
ObjectHelper.createIterator(headerValue, null, true);
 

Reply via email to