@Override public void channelRead(final ChannelHandlerContext ctx, final Object msg) throws Exception { FullHttpRequest request = (FullHttpRequest) msg; HttpMethod method = request.getMethod(); // if we are a post then we send upstream, otherwise we are just being prompted for a response. if (method.equals(HttpMethod.POST ) ) { ctx.fireChannelRead(ReferenceCountUtil.retain(((FullHttpRequest) msg).content())); // add a new response responses.put(new ResponseHolder(System.currentTimeMillis() + responseTime, new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK))); ReferenceCountUtil.release(msg); return; } super.channelRead(ctx, msg); }
@Override public void messageReceived(final ChannelHandlerContext ctx, final MessageEvent e) throws Exception { HttpRequest request = (HttpRequest)e.getMessage(); HttpMethod method = request.getMethod(); // if we are a post then we send upstream, otherwise we are just being prompted for a response. if (method.equals(HttpMethod.POST)) { MessageEvent event = new UpstreamMessageEvent(e.getChannel(), request.getContent(), e.getRemoteAddress()); ctx.sendUpstream(event); } // add a new response responses.put(new ResponseHolder(System.currentTimeMillis() + responseTime, new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK))); }