cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1471378 - in /cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs: interceptor/JAXRSInInterceptor.java utils/JAXRSUtils.java
Date Wed, 24 Apr 2013 12:05:51 GMT
Author: sergeyb
Date: Wed Apr 24 12:05:50 2013
New Revision: 1471378

URL: http://svn.apache.org/r1471378
Log:
[CXF-4984] More updates

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java?rev=1471378&r1=1471377&r2=1471378&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
Wed Apr 24 12:05:50 2013
@@ -20,12 +20,14 @@
 package org.apache.cxf.jaxrs.interceptor;
 
 import java.io.IOException;
+import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.ResourceBundle;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import javax.ws.rs.HttpMethod;
 import javax.ws.rs.InternalServerErrorException;
 import javax.ws.rs.NotAcceptableException;
 import javax.ws.rs.NotFoundException;
@@ -36,6 +38,7 @@ import javax.ws.rs.core.Response;
 
 import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.jaxrs.impl.MetadataMap;
 import org.apache.cxf.jaxrs.impl.RequestPreprocessor;
 import org.apache.cxf.jaxrs.impl.UriInfoImpl;
@@ -120,10 +123,19 @@ public class JAXRSInInterceptor extends 
         if (JAXRSUtils.runContainerRequestFilters(providerFactory, message, true, null, false))
{
             return;
         }
+        String httpMethod = HttpUtils.getProtocolHeader(message, Message.HTTP_REQUEST_METHOD,
"POST");
         
         String requestContentType = (String)message.get(Message.CONTENT_TYPE);
         if (requestContentType == null) {
-            requestContentType = MediaType.WILDCARD;
+            boolean getMethod = HttpMethod.GET.equals(httpMethod);
+            requestContentType = getMethod ? MediaType.WILDCARD : MediaType.APPLICATION_OCTET_STREAM;
+            message.put(Message.CONTENT_TYPE, requestContentType);
+            if (!getMethod) {
+                Map<String, List<String>> headers = CastUtils.cast((Map<?,
?>)message.get(Message.PROTOCOL_HEADERS));
+                if (headers != null) {
+                    headers.put(Message.CONTENT_TYPE, Collections.singletonList(requestContentType));
   
+                }
+            }
         }
         
         String rawPath = HttpUtils.getPathToMatch(message, true);
@@ -158,7 +170,6 @@ public class JAXRSInInterceptor extends 
             throw new NotFoundException(resp);
         }
 
-        String httpMethod = HttpUtils.getProtocolHeader(message, Message.HTTP_REQUEST_METHOD,
"POST");
         MultivaluedMap<String, String> matchedValues = new MetadataMap<String, String>();
         
         

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java?rev=1471378&r1=1471377&r2=1471378&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java Wed
Apr 24 12:05:50 2013
@@ -401,7 +401,7 @@ public final class JAXRSUtils {
         
         MediaType requestType;
         try {
-            requestType = getMethod ? MediaType.APPLICATION_OCTET_STREAM_TYPE : toMediaType(requestContentType);
+            requestType = toMediaType(requestContentType);
         } catch (IllegalArgumentException ex) {
             throw new NotSupportedException(ex);
         }
@@ -823,11 +823,7 @@ public final class JAXRSUtils {
             String contentType = (String)message.get(Message.CONTENT_TYPE);
 
             if (contentType == null) {
-                org.apache.cxf.common.i18n.Message errorMsg = 
-                    new org.apache.cxf.common.i18n.Message("NO_CONTENT_TYPE_SPECIFIED", 
-                                                           BUNDLE, 
-                                                           ori.getHttpMethod());
-                LOG.fine(errorMsg.toString());
+                // for tests only
                 contentType = MediaType.WILDCARD;
             }
 



Mime
View raw message