ffang commented on code in PR #3620:
URL: https://github.com/apache/cxf/pull/3620#discussion_r4390028852


##########
rt/transports/http/src/main/java/org/apache/cxf/transport/http/Headers.java:
##########
@@ -516,30 +521,90 @@ && isResponseBodyAvailable()) {
         boolean addHeaders = MessageUtils.getContextualBoolean(message, 
ADD_HEADERS_PROPERTY, false);
         for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
             String header = entry.getKey();
-            List<?> headerList = entry.getValue();
-
+            List<String> values = responseHeaderValues(header, 
entry.getValue(), addHeaders);
             if (addHeaders || isSingleHeader(header)) {
-                for (int i = 0; i < headerList.size(); i++) {
-                    Object headerObject = headerList.get(i);
-                    if (headerObject != null) {
-                        response.addHeader(header, 
headerObjectToString(headerObject));
-                    }
+                for (String value : values) {
+                    response.addHeader(header, value);
                 }
             } else {
-                StringBuilder sb = new StringBuilder();
-                for (int i = 0; i < headerList.size(); i++) {
-                    Object headerObject = headerList.get(i);
-                    if (headerObject != null) {
-                        sb.append(headerObjectToString(headerObject));
-                    }
-
-                    if (i + 1 < headerList.size()) {
-                        sb.append(',');
-                    }
+                response.setHeader(header, values.get(0));
+            }
+        }
+    }
+
+    static Map<String, List<String>> getResponseHeaders(Message message, 
HttpServletResponse response) {
+        Map<String, List<String>> protocol = new 
TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+        Map<String, List<String>> original = CastUtils.cast((Map<?, 
?>)message.get(Message.PROTOCOL_HEADERS));
+        if (original != null) {
+            protocol.putAll(original);
+        }
+        return new Headers(message, protocol).getResponseHeaders(response);

Review Comment:
   > After https://github.com/apache/cxf/pull/3620/changes#r4383325907, 
probably this method (and added constructor) could be removed
   
   Agreed. With the method static, the private `Headers(Message, Map)` 
constructor and the instance `getResponseHeaders` are both gone in 7e68f3b631., 
without going through `new Headers(message)`.



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