cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-6970] Using HttpServletRequest.setHeader if 'addHeaders' option is not enabled
Date Thu, 14 Jul 2016 13:03:42 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes c5996a421 -> 61477f36d


[CXF-6970] Using HttpServletRequest.setHeader if 'addHeaders' option is not enabled


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/61477f36
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/61477f36
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/61477f36

Branch: refs/heads/3.0.x-fixes
Commit: 61477f36d72b7c51c7c825342edaeb8cd2e32eb1
Parents: c5996a4
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Thu Jul 14 16:00:54 2016 +0300
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Thu Jul 14 16:03:25 2016 +0300

----------------------------------------------------------------------
 .../org/apache/cxf/transport/http/Headers.java    |  2 +-
 .../jaxrs/JAXRS20ClientServerBookTest.java        | 18 +++++++++++++++---
 2 files changed, 16 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/61477f36/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Headers.java
----------------------------------------------------------------------
diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Headers.java b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Headers.java
index 5f61dd2..ec642c0 100644
--- a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Headers.java
+++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Headers.java
@@ -492,7 +492,7 @@ public class Headers {
                         sb.append(',');
                     }
                 }
-                response.addHeader(header, sb.toString());
+                response.setHeader(header, sb.toString());
             }
 
             

http://git-wip-us.apache.org/repos/asf/cxf/blob/61477f36/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
index d504867..a40dda6 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
@@ -66,6 +66,7 @@ import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 import org.apache.cxf.systest.jaxrs.BookStore.BookInfo;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 
+import org.junit.Assert;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -649,7 +650,7 @@ public class JAXRS20ClientServerBookTest extends AbstractBusClientServerTestBase
         String address = "http://localhost:" + PORT + "/bookstores";
         List<Object> providers = new ArrayList<Object>();
         providers.add(new ClientCacheRequestFilter());
-        providers.add(new ClientHeaderResponseFilter());
+        providers.add(new ClientHeaderResponseFilter(true));
         WebClient wc = WebClient.create(address, providers);
         Book theBook = new Book("Echo", 123L);
         Response r = wc.post(theBook);
@@ -823,16 +824,27 @@ public class JAXRS20ClientServerBookTest extends AbstractBusClientServerTestBase
     }
     
     private static class ClientHeaderResponseFilter implements ClientResponseFilter {
-
+        private boolean local;
+        ClientHeaderResponseFilter() {
+            
+        }
+        ClientHeaderResponseFilter(boolean local) {
+            this.local = local;
+        }
         @Override
         public void filter(ClientRequestContext reqContext, 
                            ClientResponseContext respContext) throws IOException {
-            respContext.getHeaders().putSingle(HttpHeaders.LOCATION, "http://localhost/redirect");
+            MultivaluedMap<String, String> headers = respContext.getHeaders();
+            if (!local) {
+                Assert.assertEquals(1, headers.get("Date").size());
+            }
+            headers.putSingle(HttpHeaders.LOCATION, "http://localhost/redirect");
             
         }
         
     }
     
+    
     public static class ClientReaderInterceptor implements ReaderInterceptor {
 
         @Override


Mime
View raw message