Example usage for io.netty.handler.codec.http HttpRequestDecoder setCumulator

List of usage examples for io.netty.handler.codec.http HttpRequestDecoder setCumulator

Introduction

In this page you can find the example usage for io.netty.handler.codec.http HttpRequestDecoder setCumulator.

Prototype

public void setCumulator(Cumulator cumulator) 

Source Link

Document

Set the Cumulator to use for cumulate the received ByteBuf s.

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);/*from  w  ww  . j a v a  2s  . 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());
}