org.apache.http.client.cache.HttpCacheStorage Java Examples
The following examples show how to use
org.apache.http.client.cache.HttpCacheStorage.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KeySetRetriever.java From deprecated-security-advanced-modules with Apache License 2.0 | 7 votes |
private CloseableHttpClient createHttpClient(HttpCacheStorage httpCacheStorage) { HttpClientBuilder builder; if (httpCacheStorage != null) { builder = CachingHttpClients.custom().setCacheConfig(cacheConfig).setHttpCacheStorage(httpCacheStorage); } else { builder = HttpClients.custom(); } builder.useSystemProperties(); if (sslConfig != null) { builder.setSSLSocketFactory(sslConfig.toSSLConnectionSocketFactory()); } return builder.build(); }
Example #2
Source File: HttpClientFactory.java From riptide with MIT License | 6 votes |
private static HttpClientBuilder configureCaching(final Caching caching, @Nullable final Object cacheStorage) { final Heuristic heuristic = caching.getHeuristic(); final CacheConfig.Builder config = CacheConfig.custom() .setSharedCache(caching.getShared()) .setMaxObjectSize(caching.getMaxObjectSize()) .setMaxCacheEntries(caching.getMaxCacheEntries()); if (heuristic.getEnabled()) { config.setHeuristicCachingEnabled(true); config.setHeuristicCoefficient(heuristic.getCoefficient()); config.setHeuristicDefaultLifetime(heuristic.getDefaultLifeTime().to(TimeUnit.SECONDS)); } @Hack("return cast tricks classloader in case of missing httpclient-cache") CachingHttpClientBuilder builder = CachingHttpClients.custom() .setCacheConfig(config.build()) .setHttpCacheStorage((HttpCacheStorage) cacheStorage) .setCacheDir(Optional.ofNullable(caching.getDirectory()) .map(Path::toFile) .orElse(null)); return HttpClientBuilder.class.cast(builder); }
Example #3
Source File: DefaultRiptideRegistrar.java From riptide with MIT License | 5 votes |
private Optional<BeanReference> findCacheStorageReference(final String id, final Client client) { if (client.getCaching().getEnabled()) { return registry.findRef(id, HttpCacheStorage.class); } else { return Optional.empty(); } }
Example #4
Source File: CachingTest.java From riptide with MIT License | 4 votes |
@Bean public HttpCacheStorage publicHttpCacheStorage() { return new BasicHttpCacheStorage(CacheConfig.DEFAULT); }
Example #5
Source File: CacheStorage.java From esigate with Apache License 2.0 | 4 votes |
public void setImpl(HttpCacheStorage impl) { this.impl = impl; }