Package org.apache.http.impl.client.cache

Examples of org.apache.http.impl.client.cache.CachingHttpClient.execute()


        final JarCacheStorage storage = new JarCacheStorage(cl);

        final HttpClient httpClient = new CachingHttpClient(new SystemDefaultHttpClient(), storage,
                storage.getCacheConfig());
        final HttpGet get = new HttpGet("http://nonexisting.example.com/nested/hello");
        final HttpResponse resp = httpClient.execute(get);

        assertEquals("application/json", resp.getEntity().getContentType().getValue());
        final String str = IOUtils.toString(resp.getEntity().getContent(), "UTF-8");
        assertEquals("{ \"Hello\": \"World!\" }", str.trim());
    }
View Full Code Here


        Thread.currentThread().setContextClassLoader(cl);

        final HttpClient httpClient = new CachingHttpClient(new SystemDefaultHttpClient(), storage,
                storage.getCacheConfig());
        final HttpGet get = new HttpGet("http://nonexisting.example.com/nested/hello");
        final HttpResponse resp = httpClient.execute(get);

        assertEquals("application/json", resp.getEntity().getContentType().getValue());
        final String str = IOUtils.toString(resp.getEntity().getContent(), "UTF-8");
        assertEquals("{ \"Hello\": \"World!\" }", str.trim());
    }
View Full Code Here

        final JarCacheStorage storage = new JarCacheStorage(null);

        final HttpClient httpClient = new CachingHttpClient(new SystemDefaultHttpClient(), storage,
                storage.getCacheConfig());
        final HttpGet get = new HttpGet("http://nonexisting.example.com/context");
        final HttpResponse resp = httpClient.execute(get);
        assertEquals("application/ld+json", resp.getEntity().getContentType().getValue());
    }

}
View Full Code Here

        // cached
        final HttpClient client = new CachingHttpClient(documentLoader.getHttpClient());
        final HttpUriRequest get = new HttpGet(url.toURI());
        get.setHeader("Accept", DocumentLoader.ACCEPT_HEADER);
        final HttpContext localContext = new BasicHttpContext();
        final HttpResponse respo = client.execute(get, localContext);
        EntityUtils.consume(respo.getEntity());

        // Check cache status
        // http://hc.apache.org/httpcomponents-client-ga/tutorial/html/caching.html
        final CacheResponseStatus responseStatus = (CacheResponseStatus) localContext
View Full Code Here

        // cached
        final HttpClient client = new CachingHttpClient(DocumentLoader.getHttpClient());
        final HttpUriRequest get = new HttpGet(url.toURI());
        get.setHeader("Accept", DocumentLoader.ACCEPT_HEADER);
        final HttpContext localContext = new BasicHttpContext();
        final HttpResponse respo = client.execute(get, localContext);
        EntityUtils.consume(respo.getEntity());

        // Check cache status
        // http://hc.apache.org/httpcomponents-client-ga/tutorial/html/caching.html
        final CacheResponseStatus responseStatus = (CacheResponseStatus) localContext
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.