protected void flushUriIfSameHost(final URL requestURL, final URL targetURL) { final URL canonicalTarget = getAbsoluteURL(cacheKeyGenerator.canonicalizeUri(targetURL.toString())); if (canonicalTarget == null) { return; } if (canonicalTarget.getAuthority().equalsIgnoreCase(requestURL.getAuthority())) { flushEntry(canonicalTarget.toString()); } }
protected void flushUriIfSameHost(URL requestURL, URL targetURL) { URL canonicalTarget = getAbsoluteURL(cacheKeyGenerator.canonicalizeUri(targetURL.toString())); if (canonicalTarget == null) return; if (canonicalTarget.getAuthority().equalsIgnoreCase(requestURL.getAuthority())) { flushEntry(canonicalTarget.toString()); } }
/** * For a given {@link HttpHost} and {@link HttpRequest} get a URI from the * pair that I can use as an identifier KEY into my HttpCache * * @param host The host for this request * @param req the {@link HttpRequest} * @return String the extracted URI */ public String getURI(final HttpHost host, final HttpRequest req) { if (isRelativeRequest(req)) { return canonicalizeUri(String.format("%s%s", host.toString(), req.getRequestLine().getUri())); } return canonicalizeUri(req.getRequestLine().getUri()); }
/** * For a given {@link HttpHost} and {@link HttpRequest} get a URI from the * pair that I can use as an identifier KEY into my HttpCache * * @param host The host for this request * @param req the {@link HttpRequest} * @return String the extracted URI */ public String getURI(HttpHost host, HttpRequest req) { if (isRelativeRequest(req)) { return canonicalizeUri(String.format("%s%s", host.toString(), req.getRequestLine().getUri())); } return canonicalizeUri(req.getRequestLine().getUri()); }
private void flushLocationCacheEntry(final URL reqURL, final HttpResponse response, final URL location) { final String cacheKey = cacheKeyGenerator.canonicalizeUri(location.toString()); final HttpCacheEntry entry = getEntry(cacheKey); if (entry == null) { return; } // do not invalidate if response is strictly older than entry // or if the etags match if (responseDateOlderThanEntryDate(response, entry)) { return; } if (!responseAndEntryEtagsDiffer(response, entry)) { return; } flushUriIfSameHost(reqURL, location); }
/** Flushes entries that were invalidated by the given response * received for the given host/request pair. */ public void flushInvalidatedCacheEntries(HttpHost host, HttpRequest request, HttpResponse response) { int status = response.getStatusLine().getStatusCode(); if (status < 200 || status > 299) return; URL reqURL = getAbsoluteURL(cacheKeyGenerator.getURI(host, request)); if (reqURL == null) return; URL canonURL = getContentLocationURL(reqURL, response); if (canonURL == null) return; String cacheKey = cacheKeyGenerator.canonicalizeUri(canonURL.toString()); HttpCacheEntry entry = getEntry(cacheKey); if (entry == null) return; if (!responseDateNewerThanEntryDate(response, entry)) return; if (!responseAndEntryEtagsDiffer(response, entry)) return; flushUriIfSameHost(reqURL, canonURL); }