Tabnine Logo
HttpRequest.getCacheTtl
Code IndexAdd Tabnine to your IDE (free)

How to use
getCacheTtl
method
in
org.apache.shindig.gadgets.http.HttpRequest

Best Java code snippets using org.apache.shindig.gadgets.http.HttpRequest.getCacheTtl (Showing top 20 results out of 315)

origin: com.lmco.shindig/shindig-gadgets

protected boolean isCacheable(HttpRequest request, HttpResponse response) {
 if (!isCacheable(request)) {
  return false;
 }
 if (request.getCacheTtl() != -1) {
  // Caching was forced. Ignore what the response wants.
  return true;
 }
 
 if (response.getHttpStatusCode() == HttpResponse.SC_NOT_MODIFIED) {
  // Shindig server will serve 304s. Do not cache 304s from the origin server.
  return false;
 }
 // If the HTTP response allows for it, we can cache.
 return !response.isStrictNoCache();
}
origin: org.gatein.shindig/shindig-gadgets

protected boolean isCacheable(HttpRequest request, HttpResponse response) {
 if (!isCacheable(request)) {
  return false;
 }
 if (request.getCacheTtl() != -1) {
  // Caching was forced. Ignore what the response wants.
  return true;
 }
 
 if (response.getHttpStatusCode() == HttpResponse.SC_NOT_MODIFIED) {
  // Shindig server will serve 304s. Do not cache 304s from the origin server.
  return false;
 }
 // If the HTTP response allows for it, we can cache.
 return !response.isStrictNoCache();
}
origin: org.apache.shindig/shindig-gadgets

protected boolean isCacheable(HttpRequest request, HttpResponse response,
               boolean allowStrictNoCacheResponses) {
 if (!isCacheable(request)) {
  return false;
 }
 if (request.getCacheTtl() != -1) {
  // Caching was forced. Ignore what the response wants.
  return true;
 }
 if (response.getHttpStatusCode() == HttpResponse.SC_NOT_MODIFIED) {
  // Shindig server will serve 304s. Do not cache 304s from the origin server.
  return false;
 }
 // If we allow strict no-cache responses or the HTTP response allows for it, we can cache.
 return allowStrictNoCacheResponses || !response.isStrictNoCache();
}
origin: com.lmco.shindig/shindig-gadgets

public boolean addResponse(HttpRequest request, HttpResponse response) {
 if (isCacheable(request, response)) {
  // Both are cacheable. Check for forced cache TTL overrides.
  HttpResponseBuilder responseBuilder = new HttpResponseBuilder(response);
  int forcedTtl = request.getCacheTtl();
  if (forcedTtl != -1) {
   responseBuilder.setCacheTtl(forcedTtl);
  }
  response = responseBuilder.create();
  String keyString = createKey(request);
  addResponseImpl(keyString, response);
  return true;
 }
 return false;
}
origin: org.gatein.shindig/shindig-gadgets

public boolean addResponse(HttpRequest request, HttpResponse response) {
 if (isCacheable(request, response)) {
  // Both are cacheable. Check for forced cache TTL overrides.
  HttpResponseBuilder responseBuilder = new HttpResponseBuilder(response);
  int forcedTtl = request.getCacheTtl();
  if (forcedTtl != -1) {
   responseBuilder.setCacheTtl(forcedTtl);
  }
  response = responseBuilder.create();
  String keyString = createKey(request);
  addResponseImpl(keyString, response);
  return true;
 }
 return false;
}
origin: org.apache.shindig/shindig-gadgets

@Override
public boolean equals(Object obj) {
 if (obj == this) {
  return true;
 }
 if (!(obj instanceof HttpRequest)) {
  return false;
 }
 HttpRequest req = (HttpRequest)obj;
 return super.equals(obj) && req.getCacheTtl() == getCacheTtl() &&
     req.getIgnoreCache() == getIgnoreCache();
}
origin: org.wso2.org.apache.shindig/shindig-gadgets

@Override
public boolean equals(Object obj) {
 if (obj == this) {
  return true;
 }
 if (!(obj instanceof HttpRequest)) {
  return false;
 }
 HttpRequest req = (HttpRequest)obj;
 return super.equals(obj) && req.getCacheTtl() == getCacheTtl() &&
     req.getIgnoreCache() == getIgnoreCache();
}
origin: com.lmco.shindig/shindig-gadgets

@Override
public boolean equals(Object obj) {
 if (obj == this) {
  return true;
 }
 if (!(obj instanceof HttpRequest)) {
  return false;
 }
 HttpRequest req = (HttpRequest)obj;
 return super.equals(obj) && req.getCacheTtl() == getCacheTtl() &&
     req.getIgnoreCache() == getIgnoreCache();
}
origin: com.lmco.shindig/shindig-gadgets

@Test
public void testGetRequestWithRefresh() throws Exception {
 expect(request.getParameter(Param.REFRESH.getKey())).andReturn("120").anyTimes();
 Capture<HttpRequest> requestCapture = new Capture<HttpRequest>();
 expect(pipeline.execute(capture(requestCapture))).andReturn(new HttpResponse(RESPONSE_BODY));
 replay();
 handler.fetch(request, recorder);
 HttpRequest httpRequest = requestCapture.getValue();
 assertEquals("public,max-age=120", recorder.getHeader("Cache-Control"));
 assertEquals(120, httpRequest.getCacheTtl());
}
origin: org.apache.shindig/shindig-gadgets

@Test
public void testGetRequestWithRefresh() throws Exception {
 expect(request.getParameter(Param.REFRESH.getKey())).andReturn("120").anyTimes();
 Capture<HttpRequest> requestCapture = new Capture<HttpRequest>();
 expect(pipeline.execute(capture(requestCapture))).andReturn(new HttpResponse(RESPONSE_BODY));
 replay();
 handler.fetch(request, recorder);
 HttpRequest httpRequest = requestCapture.getValue();
 assertEquals("public,max-age=120", recorder.getHeader("Cache-Control"));
 assertEquals(120, httpRequest.getCacheTtl());
}
origin: org.wso2.org.apache.shindig/shindig-gadgets

@Test
public void testGetRequestWithRefresh() throws Exception {
 expect(request.getParameter(Param.REFRESH.getKey())).andReturn("120").anyTimes();
 Capture<HttpRequest> requestCapture = new Capture<HttpRequest>();
 expect(pipeline.execute(capture(requestCapture))).andReturn(new HttpResponse(RESPONSE_BODY));
 replay();
 handler.fetch(request, recorder);
 HttpRequest httpRequest = requestCapture.getValue();
 assertEquals("public,max-age=120", recorder.getHeader("Cache-Control"));
 assertEquals(120, httpRequest.getCacheTtl());
}
origin: org.apache.shindig/shindig-gadgets

@Test
public void testGetRequestWithBadTtl() throws Exception {
 expect(request.getParameter(Param.REFRESH.getKey())).andReturn("foo").anyTimes();
 Capture<HttpRequest> requestCapture = new Capture<HttpRequest>();
 expect(pipeline.execute(capture(requestCapture))).andReturn(new HttpResponse(RESPONSE_BODY));
 replay();
 try {
  handler.fetch(request, recorder);
 } catch (GadgetException e) {
  // Expected - catch now occurs at the MakeRequestServlet level.
 }
 HttpRequest httpRequest = requestCapture.getValue();
 assertEquals(null, recorder.getHeader("Cache-Control"));
 assertEquals(-1, httpRequest.getCacheTtl());
}
origin: org.wso2.org.apache.shindig/shindig-gadgets

@Test
public void testGetRequestWithBadTtl() throws Exception {
 expect(request.getParameter(Param.REFRESH.getKey())).andReturn("foo").anyTimes();
 Capture<HttpRequest> requestCapture = new Capture<HttpRequest>();
 expect(pipeline.execute(capture(requestCapture))).andReturn(new HttpResponse(RESPONSE_BODY));
 replay();
 try {
  handler.fetch(request, recorder);
 } catch (GadgetException e) {
  // Expected - catch now occurs at the MakeRequestServlet level.
 }
 HttpRequest httpRequest = requestCapture.getValue();
 assertEquals(null, recorder.getHeader("Cache-Control"));
 assertEquals(-1, httpRequest.getCacheTtl());
}
origin: com.lmco.shindig/shindig-gadgets

@Test
public void testGetRequestWithBadTtl() throws Exception {
 expect(request.getParameter(Param.REFRESH.getKey())).andReturn("foo").anyTimes();
 Capture<HttpRequest> requestCapture = new Capture<HttpRequest>();
 expect(pipeline.execute(capture(requestCapture))).andReturn(new HttpResponse(RESPONSE_BODY));
 replay();
 try {
  handler.fetch(request, recorder);
 } catch (GadgetException e) {
  // Expected - catch now occurs at the MakeRequestServlet level.
 }
 HttpRequest httpRequest = requestCapture.getValue();
 assertEquals(null, recorder.getHeader("Cache-Control"));
 assertEquals(-1, httpRequest.getCacheTtl());
}
origin: org.wso2.org.apache.shindig/shindig-gadgets

@Test
public void ttlPropagatesToFetcher() throws Exception {
 CapturingFetcher capturingFetcher = new CapturingFetcher();
 MessageBundleFactory factory = new DefaultMessageBundleFactory(
   new ImmediateExecutorService(), capturingFetcher, cacheProvider, MAX_AGE);
 factory.getBundle(gadgetSpec, LOCALE, false, ContainerConfig.DEFAULT_CONTAINER, null);
 assertEquals(MAX_AGE / 1000, capturingFetcher.request.getCacheTtl());
}
origin: org.apache.shindig/shindig-gadgets

@Test
public void ttlPropagatesToFetcher() throws Exception {
 CapturingFetcher capturingFetcher = new CapturingFetcher();
 MessageBundleFactory factory = new DefaultMessageBundleFactory(
   new ImmediateExecutorService(), capturingFetcher, cacheProvider, MAX_AGE);
 factory.getBundle(gadgetSpec, LOCALE, false, ContainerConfig.DEFAULT_CONTAINER, null);
 assertEquals(MAX_AGE / 1000, capturingFetcher.request.getCacheTtl());
}
origin: com.lmco.shindig/shindig-gadgets

@Test
public void ttlPropagatesToFetcher() throws Exception {
 CapturingFetcher capturingFetcher = new CapturingFetcher();
 MessageBundleFactory factory = new DefaultMessageBundleFactory(
   new TestExecutorService(), capturingFetcher, cacheProvider, MAX_AGE);
 factory.getBundle(gadgetSpec, LOCALE, false, ContainerConfig.DEFAULT_CONTAINER);
 assertEquals(MAX_AGE / 1000, capturingFetcher.request.getCacheTtl());
}
origin: org.wso2.org.apache.shindig/shindig-gadgets

@Test
public void ttlPropagatesToPipeline() throws Exception {
 CapturingPipeline capturingPipeline = new CapturingPipeline();
 GadgetSpecFactory forcedCacheFactory = new DefaultGadgetSpecFactory(
   new ImmediateExecutorService(), capturingPipeline, cacheProvider, 10000);
 forcedCacheFactory.getGadgetSpec(createContext(SPEC_URL, false));
 assertEquals(10, capturingPipeline.request.getCacheTtl());
}
origin: com.lmco.shindig/shindig-gadgets

@Test
public void ttlPropagatesToPipeline() throws Exception {
 CapturingPipeline capturingPipeline = new CapturingPipeline();
 GadgetSpecFactory forcedCacheFactory = new DefaultGadgetSpecFactory(
   new TestExecutorService(), capturingPipeline, cacheProvider, 10000);
 forcedCacheFactory.getGadgetSpec(createContext(SPEC_URL, false));
 assertEquals(10, capturingPipeline.request.getCacheTtl());
}
origin: org.apache.shindig/shindig-gadgets

@Test
public void ttlPropagatesToPipeline() throws Exception {
 CapturingPipeline capturingPipeline = new CapturingPipeline();
 GadgetSpecFactory forcedCacheFactory = new DefaultGadgetSpecFactory(
   new ImmediateExecutorService(), capturingPipeline, cacheProvider, 10000);
 forcedCacheFactory.getGadgetSpec(createContext(SPEC_URL, false));
 assertEquals(10, capturingPipeline.request.getCacheTtl());
}
org.apache.shindig.gadgets.httpHttpRequestgetCacheTtl

Popular methods of HttpRequest

  • <init>
    Clone an existing HttpRequest.
  • addHeader
    Add a single header to the request. If a value for the given name is already set, a second value is
  • getAuthType
  • getContainer
  • getFollowRedirects
  • getGadget
  • getHeader
  • getHeaders
  • getIgnoreCache
  • getMethod
  • getOAuthArguments
  • getParam
  • getOAuthArguments,
  • getParam,
  • getParamAsInteger,
  • getPostBody,
  • getPostBodyAsString,
  • getPostBodyLength,
  • getRewriteMimeType,
  • getSecurityToken,
  • getUri

Popular in Java

  • Start an intent from android
  • scheduleAtFixedRate (Timer)
  • getSupportFragmentManager (FragmentActivity)
  • addToBackStack (FragmentTransaction)
  • FileWriter (java.io)
    A specialized Writer that writes to a file in the file system. All write requests made by calling me
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • Iterator (java.util)
    An iterator over a sequence of objects, such as a collection.If a collection has been changed since
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now