public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
Object msg = e.getMessage();
if (msg instanceof HttpRequest) {
HttpRequest req = (HttpRequest) msg;
Channel channel = ctx.getChannel();
QueryStringDecoder queryDecoder = new QueryStringDecoder(req.getUri());
if (!configuration.isAllowCustomRequests()
&& !queryDecoder.getPath().startsWith(connectPath)) {
HttpResponse res = new DefaultHttpResponse(HTTP_1_1, HttpResponseStatus.BAD_REQUEST);
ChannelFuture f = channel.write(res);
f.addListener(ChannelFutureListener.CLOSE);
return;
}
if (queryDecoder.getPath().equals(connectPath)) {
String origin = req.getHeader(HttpHeaders.Names.ORIGIN);
authorize(channel, origin, queryDecoder.getParameters());
return;
}
}
ctx.sendUpstream(e);
}