@Nullable
    static CookieBuilder initCookie(Logger logger, boolean strict,
                                    String header, int nameBegin, int nameEnd, int valueBegin, int valueEnd) {
        if (nameBegin == -1 || nameBegin == nameEnd) {
            logger.debug("Skipping cookie with null name");
            return null;
        }

        if (valueBegin == -1) {
            logger.debug("Skipping cookie with null value");
            return null;
        }

        final CharSequence wrappedValue = CharBuffer.wrap(header, valueBegin, valueEnd);
        final CharSequence unwrappedValue = unwrapValue(wrappedValue);
        if (unwrappedValue == null) {
            logger.debug("Skipping cookie because starting quotes are not properly balanced in '{}'",
                         wrappedValue);
            return null;
        }

        final String name = header.substring(nameBegin, nameEnd);

        int invalidOctetPos;
        if (strict && (invalidOctetPos = firstInvalidCookieNameOctet(name)) >= 0) {
            if (logger.isDebugEnabled()) {
                logger.debug("Skipping cookie because name '{}' contains invalid char '{}'",
                             name, name.charAt(invalidOctetPos));
            }
            return null;
        }

        final boolean valueQuoted = unwrappedValue.length() != valueEnd - valueBegin;

        if (strict && (invalidOctetPos = firstInvalidCookieValueOctet(unwrappedValue)) >= 0) {
            if (logger.isDebugEnabled()) {
                logger.debug("Skipping cookie because value '{}' contains invalid char '{}'",
                             unwrappedValue, unwrappedValue.charAt(invalidOctetPos));
            }
            return null;
        }

        return Cookie.builder(name, unwrappedValue.toString()).valueQuoted(valueQuoted);
    }
Strips out the trailing 2-char separator from the specified {@link StringBuilder}.

@param buf a buffer where some cookies were encoded.
@return the {@link String} without the trailing separator
core/src/main/java/com/linecorp/armeria/common/CookieUtil.java