我想使用Netty ChannelHandler压缩和解压缩Gzip
,我试了一会儿,但总是有点困难。我的代码如下:
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());
有什么不对吗?
答案 0 :(得分: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();