Examples of ResponseCache


Examples of io.undertow.server.handlers.cache.ResponseCache

            exchange.setResponseCode(403);
            exchange.endExchange();
            return;
        }

        ResponseCache cache = exchange.getAttachment(ResponseCache.ATTACHMENT_KEY);
        final boolean cachable = this.cachable.resolve(exchange);

        //we set caching headers before we try and serve from the cache
        if (cachable && cacheTime != null) {
            exchange.getResponseHeaders().put(Headers.CACHE_CONTROL, "public, max-age=" + cacheTime);
            if (System.currentTimeMillis() > lastExpiryDate) {
                long date = System.currentTimeMillis();
                lastExpiryHeader = DateUtils.toDateString(new Date(date));
                lastExpiryDate = date;
            }
            exchange.getResponseHeaders().put(Headers.EXPIRES, lastExpiryHeader);
        }

        if (cache != null && cachable) {
            if (cache.tryServeResponse()) {
                return;
            }
        }

View Full Code Here

Examples of io.undertow.server.handlers.cache.ResponseCache

            exchange.setResponseCode(403);
            exchange.endExchange();
            return;
        }

        ResponseCache cache = exchange.getAttachment(ResponseCache.ATTACHMENT_KEY);
        final boolean cachable = this.cachable.resolve(exchange);

        //we set caching headers before we try and serve from the cache
        if (cachable && cacheTime != null) {
            exchange.getResponseHeaders().put(Headers.CACHE_CONTROL, "public, max-age=" + cacheTime);
            if (System.currentTimeMillis() > lastExpiryDate) {
                long date = System.currentTimeMillis();
                lastExpiryHeader = DateUtils.toDateString(new Date(date));
                lastExpiryDate = date;
            }
            exchange.getResponseHeaders().put(Headers.EXPIRES, lastExpiryHeader);
        }

        if (cache != null && cachable) {
            if (cache.tryServeResponse()) {
                return;
            }
        }

View Full Code Here

Examples of java.net.ResponseCache

     *        in HttpURLConnection using GetOutputStream() and Connect()
     */
    public void test_UseCache_HttpURLConnection_Connect_GetOutputStream()
            throws Exception {
        // set cache before URLConnection created, or it does not take effect
        ResponseCache rc = new MockNonCachedResponseCache();
        ResponseCache.setDefault(rc);
        uc.setUseCaches(true);
        URLConnection uc = url.openConnection();
        uc.setDoOutput(true);
        assertFalse(isGetCalled);
View Full Code Here

Examples of java.net.ResponseCache

     *        in HttpURLConnection using GetOutputStream()
     */
    public void test_UseCache_HttpURLConnection_GetOutputStream()
            throws Exception {
        // set cache before URLConnection created, or it does not take effect
        ResponseCache rc = new MockNonCachedResponseCache();
        ResponseCache.setDefault(rc);
        uc = (HttpURLConnection) url.openConnection();
        assertFalse(isGetCalled);
        uc.setDoOutput(true);
        uc.setUseCaches(true);
View Full Code Here

Examples of java.net.ResponseCache

     *        in HttpURLConnection using GetInputStream()
     */
    public void test_UseCache_HttpURLConnection_GetInputStream()
            throws Exception {
        // set cache before URLConnection created, or it does not take effect
        ResponseCache rc = new MockNonCachedResponseCache();
        ResponseCache.setDefault(rc);
        URLConnection uc = url.openConnection();
        assertFalse(isGetCalled);
        uc.setDoOutput(true);
        uc.setUseCaches(true);
View Full Code Here

Examples of java.net.ResponseCache

  /**
   * @tests java.net.ResponseCache#setDefault(ResponseCache)
   */
  public void test_SetDefaultLjava_net_ResponseCache_Normal()
      throws Exception {
    ResponseCache rc1 = new MockResponseCache();
    ResponseCache rc2 = new MockResponseCache();
    ResponseCache.setDefault(rc1);
    assertSame(ResponseCache.getDefault(), rc1);
    ResponseCache.setDefault(rc2);
    assertSame(ResponseCache.getDefault(), rc2);
    ResponseCache.setDefault(null);
View Full Code Here

Examples of java.net.ResponseCache

  /**
   * @tests java.net.ResponseCache#setDefault(ResponseCache)
   */
  public void test_setDefaultLjava_net_ResponseCache_NoPermission() {
    ResponseCache rc = new MockResponseCache();
    SecurityManager old = System.getSecurityManager();
    try {
      System.setSecurityManager(new MockSM());
    } catch (SecurityException e) {
      System.err.println("No setSecurityManager permission.");
View Full Code Here

Examples of java.net.ResponseCache

     *        in HttpURLConnection using GetInputStream() and Connect()
     */
    public void test_UseCache_HttpURLConnection_Connect_GetInputStream()
            throws Exception {
        // set cache before URLConnection created, or it does not take effect
        ResponseCache rc = new MockNonCachedResponseCache();
        ResponseCache.setDefault(rc);
        uc = (HttpURLConnection) url.openConnection();
        assertFalse(isGetCalled);
        uc.setUseCaches(true);
        uc.setDoOutput(true);
View Full Code Here

Examples of java.net.ResponseCache

     *        in HttpURLConnection using GetOutputStream() and Connect()
     */
    public void test_UseCache_HttpURLConnection_Connect_GetOutputStream()
            throws Exception {
        // set cache before URLConnection created, or it does not take effect
        ResponseCache rc = new MockNonCachedResponseCache();
        ResponseCache.setDefault(rc);
        uc.setUseCaches(true);
        URLConnection uc = url.openConnection();
        uc.setDoOutput(true);
        assertFalse(isGetCalled);
View Full Code Here

Examples of java.net.ResponseCache

     *        in HttpURLConnection using GetOutputStream()
     */
    public void test_UseCache_HttpURLConnection_GetOutputStream()
            throws Exception {
        // set cache before URLConnection created, or it does not take effect
        ResponseCache rc = new MockNonCachedResponseCache();
        ResponseCache.setDefault(rc);
        uc = (HttpURLConnection) url.openConnection();
        assertFalse(isGetCalled);
        uc.setDoOutput(true);
        uc.setUseCaches(true);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.