Java Code Examples for io.netty.handler.codec.http.cookie.Cookie#setSecure()

The following examples show how to use io.netty.handler.codec.http.cookie.Cookie#setSecure() . 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 vote down vote up
@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 vote down vote up
@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 vote down vote up
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: HttpResponse.java    From blade with Apache License 2.0 5 votes vote down vote up
@Override
public Response cookie(@NonNull String name, @NonNull String value, int maxAge, boolean secured) {
    Cookie nettyCookie = new io.netty.handler.codec.http.cookie.DefaultCookie(name, value);
    nettyCookie.setPath("/");
    nettyCookie.setMaxAge(maxAge);
    nettyCookie.setSecure(secured);
    this.cookies.add(nettyCookie);
    return this;
}
 
Example 5
Source File: HttpResponse.java    From blade with Apache License 2.0 5 votes vote down vote up
@Override
public Response cookie(@NonNull String path, @NonNull String name, @NonNull String value, int maxAge, boolean secured) {
    Cookie nettyCookie = new io.netty.handler.codec.http.cookie.DefaultCookie(name, value);
    nettyCookie.setMaxAge(maxAge);
    nettyCookie.setSecure(secured);
    nettyCookie.setPath(path);
    this.cookies.add(nettyCookie);
    return this;
}