ChannelBuffer to HttpRequest - using HttpRequestDecoder
Renjith T
renjith.tom85 at gmail.com
Wed Aug 3 16:07:04 EDT 2011
Ok - got this. Having an implementation like this - helped got past the
default visibility of 'decode' :
new MyDecoder().decode(ctx, e.getChannel(), (ChannelBuffer)
e.getMessage() );
static class MyDecoder extends HttpRequestDecoder {
public Object decode(ChannelHandlerContext ctx,
Channel channel,
ChannelBuffer buffer)
throws Exception {
return super.decode(ctx, channel, buffer,
HttpMessageDecoder.State.READ_INITIAL);
}
}
This worked great, but I wanted to reuse the ChannelBuffer after
decoding as well ( since after this the stream returns empty ).
So , used the .copy() method of ChannelBuffer to take care of the same.
new MyDecoder().decode(ctx, e.getChannel(), (ChannelBuffer)
e.getMessage()*.copy()* );
That worked fine.
But - is that an equivalent of a clear() method to force release the
contents though ?
On 08/04/2011 01:06 AM, Renjith T wrote:
> I am working on a handler ( from SimpleChannelUpstreamHandler), that
> gives the message in messageRecieved as a ChannelBuffer .
>
> public void messageReceived(ChannelHandlerContext ctx, final
> MessageEvent e)
> throws Exception {
> final ChannelBuffer request = (ChannelBuffer) e.getMessage();
> ... // do something
>
> }
>
>
> I would like to convert this ChannelBuffer to a HttpRequest, through
> some means, if possible.
>
> ( pipeline.addLast("decoder", new HttpRequestDecoder()); , in the
> pipeline factory does not work since I need the raw ChannelBuffer as
> mentioned above , for some other downstream processing as well).
>
> How can I achieve the above ?
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/netty-users/attachments/20110804/ea167337/attachment.html
More information about the netty-users
mailing list