/** * @return A new HttpResponse. */ public HttpResponse create() { if (getNumChanges() != responseObjNumChanges || responseObj == null) { // Short-circuit the creation process: no need to create a // new (immutable) HttpResponse object when no modifications occurred. responseObj = new HttpResponse(this); responseObjNumChanges = getNumChanges(); } return responseObj; }
public void invalidateApplicationResources(Set<Uri> uris, SecurityToken token) { // TODO Add checks on content for (Uri uri : uris) { httpCache.removeResponse(new HttpRequest(uri)); } }
private static void assertAllowsNegativeCaching(int status) { HttpResponse response = new HttpResponseBuilder() .setHttpStatusCode(status) .setResponse(UTF8_DATA) .setStrictNoCache() .create(); long ttl = response.getCacheTtl(); assertTrue(ttl <= response.getDefaultTtl() && ttl > 0); }
private static void assertDoesNotAllowNegativeCaching(int status) { HttpResponse response = new HttpResponseBuilder() .setHttpStatusCode(status) .setResponse(UTF8_DATA) .setStrictNoCache() .create(); assertEquals(-1, response.getCacheTtl()); }
@Test public void testFetchWithInvalidationEnabled() throws Exception { cache.addResponse(new HttpRequest(URI), CACHEABLE); assertEquals(CACHEABLE, requestPipeline.execute(new HttpRequest(URI))); }
public HttpResponse getResponse(HttpRequest request) { if (isCacheable(request)) { String keyString = createKey(request); HttpResponse cached = getResponseImpl(keyString); if (responseStillUsable(cached) && (!cached.isStrictNoCache() || refetchStrictNoCacheAfterMs >= 0)) { return cached; } } return null; }
/** * Verifies that the cache TTL is within acceptable ranges. * This always rounds down due to timing, so actual verification will be against maxAge - 1. */ private static void assertTtlOk(int maxAge, HttpResponse response) { assertEquals(maxAge - 1, roundToSeconds(response.getCacheTtl() - 1)); }
public RequestContext call() { HttpResponse httpResp = null; GadgetException gadgetException = null; try { httpResp = requestPipeline.execute(httpReq); } catch (GadgetException e){ gadgetException = e; } return new RequestContext(httpReq, httpResp, gadgetException); } }
private static void assertAllowsNegativeCaching(int status) { HttpResponse response = new HttpResponseBuilder() .setHttpStatusCode(status) .setResponse(UTF8_DATA) .setStrictNoCache() .create(); long ttl = response.getCacheTtl(); assertTrue(ttl <= response.getDefaultTtl() && ttl > 0); }
private static void assertDoesNotAllowNegativeCaching(int status) { HttpResponse response = new HttpResponseBuilder() .setHttpStatusCode(status) .setResponse(UTF8_DATA) .setStrictNoCache() .create(); assertEquals(-1, response.getCacheTtl()); }
@Test public void testFetchWithInvalidationEnabled() throws Exception { cache.addResponse(new HttpRequest(URI), CACHEABLE); assertEquals(CACHEABLE, requestPipeline.execute(new HttpRequest(URI))); }
/** * @return A new HttpResponse. */ public HttpResponse create() { if (getNumChanges() != responseObjNumChanges || responseObj == null) { // Short-circuit the creation process: no need to create a // new (immutable) HttpResponse object when no modifications occurred. responseObj = new HttpResponse(this); responseObjNumChanges = getNumChanges(); } return responseObj; }
/** * Verifies that the cache TTL is within acceptable ranges. * This always rounds down due to timing, so actual verification will be against maxAge - 1. */ private static void assertTtlOk(int maxAge, HttpResponse response) { assertEquals(maxAge - 1, roundToSeconds(response.getCacheTtl() - 1)); }
public void invalidateApplicationResources(Set<Uri> uris, SecurityToken token) { // TODO Add checks on content for (Uri uri : uris) { httpCache.removeResponse(new HttpRequest(uri)); } }
private static void assertAllowsNegativeCaching(int status) { HttpResponse response = new HttpResponseBuilder() .setHttpStatusCode(status) .setResponse(UTF8_DATA) .setStrictNoCache() .create(); long ttl = response.getCacheTtl(); assertTrue(ttl <= response.getDefaultTtl() && ttl > 0); }
private static void assertDoesNotAllowNegativeCaching(int status) { HttpResponse response = new HttpResponseBuilder() .setHttpStatusCode(status) .setResponse(UTF8_DATA) .setStrictNoCache() .create(); assertEquals(-1, response.getCacheTtl()); }
/** * @return A new HttpResponse. */ public HttpResponse create() { if (getNumChanges() != responseObjNumChanges || responseObj == null) { // Short-circuit the creation process: no need to create a // new (immutable) HttpResponse object when no modifications occurred. responseObj = new HttpResponse(this); responseObjNumChanges = getNumChanges(); } return responseObj; }
/** * Verifies that the cache TTL is within acceptable ranges. * This always rounds down due to timing, so actual verification will be against maxAge - 1. */ private static void assertTtlOk(int maxAge, HttpResponse response) { assertEquals(maxAge - 1, roundToSeconds(response.getCacheTtl() - 1)); }
public void invalidateApplicationResources(Set<Uri> uris, SecurityToken token) { // TODO Add checks on content for (Uri uri : uris) { httpCache.removeResponse(new HttpRequest(uri)); } }