Example usage for io.netty.handler.codec.http DefaultHttpHeaders names

List of usage examples for io.netty.handler.codec.http DefaultHttpHeaders names

Introduction

In this page you can find the example usage for io.netty.handler.codec.http DefaultHttpHeaders names.

Prototype

@Override
    public Set<String> names() 

Source Link

Usage

From source file:co.paralleluniverse.comsat.webactors.netty.WebActorHandler.java

License:Open Source License

private static void writeHttpResponse(ChannelHandlerContext ctx, FullHttpRequest req, FullHttpResponse res,
        boolean close) {
    if (!omitDateHeader && !res.headers().contains(DefaultHttpHeaders.Names.DATE))
        DefaultHttpHeaders.addDateHeader(res, DefaultHttpHeaders.Names.DATE, new Date());

    // Reply the response and close the connection if necessary.
    if (!HttpHeaders.isKeepAlive(req) || close) {
        res.headers().set(CONNECTION, HttpHeaders.Values.CLOSE);
        ctx.writeAndFlush(res).addListener(ChannelFutureListener.CLOSE);
    } else {//from  w w w.  jav  a 2 s .  c o  m
        res.headers().set(CONNECTION, HttpHeaders.Values.KEEP_ALIVE);
        write(ctx, res);
    }
}