cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1525403 - in /cxf/trunk/rt/frontend/jaxrs/src: main/java/org/apache/cxf/jaxrs/impl/HttpHeadersImpl.java test/java/org/apache/cxf/jaxrs/impl/HttpHeadersImplTest.java
Date Sun, 22 Sep 2013 17:52:44 GMT
Author: sergeyb
Date: Sun Sep 22 17:52:43 2013
New Revision: 1525403

URL: http://svn.apache.org/r1525403
Log:
HttpHeadersImpl can not ignore multiple list values, not a problem on the server, problem
with Response.abortWith and filters

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpHeadersImpl.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/HttpHeadersImplTest.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpHeadersImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpHeadersImpl.java?rev=1525403&r1=1525402&r2=1525403&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpHeadersImpl.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpHeadersImpl.java
Sun Sep 22 17:52:43 2013
@@ -90,7 +90,10 @@ public class HttpHeadersImpl implements 
         if (lValues == null || lValues.isEmpty() || lValues.get(0) == null) {
             return Collections.singletonList(MediaType.WILDCARD_TYPE);
         }
-        List<MediaType> mediaTypes = JAXRSUtils.parseMediaTypes(lValues.get(0));
+        List<MediaType> mediaTypes = new LinkedList<MediaType>();
+        for (String value : lValues) {
+            mediaTypes.addAll(JAXRSUtils.parseMediaTypes(value));
+        }
         sortMediaTypesUsingQualityFactor(mediaTypes); 
         return mediaTypes;
     }
@@ -216,7 +219,11 @@ public class HttpHeadersImpl implements 
         if (HttpUtils.isDateRelatedHeader(headerName)) {
             return values;
         }
-        return getHeaderValues(headerName, values.get(0));
+        List<String> actualValues = new LinkedList<String>();
+        for (String v : values) {
+            actualValues.addAll(getHeaderValues(headerName, v));
+        }
+        return actualValues;
     }
     
     private List<String> getHeaderValues(String headerName, String originalValue) {

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/HttpHeadersImplTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/HttpHeadersImplTest.java?rev=1525403&r1=1525402&r2=1525403&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/HttpHeadersImplTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/HttpHeadersImplTest.java
Sun Sep 22 17:52:43 2013
@@ -273,6 +273,19 @@ public class HttpHeadersImplTest extends
     }
     
     @Test
+    public void testGetHeader2() throws Exception {
+        
+        Message m = new MessageImpl();
+        m.put(Message.PROTOCOL_HEADERS, createHeaders());
+        HttpHeaders h = new HttpHeadersImpl(m);
+        
+        List<String> values = h.getRequestHeader("a");
+        assertEquals(2, values.size());
+        assertEquals("1", values.get(0));
+        assertEquals("2", values.get(1));
+    }
+    
+    @Test
     public void testGetMediaTypes() throws Exception {
         
         Message m = control.createMock(Message.class);
@@ -446,7 +459,8 @@ public class HttpHeadersImplTest extends
         
     private MetadataMap<String, String> createHeaders() {
         MetadataMap<String, String> hs = new MetadataMap<String, String>();
-        hs.putSingle("Accept", "text/bar;q=0.6,text/*;q=1,application/xml");
+        hs.add("Accept", "text/bar;q=0.6");
+        hs.add("Accept", "text/*;q=1,application/xml");
         hs.putSingle("Content-Type", "*/*");
         hs.putSingle("Date", "Tue, 21 Oct 2008 17:00:00 GMT");
         hs.putSingle("Content-Length", "10");



Mime
View raw message