davsclaus commented on code in PR #27690:
URL: https://github.com/apache/camel/pull/27690#discussion_r4245541749


##########
components/camel-knative/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpConsumer.java:
##########
@@ -331,14 +333,22 @@ private HttpServerResponse 
toHttpResponse(HttpServerRequest request, Message mes
             for (Map.Entry<String, Object> entry : 
message.getHeaders().entrySet()) {
                 final String key = entry.getKey();
                 final Object value = entry.getValue();
-
-                for (Object it : 
org.apache.camel.support.ObjectHelper.createIterable(value, null)) {
-                    String headerValue = tc.convertTo(String.class, it);
-                    if (headerValue == null) {
-                        continue;
-                    }
-                    if (!headerFilterStrategy.applyFilterToCamelHeaders(key, 
headerValue, message.getExchange())) {
-                        response.putHeader(key, headerValue);
+                if (value instanceof Iterable || value instanceof Object[]) {
+                    // a collection or an object array has one value per 
element (must not use a delimiter, and allow
+                    // empty values); any other value, also a byte[] or 
another primitive array, is a single value
+                    final Iterator<?> it = 
org.apache.camel.support.ObjectHelper.createIterator(value, null, true);
+                    HttpUtil.applyHeader(headerFilterStrategy, 
message.getExchange(), it, tc, key, (multiValues, prev) -> {
+                        if (multiValues != null) {
+                            // putHeader replaces the header, so all the 
values must be given at once
+                            response.putHeader(key, multiValues);
+                        } else if (prev != null) {
+                            response.putHeader(key, prev);
+                        }
+                    });
+                } else if 
(!headerFilterStrategy.applyFilterToCamelHeaders(key, value, 
message.getExchange())) {

Review Comment:
   Behaviour change in the reply that is not documented: before, 
`createIterable(value, null)` skipped blank String values, and now a blank 
header is sent as an empty header line. A `Map` value used to be iterated per 
entry and is now sent as one `{k=v}` line. Either keep the old blank check or 
mention it in the upgrade guide.



##########
components/camel-knative/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpProducer.java:
##########
@@ -102,9 +105,26 @@ public boolean process(Exchange exchange, AsyncCallback 
callback) {
             headers.add(HttpHeaders.CONTENT_TYPE, contentType);
         }
 
+        final TypeConverter tc = exchange.getContext().getTypeConverter();
         for (Map.Entry<String, Object> entry : 
exchange.getMessage().getHeaders().entrySet()) {
-            if 
(!headerFilterStrategy.applyFilterToCamelHeaders(entry.getKey(), 
entry.getValue(), exchange)) {
-                headers.add(entry.getKey(), entry.getValue().toString());
+            final String key = entry.getKey();
+            final Object value = entry.getValue();
+            if (value instanceof Iterable || value instanceof Object[]) {

Review Comment:
   Same as in #27689: `instanceof Iterable` also matches Vert.x `JsonObject` / 
`JsonArray`, which were sent as encoded JSON before and are now split into 
entries. `instanceof Collection || instanceof Object[]` avoids that.



-- 
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]

Reply via email to