cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1518295 - in /cxf/trunk/rt/transports/http-hc/src: main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java test/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduitTest.java
Date Wed, 28 Aug 2013 17:35:26 GMT
Author: dkulp
Date: Wed Aug 28 17:35:26 2013
New Revision: 1518295

URL: http://svn.apache.org/r1518295
Log:
[CXF-5241] Allow disabled chunking to actually work

Modified:
    cxf/trunk/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java
    cxf/trunk/rt/transports/http-hc/src/test/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduitTest.java

Modified: cxf/trunk/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java?rev=1518295&r1=1518294&r2=1518295&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java
(original)
+++ cxf/trunk/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java
Wed Aug 28 17:35:26 2013
@@ -256,12 +256,16 @@ public class AsyncHTTPConduit extends UR
                                         int chunkThreshold, 
                                         String conduitName,
                                         URI uri) {
-            super(message, needToCacheRequest, isChunking,
-                  chunkThreshold, conduitName,
+            super(message, 
+                  needToCacheRequest,
+                  isChunking,
+                  chunkThreshold, 
+                  conduitName,
                   uri);
             csPolicy = getClient(message);
             entity = message.get(CXFHttpRequest.class);
             basicEntity = (BasicHttpEntity)entity.getEntity();
+            basicEntity.setChunked(isChunking);
             HeapByteBufferAllocator allocator = new HeapByteBufferAllocator();
             int bufSize = csPolicy.getChunkLength() > 0 ? csPolicy.getChunkLength() :
16320;
             inbuf = new SharedInputBuffer(bufSize, allocator);
@@ -310,7 +314,7 @@ public class AsyncHTTPConduit extends UR
             basicEntity.setContentLength(i);
         }
         public void thresholdReached() throws IOException {
-            basicEntity.setChunked(true);
+            basicEntity.setChunked(chunking);
         }
 
         protected void handleNoOutput() throws IOException {
@@ -373,8 +377,25 @@ public class AsyncHTTPConduit extends UR
         
         @Override
         public void close() throws IOException {
+            if (!chunking) {
+                CachedOutputStream out = (CachedOutputStream)wrappedStream;
+                this.basicEntity.setContentLength(out.size());
+                wrappedStream = null;
+                handleHeadersTrustCaching();
+                out.writeCacheTo(wrappedStream);
+            }
             super.close();
         }
+        
+        @Override
+        protected void onFirstWrite() throws IOException {
+            if (chunking) {
+                super.onFirstWrite();
+            } else {
+                wrappedStream = new CachedOutputStream();
+            }
+        }
+        
         protected void setupWrappedStream() throws IOException {
             connect(true);
             wrappedStream = new OutputStream() {

Modified: cxf/trunk/rt/transports/http-hc/src/test/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduitTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-hc/src/test/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduitTest.java?rev=1518295&r1=1518294&r2=1518295&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-hc/src/test/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduitTest.java
(original)
+++ cxf/trunk/rt/transports/http-hc/src/test/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduitTest.java
Wed Aug 28 17:35:26 2013
@@ -36,6 +36,7 @@ import org.apache.cxf.frontend.ClientPro
 import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.transport.http.HTTPConduit;
+import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
 import org.apache.hello_world_soap_http.Greeter;
 import org.apache.hello_world_soap_http.SOAPService;
 import org.apache.hello_world_soap_http.types.GreetMeLaterResponse;
@@ -160,6 +161,11 @@ public class AsyncHTTPConduitTest extend
     public void testCall() throws Exception {
         updateAddressPort(g, PORT);
         assertEquals("Hello " + request, g.greetMe(request));
+        HTTPConduit c = (HTTPConduit)ClientProxy.getClient(g).getConduit();
+        HTTPClientPolicy cp = new HTTPClientPolicy();
+        cp.setAllowChunking(false);
+        c.setClient(cp);
+        assertEquals("Hello " + request, g.greetMe(request));
     }
     @Test
     public void testCallAsync() throws Exception {



Mime
View raw message