@Test public void makeSureHEADRequestInvalidatesCacheIfNot304() throws Exception { LocalDateTime base = LocalDateTime.of(2010, 2, 3, 10, 0, 0, 0); Headers headers = new Headers(); headers = headers.add(new CacheControl.Builder().maxAge(50).withPrivate().build().toHeader()); headers = headers.add(HeaderUtils.toHttpDate(HeaderConstants.DATE, base)); HTTPResponse cachedResponse = new HTTPResponse(createClosedPayload(), Status.OK, headers); CacheItem item = new DefaultCacheItem(cachedResponse) { @Override public boolean isStale(LocalDateTime requestTime) { return true; } }; when(cacheStorage.get(isA(HTTPRequest.class))).thenReturn(item); HTTPRequest request = new HTTPRequest(REQUEST_URI, HTTPMethod.HEAD); base = base.plusHours(1); when(responseResolver.resolve(request)).thenReturn(new HTTPResponse(Status.NOT_FOUND, new Headers().withDate(base))); HTTPResponse response = cache.execute(request); verify(cacheStorage, atLeastOnce()).invalidate(REQUEST_URI); assertFalse(response.getPayload().isPresent()); }
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);  }