org.zodiac.netty.http.headers.FrameOptionsHeader Maven / Gradle / Ivy
package org.zodiac.netty.http.headers;
import org.zodiac.commons.http.entities.FrameOptions;
import io.netty.util.AsciiString;
class FrameOptionsHeader extends AbstractHeader {
private static final AsciiString X_FRAME_OPTIONS = AsciiString.of("x-frame-options");
private static final AsciiString DENY = AsciiString.of("DENY");
private static final AsciiString SAMEORIGIN = AsciiString.of("SAMEORIGIN");
FrameOptionsHeader() {
super(FrameOptions.class, X_FRAME_OPTIONS);
}
@Override
public CharSequence toCharSequence(FrameOptions value) {
return AsciiString.of(value.toString());
}
@Override
public boolean is(CharSequence name) {
return X_FRAME_OPTIONS.contentEqualsIgnoreCase(name);
}
@Override
public FrameOptions toValue(CharSequence value) {
if (value == DENY || DENY.contentEqualsIgnoreCase(value)) {
return FrameOptions.DENY;
} else if (value == SAMEORIGIN || SAMEORIGIN.contentEqualsIgnoreCase(value)) {
return FrameOptions.SAMEORIGIN;
}
return FrameOptions.parse(value);
}
}