cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1239365 - in /cxf/trunk/rt/frontend/jaxrs/src: main/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProvider.java test/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProviderTest.java
Date Wed, 01 Feb 2012 22:20:30 GMT
Author: sergeyb
Date: Wed Feb  1 22:20:29 2012
New Revision: 1239365

URL: http://svn.apache.org/viewvc?rev=1239365&view=rev
Log:
Better support for wildcard media types

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

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProvider.java?rev=1239365&r1=1239364&r2=1239365&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProvider.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProvider.java
Wed Feb  1 22:20:29 2012
@@ -41,12 +41,15 @@ public class MediaTypeHeaderProvider imp
             throw new IllegalArgumentException("Media type value can not be null");
         }
         
-        if (mType.equals(MediaType.MEDIA_TYPE_WILDCARD) || mType.startsWith("*;")) {
-            return new MediaType("*", "*");
-        }
-        
         int i = mType.indexOf('/');
         if (i == -1) {
+            mType = mType.trim();
+            if (mType.startsWith(MediaType.MEDIA_TYPE_WILDCARD)) {
+                char next = mType.length() == 1 ? ' ' : mType.charAt(1);
+                if (next == ' ' || next == ';') {
+                    return new MediaType("*", "*");
+                }
+            }
             throw new IllegalArgumentException("Media type separator is missing");
         }
         

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProviderTest.java?rev=1239365&r1=1239364&r2=1239365&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProviderTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProviderTest.java
Wed Feb  1 22:20:29 2012
@@ -58,6 +58,13 @@ public class MediaTypeHeaderProviderTest
     }
     
     @Test
+    public void testShortWildcardWithParameters2() {
+        MediaType m = MediaType.valueOf("* ;q=0.2");
+        assertEquals("Media type was not parsed correctly", 
+                     m, new MediaType("*", "*"));
+    }
+    
+    @Test
     public void testBadType() {
         try {
             new MediaTypeHeaderProvider().fromString("texthtml");



Mime
View raw message