Skip to content
Browse files

#66 tidy up initializer

  • Loading branch information...
1 parent 8f29857 commit 4fbcf8751ae71c7bbf0f8f716088aeec96723638 Rob Fletcher committed
View
23 betamax-netty/src/main/java/co/freeside/betamax/proxy/netty/HttpChannelInitializer.java
@@ -1,9 +1,12 @@
package co.freeside.betamax.proxy.netty;
+import javax.net.ssl.*;
+import co.freeside.betamax.proxy.netty.ssl.*;
import io.netty.channel.*;
import io.netty.channel.nio.*;
import io.netty.channel.socket.*;
import io.netty.handler.codec.http.*;
+import io.netty.handler.ssl.*;
import io.netty.handler.stream.*;
/**
@@ -13,12 +16,10 @@
public static final int MAX_CONTENT_LENGTH = 65536;
- private final int workerThreads;
private final ChannelHandler handler;
private final EventLoopGroup workerGroup;
public HttpChannelInitializer(int workerThreads, ChannelHandler handler) {
- this.workerThreads = workerThreads;
this.handler = handler;
if (workerThreads > 0) {
@@ -31,15 +32,19 @@ public HttpChannelInitializer(int workerThreads, ChannelHandler handler) {
@Override
public void initChannel(SocketChannel channel) throws Exception {
ChannelPipeline pipeline = channel.pipeline();
- pipeline
- .addLast(new HttpRequestDecoder())
- .addLast(new HttpObjectAggregator(MAX_CONTENT_LENGTH))
- .addLast(new HttpResponseEncoder())
- .addLast(new ChunkedWriteHandler());
+
+// SSLEngine engine = SslContextFactory.getServerContext().createSSLEngine();
+// engine.setUseClientMode(false);
+
+// pipeline.addLast("ssl", new SslHandler(engine));
+ pipeline.addLast("decoder", new HttpRequestDecoder());
+ pipeline.addLast("aggregator", new HttpObjectAggregator(MAX_CONTENT_LENGTH));
+ pipeline.addLast("encoder", new HttpResponseEncoder());
+ pipeline.addLast("chunkedWriter", new ChunkedWriteHandler());
if (workerGroup == null) {
- pipeline.addLast(handler);
+ pipeline.addLast("betamaxHandler", handler);
} else {
- pipeline.addLast(workerGroup, handler);
+ pipeline.addLast(workerGroup, "betamaxHandler", handler);
}
}
}

0 comments on commit 4fbcf87

Please sign in to comment.
Something went wrong with that request. Please try again.