@Test public void testCacheWithRequestAllowingStaleReponse() throws IOException { LocalDateTime now = LocalDateTime.of(2010, 2, 3, 10, 0, 0, 0); Headers headers = new Headers(); headers = headers.add(new Header("Cache-Control", "private, max-age=5")); headers = headers.add(HeaderUtils.toHttpDate(HeaderConstants.DATE, now)); HTTPResponse cachedResponse = new HTTPResponse(Status.OK, headers); CacheItem item = new DefaultCacheItem(cachedResponse, now); now = LocalDateTime.of(2010, 2, 3, 10, 0, 10, 0); HTTPRequest request = new HTTPRequest(REQUEST_URI).headers(new Headers().add(HeaderConstants.CACHE_CONTROL, "max-stale=10")); when(cacheStorage.get(isA(HTTPRequest.class))).thenReturn(item); assertTrue("Item was not stale", item.isStale(now)); HTTPResponse response = cache.execute(request); verify(responseResolver, never()).resolve(request); assertTrue("No warn header", response.getHeaders().contains("warning")); }
public HTTPResponse execute(final HTTPRequest request) { return execute(request, helper.isEndToEndReloadRequest(request)); }
HTTPCache { public HTTPResponse execute(final HTTPRequest request) { return execute(request, helper.isEndToEndReloadRequest(request)); } }
HTTPCache { public HTTPResponse execute(final HTTPRequest request) { return execute(request, helper.isEndToEndReloadRequest(request)); } HTTPCache(CacheStorage storage, ResponseResolver resolver); }
HTTPCache { public HTTPResponse execute(final HTTPRequest request) { return execute(request, helper.isEndToEndReloadRequest(request)); } HTTPCache(CacheStorage storage, ResponseResolver resolver); void clear(); CacheStorage getStorage(); ResponseResolver getResolver(); CacheStatistics getStatistics(); HTTPResponse execute(final HTTPRequest request); HTTPResponse executeRefresh(final HTTPRequest request); void shutdown(); boolean isTranslateHEADToGET(); void setTranslateHEADToGET(boolean translateHEADToGET); }
HTTPCache { public HTTPResponse execute(final HTTPRequest request) { return execute(request, helper.isEndToEndReloadRequest(request)); } HTTPCache(CacheStorage storage, ResponseResolver resolver); void clear(); CacheStorage getStorage(); ResponseResolver getResolver(); CacheStatistics getStatistics(); HTTPResponse execute(final HTTPRequest request); HTTPResponse executeRefresh(final HTTPRequest request); void shutdown(); boolean isTranslateHEADToGET(); void setTranslateHEADToGET(boolean translateHEADToGET);  }