Added static #copy method to config classes
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1428925 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d38d340a1e
commit
8155bab28d
|
@ -26,6 +26,8 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.http.impl.client.cache;
|
package org.apache.http.impl.client.cache;
|
||||||
|
|
||||||
|
import org.apache.http.util.Args;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Java Beans-style configuration for a {@link CachingHttpClient}. Any class
|
* <p>Java Beans-style configuration for a {@link CachingHttpClient}. Any class
|
||||||
* in the caching module that has configuration options should take a
|
* in the caching module that has configuration options should take a
|
||||||
|
@ -468,6 +470,24 @@ public class CacheConfig implements Cloneable {
|
||||||
return new Builder();
|
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 {
|
public static class Builder {
|
||||||
|
|
||||||
private long maxObjectSize;
|
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
|
* to better emulate IE, which also never caches responses, regardless of what caching
|
||||||
* headers may be present.
|
* headers may be present.
|
||||||
*/
|
*/
|
||||||
public Builder setNeverCache1_0ResponsesWithQueryString(boolean b) {
|
public Builder setNeverCacheHTTP10ResponsesWithQueryString(boolean b) {
|
||||||
this.neverCacheHTTP10ResponsesWithQuery = b;
|
this.neverCacheHTTP10ResponsesWithQuery = b;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,6 +177,25 @@ public class RequestConfig implements Cloneable {
|
||||||
return new Builder();
|
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 {
|
public static class Builder {
|
||||||
|
|
||||||
private boolean expectContinueEnabled;
|
private boolean expectContinueEnabled;
|
||||||
|
|
Loading…
Reference in New Issue