1

I want to compress and uncompress with Gzip using Netty ChannelHandler, I was trying for a while, but always got a bit difficulty. My code is below:

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

Is there anything wrong?

leealways
  • 11
  • 1
  • 2

1 Answers1

1

I think your channel handlers are in the wrong order, this is how I have mine:

    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();
Derek Troy-West
  • 2,469
  • 1
  • 24
  • 27
  • Your answer is a reordering of the question, and I'm not saying the question deserves anything more, but do you happen to have a reasonable code snippet? See https://stackoverflow.com/q/48046007/839733 – Abhijit Sarkar Dec 31 '17 at 22:37
  • The order is the only important factor in this case. – Derek Troy-West Apr 09 '18 at 10:55