use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpServerCodec in project cdap by caskdata.
the class NettyRouter method createServerBootstrap.
private ServerBootstrap createServerBootstrap(final ChannelGroup channelGroup) throws ServiceBindException {
EventLoopGroup bossGroup = createEventLoopGroup(serverBossThreadPoolSize, "router-server-boss-thread-%d");
EventLoopGroup workerGroup = createEventLoopGroup(serverWorkerThreadPoolSize, "router-server-worker-thread-%d");
return new ServerBootstrap().group(bossGroup, workerGroup).channel(NioServerSocketChannel.class).option(ChannelOption.SO_BACKLOG, serverConnectionBacklog).childHandler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) throws Exception {
channelGroup.add(ch);
ChannelPipeline pipeline = ch.pipeline();
if (isSSLEnabled()) {
pipeline.addLast("ssl", sslHandlerFactory.create(ch.alloc()));
}
pipeline.addLast("http-codec", new HttpServerCodec());
pipeline.addLast("http-status-request-handler", new HttpStatusRequestHandler());
if (securityEnabled) {
pipeline.addLast("access-token-authenticator", new AuthenticationHandler(cConf, tokenValidator, discoveryServiceClient, accessTokenTransformer));
}
if (cConf.getBoolean(Constants.Router.ROUTER_AUDIT_LOG_ENABLED)) {
pipeline.addLast("audit-log", new AuditLogHandler());
}
// Always let the client to continue sending the request body after the authentication passed
pipeline.addLast("expect-continue", new HttpServerExpectContinueHandler());
// for now there's only one hardcoded rule, but if there will be more, we may want it generic and configurable
pipeline.addLast("http-request-handler", new HttpRequestRouter(cConf, serviceLookup));
}
});
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpServerCodec in project reactor-netty by reactor.
the class NettyContextTest method addByteEncoderWhenFullReactorPipeline.
@Test
public void addByteEncoderWhenFullReactorPipeline() throws Exception {
channel.pipeline().addLast(NettyPipeline.HttpCodec, new HttpServerCodec()).addLast(NettyPipeline.HttpServerHandler, new ChannelDuplexHandler()).addLast(NettyPipeline.ReactiveBridge, new ChannelHandlerAdapter() {
});
ChannelHandler encoder = new LineBasedFrameDecoder(12);
testContext.addHandlerFirst("encoder", encoder);
assertEquals(channel.pipeline().names(), Arrays.asList(NettyPipeline.HttpCodec, NettyPipeline.HttpServerHandler, "encoder", NettyPipeline.ReactiveBridge, "DefaultChannelPipeline$TailContext#0"));
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpServerCodec in project reactor-netty by reactor.
the class NettyContextTest method addNonByteEncoderWhenFullReactorPipeline.
@Test
public void addNonByteEncoderWhenFullReactorPipeline() throws Exception {
channel.pipeline().addLast(NettyPipeline.HttpCodec, new HttpServerCodec()).addLast(NettyPipeline.HttpServerHandler, new ChannelDuplexHandler()).addLast(NettyPipeline.ReactiveBridge, new ChannelHandlerAdapter() {
});
ChannelHandler encoder = new ChannelHandlerAdapter() {
};
testContext.addHandlerFirst("encoder", encoder);
assertEquals(channel.pipeline().names(), Arrays.asList(NettyPipeline.HttpCodec, NettyPipeline.HttpServerHandler, "encoder", NettyPipeline.ReactiveBridge, "DefaultChannelPipeline$TailContext#0"));
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpServerCodec in project reactor-netty by reactor.
the class NettyContextTest method addByteDecoderWhenFullReactorPipeline.
@Test
public void addByteDecoderWhenFullReactorPipeline() throws Exception {
channel.pipeline().addLast(NettyPipeline.HttpCodec, new HttpServerCodec()).addLast(NettyPipeline.HttpServerHandler, new ChannelDuplexHandler()).addLast(NettyPipeline.ReactiveBridge, new ChannelHandlerAdapter() {
});
ChannelHandler decoder = new LineBasedFrameDecoder(12);
testContext.addHandlerLast("decoder", decoder).addHandlerFirst("decoder$extract", NettyPipeline.inboundHandler(ADD_EXTRACTOR));
assertEquals(channel.pipeline().names(), Arrays.asList(NettyPipeline.HttpCodec, NettyPipeline.HttpServerHandler, "decoder$extract", "decoder", NettyPipeline.ReactiveBridge, "DefaultChannelPipeline$TailContext#0"));
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpServerCodec in project neo4j by neo4j.
the class TransportSelectionHandler method switchToWebsocket.
private void switchToWebsocket(ChannelHandlerContext ctx) {
ChannelPipeline p = ctx.pipeline();
memoryTracker.allocateHeap(HTTP_SERVER_CODEC_SHALLOW_SIZE + HTTP_OBJECT_AGGREGATOR_SHALLOW_SIZE + WEB_SOCKET_SERVER_PROTOCOL_HANDLER_SHALLOW_SIZE + WEB_SOCKET_FRAME_AGGREGATOR_SHALLOW_SIZE + WebSocketFrameTranslator.SHALLOW_SIZE + ProtocolHandshaker.SHALLOW_SIZE);
p.addLast(new HttpServerCodec(), new HttpObjectAggregator(MAX_WEBSOCKET_HANDSHAKE_SIZE), new WebSocketServerProtocolHandler("/", null, false, MAX_WEBSOCKET_FRAME_SIZE), new WebSocketFrameAggregator(MAX_WEBSOCKET_FRAME_SIZE), new WebSocketFrameTranslator(), newHandshaker());
p.remove(this);
}
Aggregations