public static HttpClientBuilder getHttpClientBuilder() { // Common CacheConfig for both the JarCacheStorage and the underlying // BasicHttpCacheStorage final CacheConfig cacheConfig = CacheConfig.custom().setMaxCacheEntries(1000).setMaxObjectSize(1024 * 128) .build(); RequestConfig config = RequestConfig.custom().setConnectTimeout(DEFAULT_TIMEOUT) .setConnectionRequestTimeout(DEFAULT_TIMEOUT).setSocketTimeout(DEFAULT_TIMEOUT).build(); HttpClientBuilder clientBuilder = CachingHttpClientBuilder.create() // allow caching .setCacheConfig(cacheConfig) // Wrap the local JarCacheStorage around a BasicHttpCacheStorage .setHttpCacheStorage(new JarCacheStorage(null, cacheConfig, new BasicHttpCacheStorage(cacheConfig))) // Support compressed data // http://hc.apache.org/httpcomponents-client-ga/tutorial/html/httpagent.html#d5e1238 .addInterceptorFirst(new RequestAcceptEncoding()).addInterceptorFirst(new ResponseContentEncoding()) // use system defaults for proxy etc. .useSystemProperties().setDefaultRequestConfig(config); return clientBuilder; }
private HttpCacheStorage createStorage() { CacheConfig config = new CacheConfig(); // if max cache entries value is not present the CacheConfig's default (CacheConfig.DEFAULT_MAX_CACHE_ENTRIES = 1000) will be used Integer maxCacheEntries = Integer.getInteger("bitbucket.client.cache.maxentries"); if (maxCacheEntries != null) { config.setMaxCacheEntries(maxCacheEntries); } return new BasicHttpCacheStorage(config); }
public EtagCachingHttpClient() { this(new DefaultHttpClient(), new BasicHttpCacheStorage(new CacheConfig())); }
public EtagCachingHttpClient(HttpClient httpClient) { this(httpClient, new BasicHttpCacheStorage(new CacheConfig())); }