Netty4HttpServerTransport.java 文件源码

java
阅读 27 收藏 0 点赞 0 评论 0

项目:elasticsearch_my 作者:
@Override
protected void initChannel(Channel ch) throws Exception {
    ch.pipeline().addLast("openChannels", transport.serverOpenChannels);
    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()));
    if (transport.maxCompositeBufferComponents != -1) {
        aggregator.setMaxCumulationBufferComponents(transport.maxCompositeBufferComponents);
    }
    ch.pipeline().addLast("aggregator", aggregator);
    if (transport.compression) {
        ch.pipeline().addLast("encoder_compress", new HttpContentCompressor(transport.compressionLevel));
    }
    if (SETTING_CORS_ENABLED.get(transport.settings())) {
        ch.pipeline().addLast("cors", new Netty4CorsHandler(transport.getCorsConfig()));
    }
    if (transport.pipelining) {
        ch.pipeline().addLast("pipelining", new HttpPipeliningHandler(transport.pipeliningMaxEvents));
    }
    ch.pipeline().addLast("handler", requestHandler);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号