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;
}
java类org.apache.http.impl.client.cache.BasicHttpCacheStorage的实例源码
JSONUtil.java 文件源码
项目:csvsum
阅读 22
收藏 0
点赞 0
评论 0
HttpClientProvider.java 文件源码
项目:jira-dvcs-connector
阅读 21
收藏 0
点赞 0
评论 0
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);
}
EtagCachingHttpClient.java 文件源码
项目:jira-dvcs-connector
阅读 17
收藏 0
点赞 0
评论 0
public EtagCachingHttpClient()
{
this(new DefaultHttpClient(), new BasicHttpCacheStorage(new CacheConfig()));
}
EtagCachingHttpClient.java 文件源码
项目:jira-dvcs-connector
阅读 17
收藏 0
点赞 0
评论 0
public EtagCachingHttpClient(HttpClient httpClient)
{
this(httpClient, new BasicHttpCacheStorage(new CacheConfig()));
}