You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2011/06/29 10:07:14 UTC
svn commit: r1140990 - in /cxf/branches/2.4.x-fixes: ./
rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
Author: sergeyb
Date: Wed Jun 29 08:07:13 2011
New Revision: 1140990
URL: http://svn.apache.org/viewvc?rev=1140990&view=rev
Log:
Merged revisions 1140843 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r1140843 | sergeyb | 2011-06-28 22:00:13 +0100 (Tue, 28 Jun 2011) | 1 line
Minor update to HttpConduit to allow chunking for non-empty PUTs
........
Modified:
cxf/branches/2.4.x-fixes/ (props changed)
cxf/branches/2.4.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
svn:mergeinfo = /cxf/trunk:1140843
Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: cxf/branches/2.4.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java?rev=1140990&r1=1140989&r2=1140990&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java (original)
+++ cxf/branches/2.4.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java Wed Jun 29 08:07: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,