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

  • Making http requests using okhttp
  • getExternalFilesDir (Context)
  • getSharedPreferences (Context)
  • addToBackStack (FragmentTransaction)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • 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