org.zodiac.netty.http.headers.SetCookieHeaderNetty428 Maven / Gradle / Ivy
package org.zodiac.netty.http.headers;
import java.util.Objects;
import io.netty.handler.codec.http.cookie.ClientCookieDecoder;
import io.netty.handler.codec.http.cookie.Cookie;
import io.netty.handler.codec.http.cookie.ServerCookieEncoder;
final class SetCookieHeaderNetty428 extends AbstractHeader {
private final boolean strict;
SetCookieHeaderNetty428(CharSequence name, boolean strict) {
super(Cookie.class, name);
this.strict = strict;
}
@Override
public String toString(Cookie value) {
return strict ? ServerCookieEncoder.STRICT.encode(value)
: ServerCookieEncoder.LAX.encode(value);
}
@Override
public Cookie toValue(CharSequence value) {
return strict ? ClientCookieDecoder.STRICT.decode(Objects.requireNonNull(value, "value").toString())
: ClientCookieDecoder.LAX.decode(value.toString());
}
}