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

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

Introduction

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

Prototype

@Override
    public void setSecure(boolean secure) 

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));
    }// w  ww  .  j  a  v  a2 s.co m
    for (String name : this.discardCookies) {
        DefaultCookie cookie = new DefaultCookie(name, "");
        cookie.setDiscard(true);
        response.headers().add("Set-Cookie", ServerCookieEncoder.encode(cookie));
    }
}