All Downloads are FREE. Search and download functionalities are using the official Maven repository.

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;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy