cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1036441 - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ rt/transports/http/src/main/java/org/apache/cxf/transport/http/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/
Date Thu, 18 Nov 2010 12:58:53 GMT
Author: sergeyb
Date: Thu Nov 18 12:58:52 2010
New Revision: 1036441

URL: http://svn.apache.org/viewvc?rev=1036441&view=rev
Log:
[CXF-3112] : Applying a patch on behalf of David Hagar

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java?rev=1036441&r1=1036440&r2=1036441&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
Thu Nov 18 12:58:52 2010
@@ -340,9 +340,9 @@ public class AbstractClient implements C
                     currentResponseBuilder.header(entry.getKey(), entry.getValue().get(0));
                     continue;                    
                 }
-                boolean splitPossible = !(HttpHeaders.SET_COOKIE.equalsIgnoreCase(entry.getKey())
-                                          && entry.getValue().get(0).contains(HttpHeaders.EXPIRES));
                 for (String val : entry.getValue()) {
+                    boolean splitPossible = !(HttpHeaders.SET_COOKIE.equalsIgnoreCase(entry.getKey())
+                        && val.contains(HttpHeaders.EXPIRES));
                     String[] values = splitPossible ? val.split(",") : new String[]{val};
                     for (String s : values) {
                         String theValue = s.trim();

Modified: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java?rev=1036441&r1=1036440&r2=1036441&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
(original)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
Thu Nov 18 12:58:52 2010
@@ -95,6 +95,9 @@ public abstract class AbstractHTTPDestin
     public static final String RESPONSE_COMMITED = "http.response.done";
     public static final String REQUEST_REDIRECTED = "http.request.redirected";
     public static final String CXF_CONTINUATION_MESSAGE = "cxf.continuation.message";
+    
+    private static final String HTTP_HEADERS_SETCOOKIE = "Set-Cookie";
+    
     private static final Logger LOG = LogUtils.getL7dLogger(AbstractHTTPDestination.class);
     
     private static final long serialVersionUID = 1L;
@@ -254,12 +257,20 @@ public abstract class AbstractHTTPDestin
                 String header = (String)iter.next();
                 List<?> headerList = (List<?>)headers.get(header);
                 StringBuilder sb = new StringBuilder();
-                for (int i = 0; i < headerList.size(); i++) {
-                    sb.append(headerList.get(i));
-                    if (i + 1 < headerList.size()) {
-                        sb.append(',');
+
+                if (HTTP_HEADERS_SETCOOKIE.equals(header)) {
+                    for (int i = 0; i < headerList.size(); i++) {
+                        response.addHeader(header, headerList.get(i).toString());
+                    }
+                } else {
+                    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());
             }
         } else {

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java?rev=1036441&r1=1036440&r2=1036441&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java (original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java Thu
Nov 18 12:58:52 2010
@@ -137,6 +137,14 @@ public class BookStore {
                                     .build();
     }
     
+
+    @GET
+    @Path("settwocookies")
+    public Response setTwoCookies() {
+        return Response.ok().header("Set-Cookie", "JSESSIONID=0475F7F30A26E5B0C15D69; Path=/")
+            .header("Set-Cookie", "COOKIETWO=dummy; Expires=Sat, 20-Nov-2010 19:11:32 GMT;
Path=/").build();
+    }
+    
     @GET
     @Path("propogateexception")
     public Book propogateException() throws BookNotFoundFault {

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=1036441&r1=1036440&r2=1036441&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Thu Nov 18 12:58:52 2010
@@ -92,6 +92,16 @@ public class JAXRSClientServerBookTest e
         assertEquals(1, cookies.size());
     }
     
+    @Test
+    public void testSetTwoCookieWebClient() throws Exception {
+        WebClient client = WebClient.create("http://localhost:" + PORT + "/bookstore/settwocookies");
+        Response r = client.type("*/*").get();
+        assertEquals(200, r.getStatus());
+        List<Object> cookies = r.getMetadata().get("Set-Cookie");
+        assertNotNull(cookies);
+        assertEquals(2, cookies.size());
+    }
+
     
     @Test
     public void testOnewayProxy() throws Exception {



Mime
View raw message