下面列出了 io.netty.handler.codec.http.cookie.DefaultCookie # setPath ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public Response addCookie(String name, String value, String domain, Boolean isHttpOnly, Long maxAge, String path, Boolean isSecured) {
if(cookies == null) {
cookies = Lists.newArrayList();
}
final DefaultCookie defaultCookie = new DefaultCookie(name, value);
if(domain != null) {
defaultCookie.setDomain(domain);
}
if(isHttpOnly != null) {
defaultCookie.setHttpOnly(isHttpOnly);
}
if(maxAge != null) {
defaultCookie.setMaxAge(maxAge);
}
if(path != null) {
defaultCookie.setPath(path);
}
if(isSecured != null) {
defaultCookie.setSecure(isSecured);
}
cookies.add(defaultCookie);
return this;
}
/**
* Converts the Wisdom's cookie to a Netty's cookie.
*
* @param cookie the Wisdom's cookie
* @return the Netty's cookie with the same metadata and content than the input cookie.
*/
public static DefaultCookie convertWisdomCookieToNettyCookie(Cookie cookie) {
DefaultCookie nettyCookie = new DefaultCookie(cookie.name(), cookie.value());
nettyCookie.setMaxAge(cookie.maxAge());
// Comments are not supported anymore by netty.
if (cookie.domain() != null) {
nettyCookie.setDomain(cookie.domain());
}
if (cookie.isSecure()) {
nettyCookie.setSecure(true);
}
if (cookie.path() != null) {
nettyCookie.setPath(cookie.path());
}
if (cookie.isHttpOnly()) {
nettyCookie.setHttpOnly(true);
}
return nettyCookie;
}
private DefaultCookie createCookie(String value, Long maxAge) {
DefaultCookie nettyCookie = new DefaultCookie(cookieConfig.getAuthCookieName(), value);
nettyCookie.setMaxAge(maxAge);
nettyCookie.setHttpOnly(true);
nettyCookie.setSecure(cookieConfig.isSecureOnly());
nettyCookie.setPath("/");
if (cookieConfig.isDomainNameSet()) {
nettyCookie.setDomain(cookieConfig.getDomainName());
}
return nettyCookie;
}
private DefaultCookie createCookie(String value, Long maxAge) {
DefaultCookie nettyCookie = new DefaultCookie(authCookieName, value);
nettyCookie.setMaxAge(maxAge);
nettyCookie.setHttpOnly(true);
nettyCookie.setPath("/");
nettyCookie.setDomain(domainName);
return nettyCookie;
}
public static DefaultCookie createCookie(String authCookieName, String domainName, String value, Long maxAge) {
DefaultCookie nettyCookie = new DefaultCookie(authCookieName, value);
nettyCookie.setMaxAge(maxAge);
nettyCookie.setHttpOnly(false);
nettyCookie.setPath("/");
if (domainName != null && !"none".equals(domainName)) {
nettyCookie.setDomain(domainName);
}
return nettyCookie;
}