0

In the following file: https://github.com/adamfisk/LittleProxy/blob/master/src/main/java/org/littleshoot/proxy/impl/ProxyToServerConnection.java

I need to add a 'channel handler' which will deflate gzipped content. I have no idea how to do this having no netty knowledge. Can somebody give me a point in the right direction?

Kevin Panko
  • 8,356
  • 19
  • 50
  • 61
nfvindaloo
  • 948
  • 2
  • 11
  • 24
  • 3
    Your question should include everything we need to know; please reproduce the relevant snippet of code here rather than linking to files elsewhere. – anaximander Apr 28 '15 at 15:54
  • There is no need to sign your name at the end of your question. Also, I attempted to copy your code into the question, but it is too long. You will need to create a small example of what your code looks like. Please review the help provided: http://stackoverflow.com/help/how-to-ask – Kevin Panko Apr 28 '15 at 21:25

1 Answers1

1

As others pointed out, your code is a bit too long and it makes the life of people on this website a bit more difficult, but I think I can help you a little bit.

To give a small explanation about netty, each request that you receive goes through a pipeline of handlers, and each requests has its own pipeline associated with.

So it is in the method initiating your pipeline that you should add a handler for decompression, in your case:

initChannelPipeline(ChannelPipeline pipeline, HttpRequest httpRequest)

The handler you are looking for is either HttpContentDecompressor or HttpContentCompressor whether you are trying to uncompress gzipped data or compress it into gzip (it is unclear as you say you would like to deflate gzip content. You should say inflate it if is gzipped or deflate it if is not compressed. Think of it as a balloon. When inflated, it takes a lot more space).

You should pay attention to the order in which you add your handlers in the pipeline.

See Channel pipeline doc for more explanation.

Arnaud Potier
  • 1,750
  • 16
  • 28