Example usage for io.netty.handler.codec.http DefaultCookie setHttpOnly

List of usage examples for io.netty.handler.codec.http DefaultCookie setHttpOnly

Introduction

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

Prototype

@Override
    public void setHttpOnly(boolean httpOnly) 

Source Link

Usage

From source file:holon.internal.http.netty.NettyRequestContext.java

License:Open Source License

private void renderCookies(FullHttpResponse response) {
    for (Map.Entry<String, Cookie> cookieToAdd : this.responseCookies.entrySet()) {
        Cookie holonCookie = cookieToAdd.getValue();
        DefaultCookie cookie = new DefaultCookie(cookieToAdd.getKey(), cookieToAdd.getValue().value());

        cookie.setPath(holonCookie.path() == null ? "/" : holonCookie.path());
        cookie.setSecure(holonCookie.secure());
        cookie.setDomain(holonCookie.domain() == null ? "" : holonCookie.domain());
        cookie.setHttpOnly(holonCookie.httpOnly());

        response.headers().add("Set-Cookie", ServerCookieEncoder.encode(cookie));
    }//from www  . j  a v a  2s  .  c o  m
    for (String name : this.discardCookies) {
        DefaultCookie cookie = new DefaultCookie(name, "");
        cookie.setDiscard(true);
        response.headers().add("Set-Cookie", ServerCookieEncoder.encode(cookie));
    }
}