org.jboss.netty.handler.codec.http.HttpHeaders.Values Java Examples

The following examples show how to use org.jboss.netty.handler.codec.http.HttpHeaders.Values. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HttpServerRequestHandler.java    From feeyo-hlsserver with Apache License 2.0 6 votes vote down vote up
private void sendResponse(ChannelHandlerContext ctx, HttpResponse httpResponse){
    boolean close = false;
    ChannelFuture channelFuture = null;
    try {
        channelFuture = ctx.getChannel().write(httpResponse);
    } catch (Exception e) {
    	LOGGER.error("write response fail.", e);
        close = true;
    } finally {
        // close connection
        if (close || httpResponse == null || !Values.KEEP_ALIVE.equals(httpResponse.headers().get(HttpHeaders.Names.CONNECTION))) {
        	if (channelFuture.isSuccess()) {
    			channelFuture.getChannel().close();
    		}
        }
    }
}