javanettylittle-proxy

Need to get body from HttpObjectAggregator.AggregatedFullHttpRequest in Netty


I am using a configurable proxy(little proxy) to listen on requests generated from client end i.e chrome browser. I need the body of the post request.

In the pipeline, this is the one i added. I thought i will be getting a FullHttpRequest, but getting

pipeline.addLast("decoder", new HttpRequestDecoder(8192*4, 8192 * 8,8192 * 8));
pipeline.addLast("inflater", new HttpContentDecompressor());
pipeline.addLast("aggregator", new HttpObjectAggregator(1048576));
pipeline.addLast("encoder", new HttpResponseEncoder());

For Post request, I am getting this data type HttpObjectAggregator#AggregatedFullHttpRequest. I tried debugging. But not able to understand the concept of compositebytebuff.

Let me know how to achieve this.


Solution

  • Found the issue. I thought the error thrown was due to some bytebuf issue. It was because, when i listen for request, i get the original request and send it. But the problem was, the content(bytebuf) will be released when it channelRead is fired. Hence i was trying to access the content which was already released. So i made a copy of the content(so it wont be released when channelRead is fired) when i listen for the requests and give to the listener. So he will be able to access the content.