/** * Returns a request to unconditionally validate a cache entry with * the origin. In certain cases (due to multiple intervening caches) * our cache may actually receive a response to a normal conditional * validation where the Date header is actually older than that of * our current cache entry. In this case, the protocol recommendation * is to retry the validation and force syncup with the origin. * @param request client request we are trying to satisfy * @return an unconditional validation request */ public T buildUnconditionalRequest(final T request) { final T newRequest = messageCopier.copy(request); newRequest.addHeader(HeaderConstants.CACHE_CONTROL,HeaderConstants.CACHE_CONTROL_NO_CACHE); newRequest.addHeader(HeaderConstants.PRAGMA,HeaderConstants.CACHE_CONTROL_NO_CACHE); newRequest.removeHeaders(HeaderConstants.IF_RANGE); newRequest.removeHeaders(HeaderConstants.IF_MATCH); newRequest.removeHeaders(HeaderConstants.IF_NONE_MATCH); newRequest.removeHeaders(HeaderConstants.IF_UNMODIFIED_SINCE); newRequest.removeHeaders(HeaderConstants.IF_MODIFIED_SINCE); return newRequest; }
private void decrementOPTIONSMaxForwardsIfGreaterThen0(final HttpRequest request) { if (!HeaderConstants.OPTIONS_METHOD.equals(request.getMethod())) { return; } final Header maxForwards = request.getFirstHeader(HeaderConstants.MAX_FORWARDS); if (maxForwards == null) { return; } request.removeHeaders(HeaderConstants.MAX_FORWARDS); final int currentMaxForwards = Integer.parseInt(maxForwards.getValue()); request.setHeader(HeaderConstants.MAX_FORWARDS, Integer.toString(currentMaxForwards - 1)); }
private void stripOtherFreshnessDirectivesWithNoCache(final HttpRequest request) { final List<HeaderElement> outElts = new ArrayList<>(); boolean shouldStrip = false; final Iterator<HeaderElement> it = MessageSupport.iterate(request, HeaderConstants.CACHE_CONTROL); while (it.hasNext()) { final HeaderElement elt = it.next(); if (!disallowedWithNoCache.contains(elt.getName())) { outElts.add(elt); } if (HeaderConstants.CACHE_CONTROL_NO_CACHE.equals(elt.getName())) { shouldStrip = true; } } if (!shouldStrip) { return; } request.removeHeaders(HeaderConstants.CACHE_CONTROL); request.setHeader(HeaderConstants.CACHE_CONTROL, buildHeaderFromElements(outElts)); }
/** * Returns a request to unconditionally validate a cache entry with * the origin. In certain cases (due to multiple intervening caches) * our cache may actually receive a response to a normal conditional * validation where the Date header is actually older than that of * our current cache entry. In this case, the protocol recommendation * is to retry the validation and force syncup with the origin. * @param request client request we are trying to satisfy * @return an unconditional validation request */ public T buildUnconditionalRequest(final T request) { final T newRequest = messageCopier.copy(request); newRequest.addHeader(HeaderConstants.CACHE_CONTROL,HeaderConstants.CACHE_CONTROL_NO_CACHE); newRequest.addHeader(HeaderConstants.PRAGMA,HeaderConstants.CACHE_CONTROL_NO_CACHE); newRequest.removeHeaders(HeaderConstants.IF_RANGE); newRequest.removeHeaders(HeaderConstants.IF_MATCH); newRequest.removeHeaders(HeaderConstants.IF_NONE_MATCH); newRequest.removeHeaders(HeaderConstants.IF_UNMODIFIED_SINCE); newRequest.removeHeaders(HeaderConstants.IF_MODIFIED_SINCE); return newRequest; }
private void decrementOPTIONSMaxForwardsIfGreaterThen0(final HttpRequest request) { if (!HeaderConstants.OPTIONS_METHOD.equals(request.getMethod())) { return; } final Header maxForwards = request.getFirstHeader(HeaderConstants.MAX_FORWARDS); if (maxForwards == null) { return; } request.removeHeaders(HeaderConstants.MAX_FORWARDS); final int currentMaxForwards = Integer.parseInt(maxForwards.getValue()); request.setHeader(HeaderConstants.MAX_FORWARDS, Integer.toString(currentMaxForwards - 1)); }
private void stripOtherFreshnessDirectivesWithNoCache(final HttpRequest request) { final List<HeaderElement> outElts = new ArrayList<>(); boolean shouldStrip = false; final Iterator<HeaderElement> it = MessageSupport.iterate(request, HeaderConstants.CACHE_CONTROL); while (it.hasNext()) { final HeaderElement elt = it.next(); if (!disallowedWithNoCache.contains(elt.getName())) { outElts.add(elt); } if (HeaderConstants.CACHE_CONTROL_NO_CACHE.equals(elt.getName())) { shouldStrip = true; } } if (!shouldStrip) { return; } request.removeHeaders(HeaderConstants.CACHE_CONTROL); request.setHeader(HeaderConstants.CACHE_CONTROL, buildHeaderFromElements(outElts)); }
Args.notNull(request, "HTTP request"); if (this.overwrite) { request.removeHeaders(HttpHeaders.TRANSFER_ENCODING); request.removeHeaders(HttpHeaders.CONTENT_LENGTH); } else { if (request.containsHeader(HttpHeaders.TRANSFER_ENCODING)) {
Args.notNull(request, "HTTP request"); if (this.overwrite) { request.removeHeaders(HttpHeaders.TRANSFER_ENCODING); request.removeHeaders(HttpHeaders.CONTENT_LENGTH); } else { if (request.containsHeader(HttpHeaders.TRANSFER_ENCODING)) {