cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1154246 - /cxf/branches/2.3.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
Date Fri, 05 Aug 2011 14:46:03 GMT
Author: sergeyb
Date: Fri Aug  5 14:46:03 2011
New Revision: 1154246

URL: http://svn.apache.org/viewvc?rev=1154246&view=rev
Log:
[CXF-3714] Adding property to customize the way http headers can be added

Modified:
    cxf/branches/2.3.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java

Modified: cxf/branches/2.3.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java?rev=1154246&r1=1154245&r2=1154246&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
Fri Aug  5 14:46:03 2011
@@ -98,7 +98,7 @@ public abstract class AbstractHTTPDestin
     public static final String CXF_ASYNC_CONTEXT = "cxf.async.context";
     
     private static final String HTTP_HEADERS_SETCOOKIE = "Set-Cookie";
-    
+    private static final String ADD_HEADERS_PROPERTY = "org.apache.cxf.http.add-headers";
   
     private static final Logger LOG = LogUtils.getL7dLogger(AbstractHTTPDestination.class);
     
     protected final Bus bus;
@@ -254,26 +254,27 @@ public abstract class AbstractHTTPDestin
             if (!headers.containsKey(Message.CONTENT_TYPE) && ct != null) {
                 response.setContentType(ct);
             }
-            
+            boolean addHeaders = MessageUtils.isTrue(
+                    message.getContextualProperty(ADD_HEADERS_PROPERTY));
             for (Iterator<?> iter = headers.keySet().iterator(); iter.hasNext();) {
                 String header = (String)iter.next();
                 List<?> headerList = (List<?>)headers.get(header);
-                StringBuilder sb = new StringBuilder();
-
-                if (HTTP_HEADERS_SETCOOKIE.equals(header)) {
+                
+                if (addHeaders || HTTP_HEADERS_SETCOOKIE.equals(header)) {
                     for (int i = 0; i < headerList.size(); i++) {
                         response.addHeader(header, headerList.get(i).toString());
                     }
                 } else {
+                    StringBuilder sb = new StringBuilder();
                     for (int i = 0; i < headerList.size(); i++) {
                         sb.append(headerList.get(i));
                         if (i + 1 < headerList.size()) {
                             sb.append(',');
                         }
                     }
+                    response.addHeader(header, sb.toString());
                 }
-
-                response.addHeader(header, sb.toString());
+                
             }
         } else {
             response.setContentType(ct);



Mime
View raw message