Java Code Examples for io.netty.handler.codec.http.cookie.Cookie#setDomain()
The following examples show how to use
io.netty.handler.codec.http.cookie.Cookie#setDomain() .
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: ReactorServerHttpResponse.java From spring-analysis-note with MIT License | 6 votes |
@Override protected void applyCookies() { for (String name : getCookies().keySet()) { for (ResponseCookie httpCookie : getCookies().get(name)) { Cookie cookie = new DefaultCookie(name, httpCookie.getValue()); if (!httpCookie.getMaxAge().isNegative()) { cookie.setMaxAge(httpCookie.getMaxAge().getSeconds()); } if (httpCookie.getDomain() != null) { cookie.setDomain(httpCookie.getDomain()); } if (httpCookie.getPath() != null) { cookie.setPath(httpCookie.getPath()); } cookie.setSecure(httpCookie.isSecure()); cookie.setHttpOnly(httpCookie.isHttpOnly()); this.response.addCookie(cookie); } } }
Example 2
Source File: ReactorServerHttpResponse.java From java-technology-stack with MIT License | 6 votes |
@Override protected void applyCookies() { for (String name : getCookies().keySet()) { for (ResponseCookie httpCookie : getCookies().get(name)) { Cookie cookie = new DefaultCookie(name, httpCookie.getValue()); if (!httpCookie.getMaxAge().isNegative()) { cookie.setMaxAge(httpCookie.getMaxAge().getSeconds()); } if (httpCookie.getDomain() != null) { cookie.setDomain(httpCookie.getDomain()); } if (httpCookie.getPath() != null) { cookie.setPath(httpCookie.getPath()); } cookie.setSecure(httpCookie.isSecure()); cookie.setHttpOnly(httpCookie.isHttpOnly()); this.response.addCookie(cookie); } } }
Example 3
Source File: DefaultWebRes.java From krpc with Apache License 2.0 | 5 votes |
public DefaultWebRes addCookie(String name, String value) { String paramsStr = null; int p = value.indexOf("^"); if (p >= 0) { paramsStr = value.substring(p + 1); value = value.substring(0, p); } if (cookies == null) cookies = new ArrayList<>(); Cookie c = new DefaultCookie(name, value); if (paramsStr != null) { Map<String, String> params = Plugin.defaultSplitParams(paramsStr); if (params.containsKey("domain")) c.setDomain(params.get("domain")); if (params.containsKey("path")) c.setPath(params.get("path")); if (params.containsKey("maxAge")) c.setMaxAge(Long.parseLong(params.get("maxAge"))); if (params.containsKey("httpOnly")) c.setHttpOnly(Boolean.parseBoolean(params.get("httpOnly"))); else c.setHttpOnly(true); if (params.containsKey("secure")) c.setSecure(Boolean.parseBoolean(params.get("secure"))); if (params.containsKey("wrap")) c.setWrap(Boolean.parseBoolean(params.get("wrap"))); } cookies.add(c); return this; }
Example 4
Source File: DefaultCookieManager.java From redant with Apache License 2.0 | 5 votes |
@Override public void addCookie(String name, String value, String domain, long maxAge) { if (StrUtil.isNotBlank(name) && StrUtil.isNotBlank(value)) { Cookie cookie = new DefaultCookie(name, value); cookie.setPath("/"); if (domain != null && domain.trim().length() > 0) { cookie.setDomain(domain); } if (maxAge > 0) { cookie.setMaxAge(maxAge); } setCookie(cookie); } }