Java Code Examples for io.netty.handler.codec.http.HttpObjectAggregator#setMaxCumulationBufferComponents()

The following examples show how to use io.netty.handler.codec.http.HttpObjectAggregator#setMaxCumulationBufferComponents() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Netty4HttpServerTransport.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public void initChannel(Channel ch) throws Exception {
    ch.pipeline().addLast("openChannels", transport.serverOpenChannels);
    ch.pipeline().addLast("read_timeout", new ReadTimeoutHandler(transport.readTimeoutMillis, TimeUnit.MILLISECONDS));
    final HttpRequestDecoder decoder = new HttpRequestDecoder(
        Math.toIntExact(transport.maxInitialLineLength.getBytes()),
        Math.toIntExact(transport.maxHeaderSize.getBytes()),
        Math.toIntExact(transport.maxChunkSize.getBytes()));
    decoder.setCumulator(ByteToMessageDecoder.COMPOSITE_CUMULATOR);
    ch.pipeline().addLast("decoder", decoder);
    ch.pipeline().addLast("decoder_compress", new HttpContentDecompressor());
    ch.pipeline().addLast("encoder", new HttpResponseEncoder());
    final HttpObjectAggregator aggregator = new HttpObjectAggregator(Math.toIntExact(transport.maxContentLength.getBytes()));
    aggregator.setMaxCumulationBufferComponents(transport.maxCompositeBufferComponents);
    ch.pipeline().addLast("aggregator", aggregator);
    if (transport.compression) {
        ch.pipeline().addLast("encoder_compress", new HttpContentCompressor(transport.compressionLevel));
    }
    ch.pipeline().addLast("handler", new MainAndStaticFileHandler(
        nodeName,
        home,
        nodeClient,
        transport.getCorsConfig()
    ));
    pipelineRegistry.registerItems(ch.pipeline(), transport.getCorsConfig());
    if (SETTING_CORS_ENABLED.get(transport.settings())) {
        ch.pipeline().addAfter("encoder", "cors", new Netty4CorsHandler(transport.getCorsConfig()));
    }
}
 
Example 2
Source File: WebSocketChannelizer.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
@Override
public void configure(final ChannelPipeline pipeline) {
    if (logger.isDebugEnabled())
        pipeline.addLast(new LoggingHandler("log-io", LogLevel.DEBUG));

    logger.debug("HttpRequestDecoder settings - maxInitialLineLength={}, maxHeaderSize={}, maxChunkSize={}",
            settings.maxInitialLineLength, settings.maxHeaderSize, settings.maxChunkSize);
    pipeline.addLast(PIPELINE_HTTP_REQUEST_DECODER, new HttpRequestDecoder(settings.maxInitialLineLength, settings.maxHeaderSize, settings.maxChunkSize));

    if (logger.isDebugEnabled())
        pipeline.addLast(new LoggingHandler("log-decoder-aggregator", LogLevel.DEBUG));

    logger.debug("HttpObjectAggregator settings - maxContentLength={}, maxAccumulationBufferComponents={}",
            settings.maxContentLength, settings.maxAccumulationBufferComponents);
    final HttpObjectAggregator aggregator = new HttpObjectAggregator(settings.maxContentLength);
    aggregator.setMaxCumulationBufferComponents(settings.maxAccumulationBufferComponents);
    pipeline.addLast("aggregator", aggregator);

    if (logger.isDebugEnabled())
        pipeline.addLast(new LoggingHandler("log-aggregator-encoder", LogLevel.DEBUG));

    pipeline.addLast(PIPELINE_HTTP_RESPONSE_ENCODER, new HttpResponseEncoder());

    // setting closeOnProtocolViolation to false prevents causing all the other requests using the same channel
    // to fail when a single request causes a protocol violation.
    final WebSocketDecoderConfig wsDecoderConfig = WebSocketDecoderConfig.newBuilder().
            closeOnProtocolViolation(false).allowExtensions(false).maxFramePayloadLength(settings.maxContentLength).build();
    pipeline.addLast(PIPELINE_REQUEST_HANDLER, new WebSocketServerProtocolHandler(GREMLIN_ENDPOINT,
            null, false, false, 10000L, wsDecoderConfig));

    if (logger.isDebugEnabled())
        pipeline.addLast(new LoggingHandler("log-aggregator-encoder", LogLevel.DEBUG));

    pipeline.addLast("ws-frame-encoder", wsGremlinResponseFrameEncoder);
    pipeline.addLast("response-frame-encoder", gremlinResponseFrameEncoder);
    pipeline.addLast("request-text-decoder", wsGremlinTextRequestDecoder);
    pipeline.addLast("request-binary-decoder", wsGremlinBinaryRequestDecoder);
    pipeline.addLast("request-close-decoder", wsGremlinCloseRequestDecoder);

    if (logger.isDebugEnabled())
        pipeline.addLast(new LoggingHandler("log-aggregator-encoder", LogLevel.DEBUG));

    if (authenticationHandler != null)
        pipeline.addLast(PIPELINE_AUTHENTICATOR, authenticationHandler);
}