public static void if_keepAliveRequest_then_resumeReading_else_closeOnComplete(
            final HttpRequest request, final Channel channel, final ChannelFuture channelFuture
    ) {
        // TODO:
        // Add Connection: Close, or Keep-Alive?
        // res.headers().set(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.KEEP_ALIVE);
        if (HttpUtil.isKeepAlive(request)) {
            channelFuture.addListener(new ChannelFutureListener() {
                public void operationComplete(ChannelFuture future) {
                    resumeReading(channel);
                }
            });
        } else {
            channelFuture.addListener(ChannelFutureListener.CLOSE);
        }
    }
public static void if_keepAliveRequest_then_resumeReading_else_closeOnComplete ( final HttpRequest request , final Channel channel , final ChannelFuture channelFuture ) { if ( HttpUtil . isKeepAlive ( request ) ) { channelFuture . addListener ( new ChannelFutureListener ( ) { public void operationComplete ( ChannelFuture future ) { resumeReading ( channel ) ; } } ) ; } else { channelFuture . addListener ( ChannelFutureListener . CLOSE ) ; } }
Handle keep alive as long as there's the request contains
'connection:Keep-Alive' header, no matter what the client is 1.0 or 1.1:
http://sockjs.github.com/sockjs-protocol/sockjs-protocol-0.3.3.html#section-157