List of usage examples for org.apache.http.client.cache HttpCacheEntry getVariantMap
public Map<String, String> getVariantMap()
From source file:org.apache.http.impl.client.cache.BasicHttpCache.java
HttpCacheEntry doGetUpdatedParentEntry(final String requestId, final HttpCacheEntry existing, final HttpCacheEntry entry, final String variantKey, final String variantCacheKey) throws IOException { HttpCacheEntry src = existing; if (src == null) { src = entry;// w w w. j av a2 s . c o m } Resource resource = resourceFactory.copy(requestId, src.getResource()); Map<String, String> variantMap = new HashMap<String, String>(src.getVariantMap()); variantMap.put(variantKey, variantCacheKey); return new HttpCacheEntry(src.getRequestDate(), src.getResponseDate(), src.getStatusLine(), src.getAllHeaders(), resource, variantMap); }
From source file:org.apache.http.impl.client.cache.BasicHttpCache.java
public HttpCacheEntry getCacheEntry(HttpHost host, HttpRequest request) throws IOException { HttpCacheEntry root = storage.getEntry(uriExtractor.getURI(host, request)); if (root == null) return null; if (!root.hasVariants()) return root; String variantCacheKey = root.getVariantMap().get(uriExtractor.getVariantKey(request, root)); if (variantCacheKey == null) return null; return storage.getEntry(variantCacheKey); }
From source file:org.apache.http.impl.client.cache.BasicHttpCache.java
public Map<String, Variant> getVariantCacheEntriesWithEtags(HttpHost host, HttpRequest request) throws IOException { Map<String, Variant> variants = new HashMap<String, Variant>(); HttpCacheEntry root = storage.getEntry(uriExtractor.getURI(host, request)); if (root == null || !root.hasVariants()) return variants; for (Map.Entry<String, String> variant : root.getVariantMap().entrySet()) { String variantKey = variant.getKey(); String variantCacheKey = variant.getValue(); addVariantWithEtag(variantKey, variantCacheKey, variants); }/* ww w .jav a2s . c o m*/ return variants; }
From source file:org.apache.http.impl.client.cache.CacheInvalidator.java
/** * Remove cache entries from the cache that are no longer fresh or * have been invalidated in some way./*from w w w .ja va 2 s . c o m*/ * * @param host The backend host we are talking to * @param req The HttpRequest to that host */ public void flushInvalidatedCacheEntries(HttpHost host, HttpRequest req) { if (requestShouldNotBeCached(req)) { log.debug("Request should not be cached"); String theUri = cacheKeyGenerator.getURI(host, req); HttpCacheEntry parent = getEntry(theUri); log.debug("parent entry: " + parent); if (parent != null) { for (String variantURI : parent.getVariantMap().values()) { flushEntry(variantURI); } flushEntry(theUri); } URL reqURL = getAbsoluteURL(theUri); if (reqURL == null) { log.error("Couldn't transform request into valid URL"); return; } Header clHdr = req.getFirstHeader("Content-Location"); if (clHdr != null) { String contentLocation = clHdr.getValue(); if (!flushAbsoluteUriFromSameHost(reqURL, contentLocation)) { flushRelativeUriFromSameHost(reqURL, contentLocation); } } Header lHdr = req.getFirstHeader("Location"); if (lHdr != null) { flushAbsoluteUriFromSameHost(reqURL, lHdr.getValue()); } } }