cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1151236 - in /cxf/branches/2.4.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/ rt/transports/http/src/main/java/org/apache/cxf/transport/http/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/
Date Tue, 26 Jul 2011 20:40:18 GMT
Author: sergeyb
Date: Tue Jul 26 20:40:17 2011
New Revision: 1151236

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

........
  r1151235 | sergeyb | 2011-07-26 21:38:35 +0100 (Tue, 26 Jul 2011) | 1 line
  
  [CXF-3667] Drop Content-Type if Content-Length is available and set to 0
........

Modified:
    cxf/branches/2.4.x-fixes/   (props changed)
    cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
    cxf/branches/2.4.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Headers.java
    cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java

Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jul 26 20:40:17 2011
@@ -1 +1 @@
-/cxf/trunk:1151152,1151228
+/cxf/trunk:1151152,1151228,1151235

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

Modified: cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java?rev=1151236&r1=1151235&r2=1151236&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
Tue Jul 26 20:40:17 2011
@@ -187,6 +187,7 @@ public class JAXRSOutInterceptor extends
         
         setResponseDate(responseHeaders, firstTry);
         if (isResponseNull(responseObj)) {
+            responseHeaders.putSingle("Content-Length", "0");
             return;
         }
         

Modified: cxf/branches/2.4.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Headers.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Headers.java?rev=1151236&r1=1151235&r2=1151236&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Headers.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Headers.java
Tue Jul 26 20:40:17 2011
@@ -358,6 +358,23 @@ public class Headers {
         }
     }
     
+    // Assumes that response body is not available only
+    // if Content-Length is available and set to 0
+    private boolean isResponseBodyAvailable() {
+        List<String> ctLen = headers.get("Content-Length");
+        if (ctLen == null || ctLen.size() != 1) {
+            return true;
+        }
+        try {
+            if (Integer.valueOf(ctLen.get(0)) == 0) {
+                return false;
+            }
+        } catch (NumberFormatException ex) {
+            // ignore
+        }
+        return true;
+    }
+    
     /**
      * Copy the response headers into the response.
      * 
@@ -367,7 +384,8 @@ public class Headers {
     protected void copyToResponse(HttpServletResponse response) {
         String contentType = getContentTypeFromMessage();
  
-        if (!headers.containsKey(Message.CONTENT_TYPE) && contentType != null) {
+        if (!headers.containsKey(Message.CONTENT_TYPE) && contentType != null 
+            && isResponseBodyAvailable()) {
             response.setContentType(contentType);
         }
 

Modified: cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=1151236&r1=1151235&r2=1151236&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
(original)
+++ cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Tue Jul 26 20:40:17 2011
@@ -591,8 +591,10 @@ public class JAXRSClientServerBookTest e
         WebClient wc = 
             WebClient.create("http://localhost:" 
                              + PORT + "/bookstore/emptypost");
+        WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(10000000L);
         Response response = wc.post(null);
         assertEquals(204, response.getStatus());
+        assertNull(response.getMetadata().getFirst("Content-Type"));
     }
     
     @Test



Mime
View raw message