Example usage for org.apache.http.client.cache HttpCacheEntry hasVariants

List of usage examples for org.apache.http.client.cache HttpCacheEntry hasVariants

Introduction

In this page you can find the example usage for org.apache.http.client.cache HttpCacheEntry hasVariants.

Prototype

public boolean hasVariants() 

Source Link

Document

Indicates whether the origin response indicated the associated resource had variants (i.e.

Usage

From source file:org.apache.http.impl.client.cache.BasicHttpCache.java

void storeInCache(HttpHost target, HttpRequest request, HttpCacheEntry entry) throws IOException {
    if (entry.hasVariants()) {
        storeVariantEntry(target, request, entry);
    } else {/*w w  w.  j a  v a  2s.  co  m*/
        storeNonVariantEntry(target, request, entry);
    }
}

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);
    }/*from   www  .j  av a2  s .co m*/
    return variants;
}