use of io.netty.handler.codec.http.HttpResponseEncoder in project camel by apache.
the class HttpServerSharedInitializerFactory method initChannel.
@Override
protected void initChannel(Channel ch) throws Exception {
// create a new pipeline
ChannelPipeline pipeline = ch.pipeline();
SslHandler sslHandler = configureServerSSLOnDemand();
if (sslHandler != null) {
LOG.debug("Server SSL handler configured and added as an interceptor against the ChannelPipeline: {}", sslHandler);
pipeline.addLast("ssl", sslHandler);
}
pipeline.addLast("decoder", new HttpRequestDecoder(409, configuration.getMaxHeaderSize(), 8192));
pipeline.addLast("encoder", new HttpResponseEncoder());
if (configuration.isChunked()) {
pipeline.addLast("aggregator", new HttpObjectAggregator(configuration.getChunkedMaxContentLength()));
}
if (configuration.isCompression()) {
pipeline.addLast("deflater", new HttpContentCompressor());
}
pipeline.addLast("handler", channelFactory.getChannelHandler());
}
use of io.netty.handler.codec.http.HttpResponseEncoder in project rest.li by linkedin.
the class HttpNettyServer method start.
@Override
public void start() {
_eventExecutors = new DefaultEventExecutorGroup(_threadPoolSize);
_bossGroup = new NioEventLoopGroup(1, new NamedThreadFactory("R2 Nio Boss"));
_workerGroup = new NioEventLoopGroup(0, new NamedThreadFactory("R2 Nio Worker"));
ServerBootstrap bootstrap = new ServerBootstrap().group(_bossGroup, _workerGroup).channel(NioServerSocketChannel.class).childHandler(new ChannelInitializer<NioSocketChannel>() {
@Override
protected void initChannel(NioSocketChannel ch) throws Exception {
ch.pipeline().addLast("decoder", new HttpRequestDecoder());
ch.pipeline().addLast("aggregator", new HttpObjectAggregator(1048576));
ch.pipeline().addLast("encoder", new HttpResponseEncoder());
ch.pipeline().addLast("rapi", new RAPServerCodec());
ch.pipeline().addLast(_eventExecutors, "handler", _restOverStream ? new StreamHandler() : new RestHandler());
}
});
bootstrap.bind(new InetSocketAddress(_port));
}
use of io.netty.handler.codec.http.HttpResponseEncoder in project asterixdb by apache.
the class HttpServerInitializer method initChannel.
@Override
public void initChannel(SocketChannel ch) {
ChannelPipeline p = ch.pipeline();
p.addLast(new HttpRequestDecoder(MAX_REQUEST_INITIAL_LINE_LENGTH, MAX_REQUEST_HEADER_SIZE, MAX_REQUEST_CHUNK_SIZE));
p.addLast(new HttpResponseEncoder());
p.addLast(new HttpObjectAggregator(Integer.MAX_VALUE));
p.addLast(server.createHttpHandler(RESPONSE_CHUNK_SIZE));
}
use of io.netty.handler.codec.http.HttpResponseEncoder in project netty by netty.
the class HttpUploadServerInitializer method initChannel.
@Override
public void initChannel(SocketChannel ch) {
ChannelPipeline pipeline = ch.pipeline();
if (sslCtx != null) {
pipeline.addLast(sslCtx.newHandler(ch.alloc()));
}
pipeline.addLast(new HttpRequestDecoder());
pipeline.addLast(new HttpResponseEncoder());
// Remove the following line if you don't want automatic content compression.
pipeline.addLast(new HttpContentCompressor());
pipeline.addLast(new HttpUploadServerHandler());
}
use of io.netty.handler.codec.http.HttpResponseEncoder in project netty by netty.
the class HttpServer method start.
public ChannelFuture start() throws Exception {
ServerBootstrap b = new ServerBootstrap();
b.option(ChannelOption.SO_BACKLOG, 1024);
b.group(group).channel(NioServerSocketChannel.class).handler(new LoggingHandler(LogLevel.INFO)).childHandler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) throws Exception {
ch.pipeline().addLast(new HttpRequestDecoder(), new HttpResponseEncoder(), new HttpObjectAggregator(MAX_CONTENT_LENGTH), new Http1RequestHandler());
}
});
Channel ch = b.bind(PORT).sync().channel();
return ch.closeFuture();
}
Aggregations