You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2014/10/08 16:30:00 UTC
[2/4] git commit: CAMEL-7896 netty http producer should close the
channel when theresponse connection header is close
CAMEL-7896 netty http producer should close the channel when theresponse connection header is close
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/08a66212
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/08a66212
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/08a66212
Branch: refs/heads/master
Commit: 08a66212f35abd4cc6d91a2f23f4451ca52f9118
Parents: 0a7acc9
Author: Willem Jiang <wi...@gmail.com>
Authored: Wed Oct 8 21:32:39 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Wed Oct 8 21:32:39 2014 +0800
----------------------------------------------------------------------
.../netty/http/handlers/HttpClientChannelHandler.java | 7 +++++++
.../camel/component/netty/handlers/ClientChannelHandler.java | 2 +-
2 files changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/08a66212/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpClientChannelHandler.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpClientChannelHandler.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpClientChannelHandler.java
index d463260..82df81c 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpClientChannelHandler.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpClientChannelHandler.java
@@ -20,6 +20,7 @@ import java.util.Map;
import org.apache.camel.Exchange;
import org.apache.camel.Message;
+import org.apache.camel.component.netty.NettyConstants;
import org.apache.camel.component.netty.handlers.ClientChannelHandler;
import org.apache.camel.component.netty.http.NettyHttpProducer;
import org.jboss.netty.buffer.ChannelBuffer;
@@ -28,6 +29,7 @@ import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.handler.codec.http.HttpChunk;
import org.jboss.netty.handler.codec.http.HttpChunkTrailer;
+import org.jboss.netty.handler.codec.http.HttpHeaders;
import org.jboss.netty.handler.codec.http.HttpResponse;
import org.jboss.netty.handler.codec.http.HttpResponseStatus;
import org.slf4j.Logger;
@@ -91,6 +93,11 @@ public class HttpClientChannelHandler extends ClientChannelHandler {
}
} else if (msg instanceof HttpResponse) {
response = (HttpResponse) msg;
+ Exchange exchange = super.getExchange(ctx);
+ if (!HttpHeaders.isKeepAlive(response)) {
+ // just want to make sure we close the channel if the keepAlive is not true
+ exchange.setProperty(NettyConstants.NETTY_CLOSE_CHANNEL_WHEN_COMPLETE, true);
+ }
if (LOG.isTraceEnabled()) {
LOG.trace("HttpResponse received: {} chunked:", response, response.isChunked());
}
http://git-wip-us.apache.org/repos/asf/camel/blob/08a66212/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java
----------------------------------------------------------------------
diff --git a/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java b/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java
index e0ddb9f..ea9d578 100644
--- a/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java
+++ b/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java
@@ -222,7 +222,7 @@ public class ClientChannelHandler extends SimpleChannelUpstreamHandler {
}
}
- private Exchange getExchange(ChannelHandlerContext ctx) {
+ protected Exchange getExchange(ChannelHandlerContext ctx) {
NettyCamelState state = producer.getState(ctx.getChannel());
return state != null ? state.getExchange() : null;
}