/******************************************************************************************************************* * * * ******************************************************************************************************************/ @PostConstruct /* VisibleForTesting */ void initialize() { connectionManager = new PoolingHttpClientConnectionManager(); connectionManager.setMaxTotal(200); connectionManager.setDefaultMaxPerRoute(20); cacheConfig = CacheConfig.custom() .setAllow303Caching(true) .setMaxCacheEntries(Integer.MAX_VALUE) .setMaxObjectSize(Integer.MAX_VALUE) .setSharedCache(false) .setHeuristicCachingEnabled(true) .build(); httpClient = CachingHttpClients.custom() .setHttpCacheStorage(cacheStorage) .setCacheConfig(cacheConfig) .setRedirectStrategy(dontFollowRedirect) .setUserAgent("blueMarine (fabrizio.giudici@tidalwave.it)") .setDefaultHeaders(Arrays.asList(new BasicHeader("Accept", "application/n3"))) .setConnectionManager(connectionManager) .addInterceptorFirst(killCacheHeaders) // FIXME: only if explicitly configured .build(); }
cachingClient = clientBuilderHelper(CachingHttpClientBuilder.create() .setCacheConfig(cacheConfig) .setHttpCacheStorage(httpCache), manager);
/** * Constructs a default HttpJsonHomeClient build on top of a CachingHttpClient with in-memory storage. */ public HttpJsonHomeClient() { final CacheConfig cacheConfig = CacheConfig.custom() .setMaxCacheEntries(100) .setMaxObjectSize(50000) .build(); this.cacheStorage = new BasicHttpCacheStorage(cacheConfig); this.httpClient = CachingHttpClientBuilder.create() .setHttpCacheStorage(cacheStorage) .setCacheConfig(cacheConfig) .build(); }
.setHttpCacheStorage(new JarCacheStorage(null, cacheConfig, new BasicHttpCacheStorage(cacheConfig)))
private static CloseableHttpClient createTestHttpClient(CacheConfig cacheConfig, JarCacheStorage jarCacheConfig) { final CloseableHttpClient result = CachingHttpClientBuilder.create() // allow caching .setCacheConfig(cacheConfig) // Set the JarCacheStorage instance as the HttpCache .setHttpCacheStorage(jarCacheConfig) // Support compressed data // http://hc.apache.org/httpcomponents-client-ga/tutorial/html/httpagent.html#d5e1238 .addInterceptorFirst(new RequestAcceptEncoding()) .addInterceptorFirst(new ResponseContentEncoding()) .setRedirectStrategy(DefaultRedirectStrategy.INSTANCE) // use system defaults for proxy etc. .useSystemProperties().build(); return result; } }
public static HttpClientBuilder createDefaultHttpClientBuilder(final CacheConfig cacheConfig) { // Common CacheConfig for both the JarCacheStorage and the underlying // BasicHttpCacheStorage return CachingHttpClientBuilder.create() // allow caching .setCacheConfig(cacheConfig) // Wrap the local JarCacheStorage around a BasicHttpCacheStorage .setHttpCacheStorage(new JarCacheStorage(null, cacheConfig, new BasicHttpCacheStorage(cacheConfig))) // Support compressed data // https://wayback.archive.org/web/20130901115452/http://hc.apache.org:80/httpcomponents-client-ga/tutorial/html/httpagent.html#d5e1238 .addInterceptorFirst(new RequestAcceptEncoding()) .addInterceptorFirst(new ResponseContentEncoding()) .setRedirectStrategy(DefaultRedirectStrategy.INSTANCE) // User agent customisation .setUserAgent(JSONLD_JAVA_USER_AGENT) // use system defaults for proxy etc. .useSystemProperties(); }
public static HttpClientBuilder createDefaultHttpClientBuilder(final CacheConfig cacheConfig) { // Common CacheConfig for both the JarCacheStorage and the underlying // BasicHttpCacheStorage return CachingHttpClientBuilder.create() // allow caching .setCacheConfig(cacheConfig) // Wrap the local JarCacheStorage around a BasicHttpCacheStorage .setHttpCacheStorage(new JarCacheStorage(null, cacheConfig, new BasicHttpCacheStorage(cacheConfig))) // Support compressed data // https://wayback.archive.org/web/20130901115452/http://hc.apache.org:80/httpcomponents-client-ga/tutorial/html/httpagent.html#d5e1238 .addInterceptorFirst(new RequestAcceptEncoding()) .addInterceptorFirst(new ResponseContentEncoding()) .setRedirectStrategy(DefaultRedirectStrategy.INSTANCE) // User agent customisation .setUserAgent(JSONLD_JAVA_USER_AGENT) // use system defaults for proxy etc. .useSystemProperties(); }