use of io.netty.handler.stream.ChunkedWriteHandler in project async-http-client by AsyncHttpClient.
the class ChannelManager method configureBootstraps.
public void configureBootstraps(NettyRequestSender requestSender) {
final AsyncHttpClientHandler httpHandler = new HttpHandler(config, this, requestSender);
wsHandler = new WebSocketHandler(config, this, requestSender);
final NoopHandler pinnedEntry = new NoopHandler();
final LoggingHandler loggingHandler = new LoggingHandler(LogLevel.TRACE);
httpBootstrap.handler(new ChannelInitializer<Channel>() {
@Override
protected void initChannel(Channel ch) throws Exception {
ChannelPipeline pipeline = //
ch.pipeline().addLast(PINNED_ENTRY, //
pinnedEntry).addLast(HTTP_CLIENT_CODEC, //
newHttpClientCodec()).addLast(INFLATER_HANDLER, //
newHttpContentDecompressor()).addLast(CHUNKED_WRITER_HANDLER, //
new ChunkedWriteHandler()).addLast(AHC_HTTP_HANDLER, httpHandler);
if (LOGGER.isTraceEnabled()) {
pipeline.addAfter(PINNED_ENTRY, LOGGING_HANDLER, loggingHandler);
}
if (config.getHttpAdditionalChannelInitializer() != null)
config.getHttpAdditionalChannelInitializer().initChannel(ch);
}
});
wsBootstrap.handler(new ChannelInitializer<Channel>() {
@Override
protected void initChannel(Channel ch) throws Exception {
ChannelPipeline pipeline = //
ch.pipeline().addLast(PINNED_ENTRY, //
pinnedEntry).addLast(HTTP_CLIENT_CODEC, //
newHttpClientCodec()).addLast(AHC_WS_HANDLER, wsHandler);
if (LOGGER.isDebugEnabled()) {
pipeline.addAfter(PINNED_ENTRY, LOGGING_HANDLER, loggingHandler);
}
if (config.getWsAdditionalChannelInitializer() != null)
config.getWsAdditionalChannelInitializer().initChannel(ch);
}
});
}
Aggregations