org.zodiac.netty.http.headers.WebSocketProtocolsHeader Maven / Gradle / Ivy
package org.zodiac.netty.http.headers;
import org.zodiac.sdk.toolkit.util.lang.StrUtil;
import io.netty.handler.codec.http.HttpHeaderNames;
final class WebSocketProtocolsHeader extends AbstractHeader {
private static final CharSequence COMMA = StrUtil.singleChar(',');
WebSocketProtocolsHeader() {
super(CharSequence[].class, HttpHeaderNames.WEBSOCKET_PROTOCOL);
}
@Override
public CharSequence toCharSequence(CharSequence[] value) {
return StrUtil.join(',', value);
}
@Override
public CharSequence[] toValue(CharSequence value) {
CharSequence[] result = StrUtil.splitToArray(value, ',');
for (int i = 0; i < result.length; i++) {
result[i] = StrUtil.trim(result[i]);
}
return result;
}
}