cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r900188 - in /cxf/branches/2.2.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/ rt/frontend/jaxrs/src/te...
Date Sun, 17 Jan 2010 18:37:37 GMT
Author: sergeyb
Date: Sun Jan 17 18:37:36 2010
New Revision: 900188

URL: http://svn.apache.org/viewvc?rev=900188&view=rev
Log:
Merged revisions 900181 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r900181 | sergeyb | 2010-01-17 18:28:41 +0000 (Sun, 17 Jan 2010) | 1 line
  
  JAXRS : ensuring multiple Cookie headers are processed
........

Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpHeadersImpl.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
    cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
    cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
    svn:mergeinfo = /cxf/trunk:900181

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpHeadersImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpHeadersImpl.java?rev=900188&r1=900187&r2=900188&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpHeadersImpl.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpHeadersImpl.java
Sun Jan 17 18:37:36 2010
@@ -82,11 +82,21 @@
     }
 
     public Map<String, Cookie> getCookies() {
-        List<String> cs = getListValues(HttpHeaders.COOKIE);
-        Map<String, Cookie> cl = new HashMap<String, Cookie>(); 
-        for (String c : cs) {
-            Cookie cookie = Cookie.valueOf(c);
-            cl.put(cookie.getName(), cookie);
+        List<String> values = headers.get(HttpHeaders.COOKIE);
+        if (values == null || values.isEmpty()) {
+            return Collections.emptyMap();
+        }
+        
+        Map<String, Cookie> cl = new HashMap<String, Cookie>();
+        for (String value : values) {
+            if (value == null) {
+                continue;
+            }
+            List<String> cs = getHeaderValues(HttpHeaders.COOKIE, value);
+            for (String c : cs) {
+                Cookie cookie = Cookie.valueOf(c);
+                cl.put(cookie.getName(), cookie);
+            }
         }
         return cl;
     }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java?rev=900188&r1=900187&r2=900188&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
Sun Jan 17 18:37:36 2010
@@ -744,22 +744,15 @@
 
     private static Object processCookieParam(Message m, String cookieName, 
                               Class<?> pClass, Type genericType, String defaultValue)
{
-        List<String> values = new HttpHeadersImpl(m).getRequestHeader(HttpHeaders.COOKIE);
-        String theValue = null;
-        for (String s : values) {
-            if (s.contains(cookieName + "=")) {
-                theValue = s;
-                break;
-            }
-        }
-        if (theValue == null && defaultValue != null) {
-            theValue = cookieName + '=' + defaultValue;
+        Cookie c = new HttpHeadersImpl(m).getCookies().get(cookieName);
+        
+        if (c == null && defaultValue != null) {
+            c = Cookie.valueOf(cookieName + '=' + defaultValue);
         }
-        if (theValue == null) {
+        if (c == null) {
             return null;
         }
         
-        Cookie c = Cookie.valueOf(theValue);
         if (pClass.isAssignableFrom(Cookie.class)) {
             return c;
         }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java?rev=900188&r1=900187&r2=900188&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
Sun Jan 17 18:37:36 2010
@@ -41,6 +41,7 @@
 import javax.ws.rs.Produces;
 import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Cookie;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.PathSegment;
 import javax.ws.rs.core.Request;
@@ -333,7 +334,8 @@
     }
     
     public void testMultipleCookieParam(@CookieParam("c1") String c1,
-                                        @CookieParam("c2") String c2) {
+                                        @CookieParam("c2") String c2,
+                                        @CookieParam("c3") Cookie c3) {
         // complete
     }
     

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java?rev=900188&r1=900187&r2=900188&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
Sun Jan 17 18:37:36 2010
@@ -33,6 +33,7 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Cookie;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
@@ -559,18 +560,20 @@
     
     @Test
     public void testMultipleCookieParameters() throws Exception {
-        Class[] argType = {String.class, String.class};
+        Class[] argType = {String.class, String.class, Cookie.class};
         Method m = Customer.class.getMethod("testMultipleCookieParam", argType);
         MessageImpl messageImpl = new MessageImpl();
         MultivaluedMap<String, String> headers = new MetadataMap<String, String>();
-        headers.add("Cookie", "c1=c1Value, c2=c2Value, c3=c3Value");
+        headers.add("Cookie", "c1=c1Value, c2=c2Value");
+        headers.add("Cookie", "c3=c3Value");
         messageImpl.put(Message.PROTOCOL_HEADERS, headers);
         List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,
null),
                                                            null, 
                                                            messageImpl);
-        assertEquals(params.size(), 2);
+        assertEquals(params.size(), 3);
         assertEquals("c1Value", params.get(0));
         assertEquals("c2Value", params.get(1));
+        assertEquals("c3Value", ((Cookie)params.get(2)).getValue());
     }
     
     @Test

Modified: cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java?rev=900188&r1=900187&r2=900188&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
(original)
+++ cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
Sun Jan 17 18:37:36 2010
@@ -49,6 +49,7 @@
 import javax.ws.rs.QueryParam;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Cookie;
 import javax.ws.rs.core.GenericEntity;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
@@ -238,7 +239,13 @@
             || !"da".equals(locales.get(1).getLanguage())) {
             throw new WebApplicationException();
         }
-        
+        Map<String, Cookie> cookies = httpHeaders.getCookies();
+        if (cookies.size() != 3
+            || !cookies.containsKey("a")
+            || !cookies.containsKey("c")
+            || !cookies.containsKey("e")) {
+            throw new WebApplicationException();
+        }
         return doGetBook(ids.get(0) + ids.get(1) + ids.get(2));
     }
     

Modified: cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=900188&r1=900187&r2=900188&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
(original)
+++ cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Sun Jan 17 18:37:36 2010
@@ -1055,6 +1055,8 @@
                                int expectedStatus) throws Exception {
         GetMethod get = new GetMethod(address);
         get.setRequestHeader("Accept", acceptType);
+        get.addRequestHeader("Cookie", "a=b,c=d");
+        get.addRequestHeader("Cookie", "e=f");
         get.setRequestHeader("Accept-Language", "da;q=0.8,en");
         get.setRequestHeader("Book", "1,2,3");
         HttpClient httpClient = new HttpClient();



Mime
View raw message