.addInterceptorFirst(new RequestAcceptEncoding()) .addInterceptorFirst(new ResponseContentEncoding()) .setRedirectStrategy(DefaultRedirectStrategy.INSTANCE)
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(); }
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(); }