com.github.dreamhead.moco.util.Cookies Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of moco-core Show documentation
Show all versions of moco-core Show documentation
Moco is an easy setup stub framework, mainly focusing on testing and integration.
package com.github.dreamhead.moco.util;
import com.github.dreamhead.moco.CookieAttribute;
import com.github.dreamhead.moco.cookie.ActualCookieAttribute;
import io.netty.handler.codec.http.cookie.ServerCookieEncoder;
import io.netty.handler.codec.http.cookie.Cookie;
import io.netty.handler.codec.http.cookie.DefaultCookie;
public final class Cookies {
public String encodeCookie(final String key, final String value, final CookieAttribute... options) {
Cookie cookie = new DefaultCookie(key, value);
for (CookieAttribute option : options) {
((ActualCookieAttribute) option).visit(cookie);
}
return ServerCookieEncoder.STRICT.encode(cookie);
}
}