1

我想Gzip使用 Netty ChannelHandler 进行压缩和解压缩,我尝试了一段时间,但总是有点困难。我的代码如下:

pipeline.addLast("decoder", new HttpRequestDecoder());
pipeline.addLast("aggregator", new HttpChunkAggregator(1048576));
pipeline.addLast("inflater", new HttpContentDecompressor());
pipeline.addLast("encoder", new HttpResponseEncoder());
pipeline.addLast("deflater", new HttpContentCompressor());

有什么问题吗?

4

1 回答 1

1

我认为您的频道处理程序的顺序错误,这就是我的方式:

    pipeline.addLast(DECODE, decoderProvider.get());
    pipeline.addLast(ENCODE, encoderProvider.get());
    pipeline.addLast(COMPRESS, compressorProvider.get());
    pipeline.addLast(DECOMPRESS, decompressorProvider.get());
    pipeline.addLast(AGGREGATE, aggregatorProvider.get());
    pipeline.addLast(EXECUTE, new CustomRequestHandler();
于 2013-06-19T08:37:41.703 回答