help required chaining httphandler and proxyhandler
rzorzorzo
rzo at gmx.de
Wed Sep 23 16:01:39 EDT 2009
hello,
i am trying to implement a proxy which checks the http requests before
forwarding these to another server.
i tried implementing this with the following pipeline
starthandler -> HttpRequestDecoder-> stophandler ->
HexDumpProxyInboundHandler
starthandler:
remembers the incoming bytes in a dynamic buffer until the httprequest has
been completely parsed
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent evt)
throws Exception
{
ChannelBuffer m = (ChannelBuffer) evt.getMessage();
ChannelBuffer buf = (ChannelBuffer) ctx.getAttachment();
if (buf == null)
{
buf = dynamicBuffer();
ctx.setAttachment(buf);
}
m.markReaderIndex();
buf.writeBytes(m);
m.resetReaderIndex();
super.messageReceived(ctx, evt);
}
stophandler
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent evt)
{
if (isOk((HttpRequest)evt.getMessage()))
{
ChannelBuffer buf = (ChannelBuffer)
ctx.getPipeline().getContext("interceptStart").getAttachment();
ctx.sendUpstream(new UpstreamMessageEvent(evt.getChannel(), buf,
evt.getRemoteAddress()));
}
}
both extend simple channel upstream handler and
@ChannelPipelineCoverage("one")
for the first page this seems to work well, but for subsequent http requests
not.
any hints or help or other ideas how to implement this with netty ?
- Ron
--
View this message in context: http://n2.nabble.com/help-required-chaining-httphandler-and-proxyhandler-tp3702021p3702021.html
Sent from the Netty User Group mailing list archive at Nabble.com.
More information about the netty-users
mailing list