Examples of HttpCacheEntry


Examples of org.apache.http.client.cache.HttpCacheEntry

        return callBackend(target, request, context);
    }

    private HttpCacheEntry satisfyFromCache(HttpHost target, HttpRequest request) {
        HttpCacheEntry entry = null;
        try {
            entry = responseCache.getCacheEntry(target, request);
        } catch (IOException ioe) {
            log.warn("Unable to retrieve entries from cache", ioe);
        }
View Full Code Here

Examples of org.apache.http.client.cache.HttpCacheEntry

        if (matchingVariant == null) {
            log.debug("304 response did not contain ETag matching one sent in If-None-Match");
            return callBackend(target, request, context);
        }

        HttpCacheEntry matchedEntry = matchingVariant.getEntry();
       
        if (revalidationResponseIsTooOld(backendResponse, matchedEntry)) {
            return retryRequestUnconditionally(target, request, context,
                    matchedEntry);
        }
       
        recordCacheUpdate(context);

        HttpCacheEntry responseEntry = getUpdatedVariantEntry(target,
                conditionalRequest, requestDate, responseDate, backendResponse,
                matchingVariant, matchedEntry);

        HttpResponse resp = responseGenerator.generateResponse(responseEntry);
        tryToUpdateVariantMap(target, request, matchingVariant);
View Full Code Here

Examples of org.apache.http.client.cache.HttpCacheEntry

    private HttpCacheEntry getUpdatedVariantEntry(HttpHost target,
            HttpRequest conditionalRequest, Date requestDate,
            Date responseDate, HttpResponse backendResponse,
            Variant matchingVariant, HttpCacheEntry matchedEntry) {
        HttpCacheEntry responseEntry = matchedEntry;
        try {
            responseEntry = responseCache.updateVariantCacheEntry(target, conditionalRequest,
                    matchedEntry, backendResponse, requestDate, responseDate, matchingVariant.getCacheKey());
        } catch (IOException ioe) {
            log.warn("Could not update cache entry", ioe);
View Full Code Here

Examples of org.apache.http.client.cache.HttpCacheEntry

        if (statusCode == HttpStatus.SC_NOT_MODIFIED || statusCode == HttpStatus.SC_OK) {
            recordCacheUpdate(context);
        }

        if (statusCode == HttpStatus.SC_NOT_MODIFIED) {
            HttpCacheEntry updatedEntry = responseCache.updateCacheEntry(target, request, cacheEntry,
                    backendResponse, requestDate, responseDate);
            if (suitabilityChecker.isConditional(request)
                    && suitabilityChecker.allConditionalsMatch(request, updatedEntry, new Date())) {
                return responseGenerator.generateNotModifiedResponse(updatedEntry);
            }
View Full Code Here

Examples of org.apache.http.client.cache.HttpCacheEntry

        return backendResponse;
    }

    private boolean alreadyHaveNewerCacheEntry(HttpHost target, HttpRequest request,
            HttpResponse backendResponse) {
        HttpCacheEntry existing = null;
        try {
            existing = responseCache.getCacheEntry(target, request);
        } catch (IOException ioe) {
            // nop
        }
        if (existing == null) return false;
        Header entryDateHeader = existing.getFirstHeader("Date");
        if (entryDateHeader == null) return false;
        Header responseDateHeader = backendResponse.getFirstHeader("Date");
        if (responseDateHeader == null) return false;
        try {
            Date entryDate = DateUtils.parseDate(entryDateHeader.getValue());
View Full Code Here

Examples of org.apache.http.client.cache.HttpCacheEntry

            throws HttpCacheUpdateException, IOException {
        int numRetries = 0;
        do {
            try {
                CASValue<Object> v = client.gets(url);
                HttpCacheEntry existingEntry = (v == null) ? null
                        : reconstituteEntry(v.getValue());
                HttpCacheEntry updatedEntry = callback.update(existingEntry);

                if (v == null) {
                    putEntry(url, updatedEntry);
                    return;
View Full Code Here

Examples of org.apache.http.client.cache.HttpCacheEntry

    @Test
    public void testApparentAgeIsMaxIntIfDateHeaderNotPresent() {
        Header[] headers = {
                new BasicHeader("Server", "MockServer/1.0")
        };
        HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(headers);
        assertEquals(2147483648L, impl.getApparentAgeSecs(entry));
    }
View Full Code Here

Examples of org.apache.http.client.cache.HttpCacheEntry

    @Test
    public void testApparentAgeIsResponseReceivedTimeLessDateHeader() {
        Header[] headers = new Header[] { new BasicHeader("Date", DateUtils
                .formatDate(tenSecondsAgo)) };

        HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(now, sixSecondsAgo, headers);
        assertEquals(4, impl.getApparentAgeSecs(entry));
    }
View Full Code Here

Examples of org.apache.http.client.cache.HttpCacheEntry

    @Test
    public void testNegativeApparentAgeIsBroughtUpToZero() {
        Header[] headers = new Header[] { new BasicHeader("Date", DateUtils
                .formatDate(sixSecondsAgo)) };
        HttpCacheEntry entry  = HttpTestUtils.makeCacheEntry(now,tenSecondsAgo,headers);
        assertEquals(0, impl.getApparentAgeSecs(entry));
    }
View Full Code Here

Examples of org.apache.http.client.cache.HttpCacheEntry

    }

    @Test
    public void testCorrectedReceivedAgeIsAgeHeaderIfLarger() {
        Header[] headers = new Header[] { new BasicHeader("Age", "10"), };
        HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(headers);
        impl = new CacheValidityPolicy() {
            @Override
            protected long getApparentAgeSecs(HttpCacheEntry entry) {
                return 6;
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.