camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [1/2] camel git commit: CAMEL-8072 Camel Netty4 Http Server should close the channel once it return an error message
Date Fri, 21 Nov 2014 15:06:39 GMT
Repository: camel
Updated Branches:
  refs/heads/master 6edc6649f -> 1b79de058


CAMEL-8072 Camel Netty4 Http Server should close the channel once it return an error message


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/1b79de05
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/1b79de05
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/1b79de05

Branch: refs/heads/master
Commit: 1b79de0588fdb8f488282c6a9a5471522aa7ec25
Parents: 4c1fd02
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Fri Nov 21 23:03:11 2014 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Fri Nov 21 23:03:38 2014 +0800

----------------------------------------------------------------------
 .../netty4/http/handlers/HttpServerChannelHandler.java   | 11 ++++++-----
 .../http/handlers/HttpServerMultiplexChannelHandler.java |  2 ++
 2 files changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/1b79de05/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/handlers/HttpServerChannelHandler.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/handlers/HttpServerChannelHandler.java
b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/handlers/HttpServerChannelHandler.java
index 7e72a86..cdbc999 100644
--- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/handlers/HttpServerChannelHandler.java
+++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/handlers/HttpServerChannelHandler.java
@@ -16,7 +16,6 @@
  */
 package org.apache.camel.component.netty4.http.handlers;
 
-import java.net.SocketAddress;
 import java.net.URI;
 import java.nio.channels.ClosedChannelException;
 import java.nio.charset.Charset;
@@ -26,16 +25,15 @@ import javax.security.auth.Subject;
 import javax.security.auth.login.LoginException;
 
 import io.netty.buffer.ByteBuf;
-import io.netty.channel.ChannelFutureListener;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.handler.codec.base64.Base64;
 import io.netty.handler.codec.http.DefaultHttpResponse;
 import io.netty.handler.codec.http.HttpHeaders;
 import io.netty.handler.codec.http.HttpRequest;
 import io.netty.handler.codec.http.HttpResponse;
+
 import org.apache.camel.Exchange;
 import org.apache.camel.LoggingLevel;
-import org.apache.camel.component.netty4.NettyConsumer;
 import org.apache.camel.component.netty4.NettyConverter;
 import org.apache.camel.component.netty4.NettyHelper;
 import org.apache.camel.component.netty4.handlers.ServerChannelHandler;
@@ -47,14 +45,13 @@ import org.apache.camel.util.CamelLogger;
 import org.apache.camel.util.ObjectHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import static io.netty.handler.codec.http.HttpHeaders.isKeepAlive;
+
 import static io.netty.handler.codec.http.HttpResponseStatus.BAD_REQUEST;
 import static io.netty.handler.codec.http.HttpResponseStatus.METHOD_NOT_ALLOWED;
 import static io.netty.handler.codec.http.HttpResponseStatus.OK;
 import static io.netty.handler.codec.http.HttpResponseStatus.SERVICE_UNAVAILABLE;
 import static io.netty.handler.codec.http.HttpResponseStatus.UNAUTHORIZED;
 import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1;
-
 /**
  * Netty HTTP {@link ServerChannelHandler} that handles the incoming HTTP requests and routes
  * the received message in Camel.
@@ -89,6 +86,7 @@ public class HttpServerChannelHandler extends ServerChannelHandler {
             response.headers().set(Exchange.CONTENT_TYPE, "text/plain");
             response.headers().set(Exchange.CONTENT_LENGTH, 0);
             ctx.writeAndFlush(response);
+            ctx.channel().close();
             return;
         }
 
@@ -114,6 +112,7 @@ public class HttpServerChannelHandler extends ServerChannelHandler {
             response.headers().set(Exchange.CONTENT_TYPE, "text/plain");
             response.headers().set(Exchange.CONTENT_LENGTH, 0);
             ctx.writeAndFlush(response);
+            ctx.channel().close();
             return;
         }
         if ("TRACE".equals(request.getMethod().name()) && !consumer.getEndpoint().isTraceEnabled())
{
@@ -121,6 +120,7 @@ public class HttpServerChannelHandler extends ServerChannelHandler {
             response.headers().set(Exchange.CONTENT_TYPE, "text/plain");
             response.headers().set(Exchange.CONTENT_LENGTH, 0);
             ctx.writeAndFlush(response);
+            ctx.channel().close();
             return;
         }
         // must include HOST header as required by HTTP 1.1
@@ -130,6 +130,7 @@ public class HttpServerChannelHandler extends ServerChannelHandler {
             response.headers().set(Exchange.CONTENT_TYPE, "text/plain");
             response.headers().set(Exchange.CONTENT_LENGTH, 0);
             ctx.writeAndFlush(response);
+            ctx.channel().close();
             return;
         }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/1b79de05/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/handlers/HttpServerMultiplexChannelHandler.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/handlers/HttpServerMultiplexChannelHandler.java
b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/handlers/HttpServerMultiplexChannelHandler.java
index 348641f..601d689 100644
--- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/handlers/HttpServerMultiplexChannelHandler.java
+++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/handlers/HttpServerMultiplexChannelHandler.java
@@ -122,6 +122,7 @@ public class HttpServerMultiplexChannelHandler extends SimpleChannelInboundHandl
             response.headers().set(Exchange.CONTENT_TYPE, "text/plain");
             response.headers().set(Exchange.CONTENT_LENGTH, 0);
             ctx.writeAndFlush(response);
+            ctx.close();
         }
     }
 
@@ -139,6 +140,7 @@ public class HttpServerMultiplexChannelHandler extends SimpleChannelInboundHandl
             response.headers().set(Exchange.CONTENT_TYPE, "text/plain");
             response.headers().set(Exchange.CONTENT_LENGTH, 0);
             ctx.writeAndFlush(response);
+            ctx.close();
         }
     }
 


Mime
View raw message