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:02:33 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes 4e0c1514f -> 457726a6a


[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/457726a6
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/457726a6
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/457726a6

Branch: refs/heads/3.1.x-fixes
Commit: 457726a6a976909fafe83b9c168c345387e378ab
Parents: 4e0c151
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:02:15 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/457726a6/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 51d156b..a94d11e 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
@@ -507,7 +507,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/457726a6/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 2ac8f9b..2d5773b 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