/** * When a {@link HttpCacheEntry} does not exist for a specific * {@link org.apache.hc.core5.http.HttpRequest} we attempt to see if an existing * {@link HttpCacheEntry} is appropriate by building a conditional * {@link org.apache.hc.core5.http.HttpRequest} using the variants' ETag values. * If no such values exist, the request is unmodified * * @param request the original request from the caller * @param variants * @return the wrapped request */ public T buildConditionalRequestFromVariants(final T request, final Map<String, Variant> variants) { final T newRequest = messageCopier.copy(request); newRequest.setHeaders(request.getHeaders()); // 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(HeaderConstants.IF_NONE_MATCH, etags.toString()); return newRequest; }
newRequest.setHeaders(request.getHeaders()); final Header eTag = cacheEntry.getFirstHeader(HeaderConstants.ETAG); if (eTag != null) {
/** * When a {@link HttpCacheEntry} does not exist for a specific * {@link org.apache.hc.core5.http.HttpRequest} we attempt to see if an existing * {@link HttpCacheEntry} is appropriate by building a conditional * {@link org.apache.hc.core5.http.HttpRequest} using the variants' ETag values. * If no such values exist, the request is unmodified * * @param request the original request from the caller * @param variants * @return the wrapped request */ public T buildConditionalRequestFromVariants(final T request, final Map<String, Variant> variants) { final T newRequest = messageCopier.copy(request); newRequest.setHeaders(request.getHeaders()); // 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(HeaderConstants.IF_NONE_MATCH, etags.toString()); return newRequest; }
request.setHeaders(); for (final Iterator<Header> it = original.headerIterator(); it.hasNext(); ) { request.addHeader(it.next());
newRequest.setHeaders(request.getHeaders()); final Header eTag = cacheEntry.getFirstHeader(HeaderConstants.ETAG); if (eTag != null) {
if (!StandardMethods.isSafe(request.getMethod())) { final HttpRequest httpGet = new BasicHttpRequest(StandardMethods.GET.name(), redirectUri); httpGet.setHeaders(scope.originalRequest.getHeaders()); state.currentRequest = httpGet; state.currentEntityProducer = null;