|
|
@ -33,7 +33,6 @@ import java.util.Collection; |
|
|
|
import com.fr.third.org.apache.http.HttpHost; |
|
|
|
import com.fr.third.org.apache.http.HttpHost; |
|
|
|
import com.fr.third.org.apache.http.annotation.Contract; |
|
|
|
import com.fr.third.org.apache.http.annotation.Contract; |
|
|
|
import com.fr.third.org.apache.http.annotation.ThreadingBehavior; |
|
|
|
import com.fr.third.org.apache.http.annotation.ThreadingBehavior; |
|
|
|
import com.fr.third.org.apache.http.impl.conn.PoolingHttpClientConnectionManager; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Immutable class encapsulating request configuration items. |
|
|
|
* Immutable class encapsulating request configuration items. |
|
|
@ -61,12 +60,13 @@ public class RequestConfig implements Cloneable { |
|
|
|
private final int connectTimeout; |
|
|
|
private final int connectTimeout; |
|
|
|
private final int socketTimeout; |
|
|
|
private final int socketTimeout; |
|
|
|
private final boolean contentCompressionEnabled; |
|
|
|
private final boolean contentCompressionEnabled; |
|
|
|
|
|
|
|
private final boolean normalizeUri; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Intended for CDI compatibility |
|
|
|
* Intended for CDI compatibility |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected RequestConfig() { |
|
|
|
protected RequestConfig() { |
|
|
|
this(false, null, null, false, null, false, false, false, 0, false, null, null, 0, 0, 0, true); |
|
|
|
this(false, null, null, false, null, false, false, false, 0, false, null, null, 0, 0, 0, true, true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
RequestConfig( |
|
|
|
RequestConfig( |
|
|
@ -85,7 +85,8 @@ public class RequestConfig implements Cloneable { |
|
|
|
final int connectionRequestTimeout, |
|
|
|
final int connectionRequestTimeout, |
|
|
|
final int connectTimeout, |
|
|
|
final int connectTimeout, |
|
|
|
final int socketTimeout, |
|
|
|
final int socketTimeout, |
|
|
|
final boolean contentCompressionEnabled) { |
|
|
|
final boolean contentCompressionEnabled, |
|
|
|
|
|
|
|
final boolean normalizeUri) { |
|
|
|
super(); |
|
|
|
super(); |
|
|
|
this.expectContinueEnabled = expectContinueEnabled; |
|
|
|
this.expectContinueEnabled = expectContinueEnabled; |
|
|
|
this.proxy = proxy; |
|
|
|
this.proxy = proxy; |
|
|
@ -103,6 +104,7 @@ public class RequestConfig implements Cloneable { |
|
|
|
this.connectTimeout = connectTimeout; |
|
|
|
this.connectTimeout = connectTimeout; |
|
|
|
this.socketTimeout = socketTimeout; |
|
|
|
this.socketTimeout = socketTimeout; |
|
|
|
this.contentCompressionEnabled = contentCompressionEnabled; |
|
|
|
this.contentCompressionEnabled = contentCompressionEnabled; |
|
|
|
|
|
|
|
this.normalizeUri = normalizeUri; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -166,7 +168,7 @@ public class RequestConfig implements Cloneable { |
|
|
|
* </p> |
|
|
|
* </p> |
|
|
|
* |
|
|
|
* |
|
|
|
* @deprecated (4.4) Use {@link |
|
|
|
* @deprecated (4.4) Use {@link |
|
|
|
* PoolingHttpClientConnectionManager#getValidateAfterInactivity()} |
|
|
|
* com.fr.third.org.apache.http.impl.conn.PoolingHttpClientConnectionManager#getValidateAfterInactivity()} |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Deprecated |
|
|
|
@Deprecated |
|
|
|
public boolean isStaleConnectionCheckEnabled() { |
|
|
|
public boolean isStaleConnectionCheckEnabled() { |
|
|
@ -262,11 +264,10 @@ public class RequestConfig implements Cloneable { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns the timeout in milliseconds used when requesting a connection |
|
|
|
* Returns the timeout in milliseconds used when requesting a connection |
|
|
|
* from the connection manager. A timeout value of zero is interpreted |
|
|
|
* from the connection manager. |
|
|
|
* as an infinite timeout. |
|
|
|
|
|
|
|
* <p> |
|
|
|
* <p> |
|
|
|
* A timeout value of zero is interpreted as an infinite timeout. |
|
|
|
* A timeout value of zero is interpreted as an infinite timeout. |
|
|
|
* A negative value is interpreted as undefined (system default). |
|
|
|
* A negative value is interpreted as undefined (system default if applicable). |
|
|
|
* </p> |
|
|
|
* </p> |
|
|
|
* <p> |
|
|
|
* <p> |
|
|
|
* Default: {@code -1} |
|
|
|
* Default: {@code -1} |
|
|
@ -278,10 +279,9 @@ public class RequestConfig implements Cloneable { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Determines the timeout in milliseconds until a connection is established. |
|
|
|
* Determines the timeout in milliseconds until a connection is established. |
|
|
|
* A timeout value of zero is interpreted as an infinite timeout. |
|
|
|
|
|
|
|
* <p> |
|
|
|
* <p> |
|
|
|
* A timeout value of zero is interpreted as an infinite timeout. |
|
|
|
* A timeout value of zero is interpreted as an infinite timeout. |
|
|
|
* A negative value is interpreted as undefined (system default). |
|
|
|
* A negative value is interpreted as undefined (system default if applicable). |
|
|
|
* </p> |
|
|
|
* </p> |
|
|
|
* <p> |
|
|
|
* <p> |
|
|
|
* Default: {@code -1} |
|
|
|
* Default: {@code -1} |
|
|
@ -297,7 +297,7 @@ public class RequestConfig implements Cloneable { |
|
|
|
* a maximum period inactivity between two consecutive data packets). |
|
|
|
* a maximum period inactivity between two consecutive data packets). |
|
|
|
* <p> |
|
|
|
* <p> |
|
|
|
* A timeout value of zero is interpreted as an infinite timeout. |
|
|
|
* A timeout value of zero is interpreted as an infinite timeout. |
|
|
|
* A negative value is interpreted as undefined (system default). |
|
|
|
* A negative value is interpreted as undefined (system default if applicable). |
|
|
|
* </p> |
|
|
|
* </p> |
|
|
|
* <p> |
|
|
|
* <p> |
|
|
|
* Default: {@code -1} |
|
|
|
* Default: {@code -1} |
|
|
@ -333,6 +333,18 @@ public class RequestConfig implements Cloneable { |
|
|
|
return contentCompressionEnabled; |
|
|
|
return contentCompressionEnabled; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Determines whether client should normalize URIs in requests or not. |
|
|
|
|
|
|
|
* <p> |
|
|
|
|
|
|
|
* Default: {@code true} |
|
|
|
|
|
|
|
* </p> |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @since 4.5.8 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public boolean isNormalizeUri() { |
|
|
|
|
|
|
|
return normalizeUri; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected RequestConfig clone() throws CloneNotSupportedException { |
|
|
|
protected RequestConfig clone() throws CloneNotSupportedException { |
|
|
|
return (RequestConfig) super.clone(); |
|
|
|
return (RequestConfig) super.clone(); |
|
|
@ -357,16 +369,17 @@ public class RequestConfig implements Cloneable { |
|
|
|
builder.append(", connectTimeout=").append(connectTimeout); |
|
|
|
builder.append(", connectTimeout=").append(connectTimeout); |
|
|
|
builder.append(", socketTimeout=").append(socketTimeout); |
|
|
|
builder.append(", socketTimeout=").append(socketTimeout); |
|
|
|
builder.append(", contentCompressionEnabled=").append(contentCompressionEnabled); |
|
|
|
builder.append(", contentCompressionEnabled=").append(contentCompressionEnabled); |
|
|
|
|
|
|
|
builder.append(", normalizeUri=").append(normalizeUri); |
|
|
|
builder.append("]"); |
|
|
|
builder.append("]"); |
|
|
|
return builder.toString(); |
|
|
|
return builder.toString(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static RequestConfig.Builder custom() { |
|
|
|
public static Builder custom() { |
|
|
|
return new Builder(); |
|
|
|
return new Builder(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("deprecation") |
|
|
|
@SuppressWarnings("deprecation") |
|
|
|
public static RequestConfig.Builder copy(final RequestConfig config) { |
|
|
|
public static Builder copy(final RequestConfig config) { |
|
|
|
return new Builder() |
|
|
|
return new Builder() |
|
|
|
.setExpectContinueEnabled(config.isExpectContinueEnabled()) |
|
|
|
.setExpectContinueEnabled(config.isExpectContinueEnabled()) |
|
|
|
.setProxy(config.getProxy()) |
|
|
|
.setProxy(config.getProxy()) |
|
|
@ -384,7 +397,8 @@ public class RequestConfig implements Cloneable { |
|
|
|
.setConnectTimeout(config.getConnectTimeout()) |
|
|
|
.setConnectTimeout(config.getConnectTimeout()) |
|
|
|
.setSocketTimeout(config.getSocketTimeout()) |
|
|
|
.setSocketTimeout(config.getSocketTimeout()) |
|
|
|
.setDecompressionEnabled(config.isDecompressionEnabled()) |
|
|
|
.setDecompressionEnabled(config.isDecompressionEnabled()) |
|
|
|
.setContentCompressionEnabled(config.isContentCompressionEnabled()); |
|
|
|
.setContentCompressionEnabled(config.isContentCompressionEnabled()) |
|
|
|
|
|
|
|
.setNormalizeUri(config.isNormalizeUri()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static class Builder { |
|
|
|
public static class Builder { |
|
|
@ -405,6 +419,7 @@ public class RequestConfig implements Cloneable { |
|
|
|
private int connectTimeout; |
|
|
|
private int connectTimeout; |
|
|
|
private int socketTimeout; |
|
|
|
private int socketTimeout; |
|
|
|
private boolean contentCompressionEnabled; |
|
|
|
private boolean contentCompressionEnabled; |
|
|
|
|
|
|
|
private boolean normalizeUri; |
|
|
|
|
|
|
|
|
|
|
|
Builder() { |
|
|
|
Builder() { |
|
|
|
super(); |
|
|
|
super(); |
|
|
@ -417,6 +432,7 @@ public class RequestConfig implements Cloneable { |
|
|
|
this.connectTimeout = -1; |
|
|
|
this.connectTimeout = -1; |
|
|
|
this.socketTimeout = -1; |
|
|
|
this.socketTimeout = -1; |
|
|
|
this.contentCompressionEnabled = true; |
|
|
|
this.contentCompressionEnabled = true; |
|
|
|
|
|
|
|
this.normalizeUri = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Builder setExpectContinueEnabled(final boolean expectContinueEnabled) { |
|
|
|
public Builder setExpectContinueEnabled(final boolean expectContinueEnabled) { |
|
|
@ -436,7 +452,7 @@ public class RequestConfig implements Cloneable { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @deprecated (4.4) Use {@link |
|
|
|
* @deprecated (4.4) Use {@link |
|
|
|
* PoolingHttpClientConnectionManager#setValidateAfterInactivity(int)} |
|
|
|
* com.fr.third.org.apache.http.impl.conn.PoolingHttpClientConnectionManager#setValidateAfterInactivity(int)} |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Deprecated |
|
|
|
@Deprecated |
|
|
|
public Builder setStaleConnectionCheckEnabled(final boolean staleConnectionCheckEnabled) { |
|
|
|
public Builder setStaleConnectionCheckEnabled(final boolean staleConnectionCheckEnabled) { |
|
|
@ -514,6 +530,11 @@ public class RequestConfig implements Cloneable { |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Builder setNormalizeUri(final boolean normalizeUri) { |
|
|
|
|
|
|
|
this.normalizeUri = normalizeUri; |
|
|
|
|
|
|
|
return this; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public RequestConfig build() { |
|
|
|
public RequestConfig build() { |
|
|
|
return new RequestConfig( |
|
|
|
return new RequestConfig( |
|
|
|
expectContinueEnabled, |
|
|
|
expectContinueEnabled, |
|
|
@ -531,7 +552,8 @@ public class RequestConfig implements Cloneable { |
|
|
|
connectionRequestTimeout, |
|
|
|
connectionRequestTimeout, |
|
|
|
connectTimeout, |
|
|
|
connectTimeout, |
|
|
|
socketTimeout, |
|
|
|
socketTimeout, |
|
|
|
contentCompressionEnabled); |
|
|
|
contentCompressionEnabled, |
|
|
|
|
|
|
|
normalizeUri); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|