cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1140843 - /cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
Date Tue, 28 Jun 2011 21:00:13 GMT
Author: sergeyb
Date: Tue Jun 28 21:00:13 2011
New Revision: 1140843

URL: http://svn.apache.org/viewvc?rev=1140843&view=rev
Log:
Minor update to HttpConduit to allow chunking for non-empty PUTs

Modified:
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java

Modified: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java?rev=1140843&r1=1140842&r2=1140843&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
(original)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
Tue Jun 28 21:00:13 2011
@@ -59,6 +59,7 @@ import org.apache.cxf.io.CachedOutputStr
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.ExchangeImpl;
 import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageContentsList;
 import org.apache.cxf.message.MessageImpl;
 import org.apache.cxf.message.MessageUtils;
 import org.apache.cxf.phase.PhaseInterceptorChain;
@@ -173,6 +174,9 @@ public class HTTPConduit 
      */
     private static final String SC_HTTP_CONDUIT_SUFFIX = ".http-conduit";
 
+    private static final String HTTP_POST_METHOD = "POST"; 
+    private static final String HTTP_PUT_METHOD = "PUT";
+    
     /**
      * This field holds the connection factory, which primarily is used to 
      * factor out SSL specific code from this implementation.
@@ -507,8 +511,8 @@ public class HTTPConduit 
         // DELETE does not work and empty PUTs cause misleading exceptions
         // if chunking is enabled
         // TODO : ensure chunking can be enabled for non-empty PUTs - if requested
-        if (connection.getRequestMethod().equals("POST")
-            && csPolicy.isAllowChunking()) {
+        if (csPolicy.isAllowChunking() 
+            && isChunkingSupported(message, connection.getRequestMethod())) {
             //TODO: The chunking mode be configured or at least some
             // documented client constant.
             //use -1 and allow the URL connection to pick a default value
@@ -544,6 +548,19 @@ public class HTTPConduit 
         // We are now "ready" to "send" the message. 
     }
 
+    protected boolean isChunkingSupported(Message message, String httpMethod) {
+        if (HTTP_POST_METHOD.equals(httpMethod)) { 
+            return true;
+        }
+        if (HTTP_PUT_METHOD.equals(httpMethod)) {
+            MessageContentsList objs = MessageContentsList.getContentsList(message);
+            if (objs != null && objs.size() > 0) {
+                return true;
+            }
+        }
+        return false;
+    }
+    
     protected OutputStream createOutputStream(Message message, 
                                               HttpURLConnection connection,
                                               boolean needToCacheRequest, 



Mime
View raw message