From 0c79379827ebe9ae73a8651d662b1ed3e6201d02 Mon Sep 17 00:00:00 2001 From: Oleg Kalnichevski Date: Sun, 18 Jun 2023 17:14:53 +0200 Subject: [PATCH] Code optimization --- .../impl/cache/ConditionalRequestBuilder.java | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) 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; }