diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ConditionalRequestBuilder.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ConditionalRequestBuilder.java index ec923ab73..eb2a67f93 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ConditionalRequestBuilder.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ConditionalRequestBuilder.java @@ -34,6 +34,7 @@ import org.apache.hc.core5.function.Factory; import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.HttpHeaders; import org.apache.hc.core5.http.HttpRequest; +import org.apache.hc.core5.http.message.MessageSupport; class ConditionalRequestBuilder { @@ -85,19 +86,7 @@ class ConditionalRequestBuilder { */ public T buildConditionalRequestFromVariants(final T request, final Map variants) { final T newRequest = messageCopier.create(request); - - // we do not support partial content so all etags are used - final StringBuilder etags = new StringBuilder(); - boolean first = true; - for(final String etag : variants.keySet()) { - if (!first) { - etags.append(","); - } - first = false; - etags.append(etag); - } - - newRequest.setHeader(HttpHeaders.IF_NONE_MATCH, etags.toString()); + newRequest.setHeader(MessageSupport.format(HttpHeaders.IF_NONE_MATCH, variants.keySet())); return newRequest; }