Author: dkulp
Date: Wed Aug 28 20:21:11 2013
New Revision: 1518357
URL: http://svn.apache.org/r1518357
Log:
Merged revisions 1518295 via git cherry-pick from
https://svn.apache.org/repos/asf/cxf/trunk
........
r1518295 | dkulp | 2013-08-28 13:35:26 -0400 (Wed, 28 Aug 2013) | 2 lines
[CXF-5241] Allow disabled chunking to actually work
........
Modified:
cxf/branches/2.7.x-fixes/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java
cxf/branches/2.7.x-fixes/rt/transports/http-hc/src/test/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduitTest.java
Modified:
cxf/branches/2.7.x-fixes/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java?rev=1518357&r1=1518356&r2=1518357&view=diff
==============================================================================
---
cxf/branches/2.7.x-fixes/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java
(original)
+++
cxf/branches/2.7.x-fixes/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java
Wed Aug 28 20:21:11 2013
@@ -250,12 +250,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);
@@ -304,7 +308,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 {
@@ -367,8 +371,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/branches/2.7.x-fixes/rt/transports/http-hc/src/test/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduitTest.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/transports/http-hc/src/test/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduitTest.java?rev=1518357&r1=1518356&r2=1518357&view=diff
==============================================================================
---
cxf/branches/2.7.x-fixes/rt/transports/http-hc/src/test/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduitTest.java
(original)
+++
cxf/branches/2.7.x-fixes/rt/transports/http-hc/src/test/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduitTest.java
Wed Aug 28 20:21:11 2013
@@ -35,6 +35,7 @@ import org.apache.cxf.continuations.Cont
import org.apache.cxf.frontend.ClientProxy;
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;
@@ -136,6 +137,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 {