diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheConfig.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheConfig.java index 257806758..909a5ecbc 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheConfig.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheConfig.java @@ -26,6 +26,8 @@ */ package org.apache.http.impl.client.cache; +import org.apache.http.util.Args; + /** *
Java Beans-style configuration for a {@link CachingHttpClient}. Any class * in the caching module that has configuration options should take a @@ -468,6 +470,24 @@ public class CacheConfig implements Cloneable { return new Builder(); } + public static Builder copy(final CacheConfig config) { + Args.notNull(config, "Cache config"); + return new Builder() + .setMaxObjectSize(config.getMaxObjectSize()) + .setMaxCacheEntries(config.getMaxCacheEntries()) + .setMaxUpdateRetries(config.getMaxUpdateRetries()) + .setHeuristicCachingEnabled(config.isHeuristicCachingEnabled()) + .setHeuristicCoefficient(config.getHeuristicCoefficient()) + .setHeuristicDefaultLifetime(config.getHeuristicDefaultLifetime()) + .setSharedCache(config.isSharedCache()) + .setAsynchronousWorkersMax(config.getAsynchronousWorkersMax()) + .setAsynchronousWorkersCore(config.getAsynchronousWorkersCore()) + .setAsynchronousWorkerIdleLifetimeSecs(config.getAsynchronousWorkerIdleLifetimeSecs()) + .setRevalidationQueueSize(config.getRevalidationQueueSize()) + .setNeverCacheHTTP10ResponsesWithQueryString(config.isNeverCacheHTTP10ResponsesWithQuery()); + } + + public static class Builder { private long maxObjectSize; @@ -621,7 +641,7 @@ public class CacheConfig implements Cloneable { * to better emulate IE, which also never caches responses, regardless of what caching * headers may be present. */ - public Builder setNeverCache1_0ResponsesWithQueryString(boolean b) { + public Builder setNeverCacheHTTP10ResponsesWithQueryString(boolean b) { this.neverCacheHTTP10ResponsesWithQuery = b; return this; } diff --git a/httpclient/src/main/java/org/apache/http/client/config/RequestConfig.java b/httpclient/src/main/java/org/apache/http/client/config/RequestConfig.java index 83a95a6a5..1ba3aac1d 100644 --- a/httpclient/src/main/java/org/apache/http/client/config/RequestConfig.java +++ b/httpclient/src/main/java/org/apache/http/client/config/RequestConfig.java @@ -177,6 +177,25 @@ public class RequestConfig implements Cloneable { return new Builder(); } + public static RequestConfig.Builder copy(final RequestConfig config) { + return new Builder() + .setExpectContinueEnabled(config.isExpectContinueEnabled()) + .setDefaultProxy(config.getDefaultProxy()) + .setLocalAddress(config.getLocalAddress()) + .setStaleConnectionCheckEnabled(config.isStaleConnectionCheckEnabled()) + .setCookieSpec(config.getCookieSpec()) + .setRedirectsEnabled(config.isRedirectsEnabled()) + .setRelativeRedirectsAllowed(config.isRelativeRedirectsAllowed()) + .setCircularRedirectsAllowed(config.isCircularRedirectsAllowed()) + .setMaxRedirects(config.getMaxRedirects()) + .setAuthenticationEnabled(config.isAuthenticationEnabled()) + .setTargetPreferredAuthSchemes(config.getProxyPreferredAuthSchemes()) + .setProxyPreferredAuthSchemes(config.getProxyPreferredAuthSchemes()) + .setConnectionRequestTimeout(config.getConnectionRequestTimeout()) + .setConnectTimeout(config.getConnectTimeout()) + .setSocketTimeout(config.getSocketTimeout()); + } + public static class Builder { private boolean expectContinueEnabled;