2013-06-18 41 views
1

我想使用Netty ChannelHandler對Gzip進行壓縮和解壓,我嘗試了一段時間,但總是有點困難。我的代碼如下:如何使用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()); 

有什麼不對嗎?

回答

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(); 
+0

你的回答是這個問題的重新排序,而我不是說這個問題應該得到更多的東西,但你碰巧有一個合理的代碼片段?請參閱https://stackoverflow.com/q/48046007/839733 –