static String encode(boolean strict, Cookie... cookies) {
        assert cookies.length != 0 : cookies.length;

        final StringBuilder buf = stringBuilder();
        if (strict) {
            if (cookies.length == 1) {
                encode(true, buf, cookies[0]);
            } else {
                final Cookie[] cookiesSorted = Arrays.copyOf(cookies, cookies.length);
                Arrays.sort(cookiesSorted, COOKIE_COMPARATOR);
                for (Cookie c : cookiesSorted) {
                    encode(true, buf, c);
                }
            }
        } else {
            for (Cookie c : cookies) {
                encode(false, buf, c);
            }
        }
        return stripTrailingSeparator(buf);
    }
Encodes the specified cookies into a single {@code "Cookie"} header value.

@param strict whether to validate that name and value chars are in the valid scope and
              to sort the cookies into order of decreasing path length, as specified in RFC 6265.
              If {@code false}, the cookies are encoded in the order in which they are given.
@param cookies the {@link Cookie}s to encode.
@return a RFC 6265-style {@code "Cookie"} header value.
core/src/main/java/com/linecorp/armeria/common/ClientCookieEncoder.java