Example usage for io.netty.handler.codec ByteToMessageDecoder COMPOSITE_CUMULATOR

List of usage examples for io.netty.handler.codec ByteToMessageDecoder COMPOSITE_CUMULATOR

Introduction

In this page you can find the example usage for io.netty.handler.codec ByteToMessageDecoder COMPOSITE_CUMULATOR.

Prototype

Cumulator COMPOSITE_CUMULATOR

To view the source code for io.netty.handler.codec ByteToMessageDecoder COMPOSITE_CUMULATOR.

Click Source Link

Document

Cumulate ByteBuf s by add them to a CompositeByteBuf and so do no memory copy whenever possible.

Usage

From source file:org.elasticsearch.http.nio.HttpReadWriteHandler.java

License:Apache License

public HttpReadWriteHandler(NioHttpChannel nioHttpChannel, NioHttpServerTransport transport,
        HttpHandlingSettings settings, NioCorsConfig corsConfig) {
    this.nioHttpChannel = nioHttpChannel;
    this.transport = transport;

    List<ChannelHandler> handlers = new ArrayList<>(5);
    HttpRequestDecoder decoder = new HttpRequestDecoder(settings.getMaxInitialLineLength(),
            settings.getMaxHeaderSize(), settings.getMaxChunkSize());
    decoder.setCumulator(ByteToMessageDecoder.COMPOSITE_CUMULATOR);
    handlers.add(decoder);//  w  w  w . j  a v  a 2 s  . c  o  m
    handlers.add(new HttpContentDecompressor());
    handlers.add(new HttpResponseEncoder());
    handlers.add(new HttpObjectAggregator(settings.getMaxContentLength()));
    if (settings.isCompression()) {
        handlers.add(new HttpContentCompressor(settings.getCompressionLevel()));
    }
    if (settings.isCorsEnabled()) {
        handlers.add(new NioCorsHandler(corsConfig));
    }
    handlers.add(new NioHttpPipeliningHandler(transport.getLogger(), settings.getPipeliningMaxEvents()));

    adaptor = new NettyAdaptor(handlers.toArray(new ChannelHandler[0]));
    adaptor.addCloseListener((v, e) -> nioHttpChannel.close());
}