camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1477565 - /camel/trunk/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/
Date Tue, 30 Apr 2013 11:29:18 GMT
Author: davsclaus
Date: Tue Apr 30 11:29:18 2013
New Revision: 1477565

URL: http://svn.apache.org/r1477565
Log:
CAMEL-6327: More work on new camel-netty-http component.

Modified:
    camel/trunk/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerChannelHandler.java
    camel/trunk/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerPipelineFactory.java
    camel/trunk/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
    camel/trunk/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConfiguration.java
    camel/trunk/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConsumer.java
    camel/trunk/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpEndpoint.java
    camel/trunk/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpMessage.java

Modified: camel/trunk/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerChannelHandler.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerChannelHandler.java?rev=1477565&r1=1477564&r2=1477565&view=diff
==============================================================================
--- camel/trunk/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerChannelHandler.java
(original)
+++ camel/trunk/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerChannelHandler.java
Tue Apr 30 11:29:18 2013
@@ -39,7 +39,8 @@ import static org.jboss.netty.handler.co
 import static org.jboss.netty.handler.codec.http.HttpVersion.HTTP_1_1;
 
 /**
- * Our http server channel handler to handle HTTP status 100 to continue.
+ * Netty HTTP {@link ServerChannelHandler} that handles the incoming HTTP requests and routes
+ * the received message in Camel.
  */
 public class HttpServerChannelHandler extends ServerChannelHandler {
 

Modified: camel/trunk/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerPipelineFactory.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerPipelineFactory.java?rev=1477565&r1=1477564&r2=1477565&view=diff
==============================================================================
--- camel/trunk/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerPipelineFactory.java
(original)
+++ camel/trunk/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerPipelineFactory.java
Tue Apr 30 11:29:18 2013
@@ -25,12 +25,16 @@ import org.apache.camel.util.ObjectHelpe
 import org.jboss.netty.channel.ChannelPipeline;
 import org.jboss.netty.channel.Channels;
 import org.jboss.netty.handler.codec.http.HttpChunkAggregator;
+import org.jboss.netty.handler.codec.http.HttpContentCompressor;
 import org.jboss.netty.handler.codec.http.HttpRequestDecoder;
 import org.jboss.netty.handler.codec.http.HttpResponseEncoder;
 import org.jboss.netty.handler.ssl.SslHandler;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+/**
+ * {@link ServerPipelineFactory} for the Netty HTTP server.
+ */
 public class HttpServerPipelineFactory extends ServerPipelineFactory {
 
     private static final Logger LOG = LoggerFactory.getLogger(HttpServerPipelineFactory.class);
@@ -71,10 +75,13 @@ public class HttpServerPipelineFactory e
 
         pipeline.addLast("decoder", new HttpRequestDecoder());
         // Uncomment the following line if you don't want to handle HttpChunks.
-        pipeline.addLast("aggregator", new HttpChunkAggregator(1048576));
+        if (supportChunked()) {
+            pipeline.addLast("aggregator", new HttpChunkAggregator(1048576));
+        }
         pipeline.addLast("encoder", new HttpResponseEncoder());
-        // Remove the following line if you don't want automatic content compression.
-        //pipeline.addLast("deflater", new HttpContentCompressor());
+        if (supportCompressed()) {
+            pipeline.addLast("deflater", new HttpContentCompressor());
+        }
 
         // handler to route Camel messages
         pipeline.addLast("handler", new HttpServerChannelHandler(consumer));
@@ -94,4 +101,12 @@ public class HttpServerPipelineFactory e
         return null;
     }
 
+    private boolean supportChunked() {
+        return consumer.getEndpoint().getConfiguration().isChunked();
+    }
+
+    private boolean supportCompressed() {
+        return consumer.getEndpoint().getConfiguration().isCompression();
+    }
+
 }

Modified: camel/trunk/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java?rev=1477565&r1=1477564&r2=1477565&view=diff
==============================================================================
--- camel/trunk/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
(original)
+++ camel/trunk/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
Tue Apr 30 11:29:18 2013
@@ -25,6 +25,9 @@ import org.apache.camel.component.netty.
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.apache.camel.spi.HeaderFilterStrategyAware;
 
+/**
+ * Netty HTTP based component.
+ */
 public class NettyHttpComponent extends NettyComponent implements HeaderFilterStrategyAware
{
 
     private NettyHttpBinding nettyHttpBinding;
@@ -37,10 +40,9 @@ public class NettyHttpComponent extends 
         setNettyHttpBinding(new DefaultNettyHttpBinding(getHeaderFilterStrategy()));
     }
 
-    // TODO: allow to turn mapMessage=true|false
+    // TODO: allow to turn mapMessage=true|false and rely on on-demand mapping
     // TODO: netty http producer
-    // TODO: make it easy to turn chunked on|off
-    // TODO: make it easy to turn compression on|off
+    // TODO: make it easy to turn keep-alive on|off on producer
     // TODO: add logging
 
     @Override

Modified: camel/trunk/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConfiguration.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConfiguration.java?rev=1477565&r1=1477564&r2=1477565&view=diff
==============================================================================
--- camel/trunk/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConfiguration.java
(original)
+++ camel/trunk/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConfiguration.java
Tue Apr 30 11:29:18 2013
@@ -28,6 +28,9 @@ import org.jboss.netty.channel.ChannelHa
  */
 public class NettyHttpConfiguration extends NettyConfiguration {
 
+    private boolean chunked = true;
+    private boolean compression;
+
     public NettyHttpConfiguration() {
         // we need sync=true as http is request/reply by nature
         setSync(true);
@@ -51,4 +54,19 @@ public class NettyHttpConfiguration exte
         }
     }
 
+    public boolean isChunked() {
+        return chunked;
+    }
+
+    public void setChunked(boolean chunked) {
+        this.chunked = chunked;
+    }
+
+    public boolean isCompression() {
+        return compression;
+    }
+
+    public void setCompression(boolean compression) {
+        this.compression = compression;
+    }
 }

Modified: camel/trunk/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConsumer.java?rev=1477565&r1=1477564&r2=1477565&view=diff
==============================================================================
--- camel/trunk/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConsumer.java
(original)
+++ camel/trunk/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConsumer.java
Tue Apr 30 11:29:18 2013
@@ -21,7 +21,7 @@ import org.apache.camel.component.netty.
 import org.apache.camel.component.netty.NettyConsumer;
 
 /**
- * Http {@link NettyConsumer}
+ * HTTP based {@link NettyConsumer}
  */
 public class NettyHttpConsumer extends NettyConsumer {
 

Modified: camel/trunk/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpEndpoint.java?rev=1477565&r1=1477564&r2=1477565&view=diff
==============================================================================
--- camel/trunk/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpEndpoint.java
(original)
+++ camel/trunk/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpEndpoint.java
Tue Apr 30 11:29:18 2013
@@ -30,6 +30,9 @@ import org.jboss.netty.channel.ChannelHa
 import org.jboss.netty.channel.MessageEvent;
 import org.jboss.netty.handler.codec.http.HttpRequest;
 
+/**
+ * HTTP based {@link NettyEndpoint}
+ */
 public class NettyHttpEndpoint extends NettyEndpoint implements HeaderFilterStrategyAware
{
 
     private NettyHttpBinding nettyHttpBinding;
@@ -61,13 +64,18 @@ public class NettyHttpEndpoint extends N
         in.setHeader(NettyConstants.NETTY_REMOTE_ADDRESS, messageEvent.getRemoteAddress());
         in.setHeader(NettyConstants.NETTY_LOCAL_ADDRESS, messageEvent.getChannel().getLocalAddress());
 
-        // Honor the character encoding
-        String contentType = request.getHeader("content-type");
+        // honor the character encoding
+        String contentType = in.getHeader(Exchange.CONTENT_TYPE, String.class);
         NettyHttpHelper.setCharsetFromContentType(contentType, exchange);
 
         return exchange;
     }
 
+    @Override
+    public NettyHttpConfiguration getConfiguration() {
+        return (NettyHttpConfiguration) super.getConfiguration();
+    }
+
     public NettyHttpBinding getNettyHttpBinding() {
         return nettyHttpBinding;
     }

Modified: camel/trunk/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpMessage.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpMessage.java?rev=1477565&r1=1477564&r2=1477565&view=diff
==============================================================================
--- camel/trunk/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpMessage.java
(original)
+++ camel/trunk/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpMessage.java
Tue Apr 30 11:29:18 2013
@@ -19,6 +19,12 @@ package org.apache.camel.component.netty
 import org.apache.camel.impl.DefaultMessage;
 import org.jboss.netty.handler.codec.http.HttpRequest;
 
+/**
+ * Netty HTTP based {@link org.apache.camel.Message}.
+ * <p/>
+ * This implementation allows direct access to the Netty {@link HttpRequest} using
+ * the {@link #getHttpRequest()} method.
+ */
 public class NettyHttpMessage extends DefaultMessage {
 
     private final transient HttpRequest httpRequest;



Mime
View raw message