public String generateVariantKey(final HttpRequest request, final Collection<String> variantNames) {
        Args.notNull(variantNames, "Variant names");
        final StringBuilder buf = new StringBuilder("{");
        final AtomicBoolean firstHeader = new AtomicBoolean();
        variantNames.stream()
                .map(h -> h.toLowerCase(Locale.ROOT))
                .sorted()
                .distinct()
                .forEach(h -> {
                    if (!firstHeader.compareAndSet(false, true)) {
                        buf.append("&");
                    }
                    buf.append(PercentCodec.encode(h, StandardCharsets.UTF_8)).append("=");
                    final AtomicBoolean firstToken = new AtomicBoolean();
                    normalizeElements(request, h, t -> {
                        if (!firstToken.compareAndSet(false, true)) {
                            buf.append(",");
                        }
                        buf.append(PercentCodec.encode(t, StandardCharsets.UTF_8));
                    });
                });
        buf.append("}");
        return buf.toString();
    }
Computes a "variant key" for the given request and the given variants.
@param request originating request
@param variantNames variant names
@return variant key

@since 5.4
httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CacheKeyGenerator.java