Class ConnectionConfig
- java.lang.Object
-
- org.apache.hc.client5.http.config.ConnectionConfig
-
- All Implemented Interfaces:
java.lang.Cloneable
@Contract(threading=IMMUTABLE) public class ConnectionConfig extends java.lang.Object implements java.lang.CloneableImmutable class encapsulating connection initialization and management settings.- Since:
- 5.2
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classConnectionConfig.BuilderBuilder forConnectionConfig.
-
Field Summary
Fields Modifier and Type Field Description private org.apache.hc.core5.util.TimeoutconnectTimeoutstatic ConnectionConfigDEFAULTThe default connection configuration.private static org.apache.hc.core5.util.TimeoutDEFAULT_CONNECT_TIMEOUTprivate org.apache.hc.core5.util.TimeoutidleTimeoutprivate org.apache.hc.core5.util.TimeoutsocketTimeoutprivate org.apache.hc.core5.util.TimeValuetimeToLiveprivate org.apache.hc.core5.util.TimeValuevalidateAfterInactivity
-
Constructor Summary
Constructors Modifier Constructor Description protectedConnectionConfig()Intended for CDI compatibility(package private)ConnectionConfig(org.apache.hc.core5.util.Timeout connectTimeout, org.apache.hc.core5.util.Timeout socketTimeout, org.apache.hc.core5.util.Timeout idleTimeout, org.apache.hc.core5.util.TimeValue validateAfterInactivity, org.apache.hc.core5.util.TimeValue timeToLive)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ConnectionConfigclone()static ConnectionConfig.Buildercopy(ConnectionConfig config)Creates a new builder forConnectionConfigbased on an existing instance.static ConnectionConfig.Buildercustom()Creates a new builder forConnectionConfig.org.apache.hc.core5.util.TimeoutgetConnectTimeout()Gets the timeout until the target endpoint acknowledges accepting the connection request.org.apache.hc.core5.util.TimeoutgetIdleTimeout()Gets the maximum period of idleness for a connection.org.apache.hc.core5.util.TimeoutgetSocketTimeout()Gets the default socket timeout value for I/O operations on connections created by this configuration.org.apache.hc.core5.util.TimeValuegetTimeToLive()Gets the total span of time connections can be kept alive or execute requests.org.apache.hc.core5.util.TimeValuegetValidateAfterInactivity()Gets the period of inactivity after which persistent connections must be re-validated.java.lang.StringtoString()
-
-
-
Field Detail
-
DEFAULT_CONNECT_TIMEOUT
private static final org.apache.hc.core5.util.Timeout DEFAULT_CONNECT_TIMEOUT
-
DEFAULT
public static final ConnectionConfig DEFAULT
The default connection configuration.- Timeout connectTimeout: 3 minutes
- Timeout socketTimeout:
null(undefined) - Timeout idleTimeout:
null(undefined) - TimeValue validateAfterInactivity:
null(undefined) - TimeValue timeToLive:
null(undefined)
-
connectTimeout
private final org.apache.hc.core5.util.Timeout connectTimeout
-
socketTimeout
private final org.apache.hc.core5.util.Timeout socketTimeout
-
idleTimeout
private final org.apache.hc.core5.util.Timeout idleTimeout
-
validateAfterInactivity
private final org.apache.hc.core5.util.TimeValue validateAfterInactivity
-
timeToLive
private final org.apache.hc.core5.util.TimeValue timeToLive
-
-
Constructor Detail
-
ConnectionConfig
protected ConnectionConfig()
Intended for CDI compatibility
-
ConnectionConfig
ConnectionConfig(org.apache.hc.core5.util.Timeout connectTimeout, org.apache.hc.core5.util.Timeout socketTimeout, org.apache.hc.core5.util.Timeout idleTimeout, org.apache.hc.core5.util.TimeValue validateAfterInactivity, org.apache.hc.core5.util.TimeValue timeToLive)
-
-
Method Detail
-
getSocketTimeout
public org.apache.hc.core5.util.Timeout getSocketTimeout()
Gets the default socket timeout value for I/O operations on connections created by this configuration. A timeout value of zero is interpreted as an infinite timeout.- Returns:
- the default socket timeout value, defaults to null.
- See Also:
ConnectionConfig.Builder.setSocketTimeout(Timeout)
-
getConnectTimeout
public org.apache.hc.core5.util.Timeout getConnectTimeout()
Gets the timeout until the target endpoint acknowledges accepting the connection request.Note that isn't the same time as the new connection being fully established. An HTTPS connection cannot be considered fully established until the TLS handshake has been successfully completed.
A timeout value of zero is interpreted as an infinite timeout.
- Returns:
- the timeout until the target endpoint acknowledges accepting the connection request, defaults to 3 minutes.
- See Also:
ConnectionConfig.Builder.setConnectTimeout(Timeout)
-
getIdleTimeout
public org.apache.hc.core5.util.Timeout getIdleTimeout()
Gets the maximum period of idleness for a connection.Implementations can use this value to discard connections that have been idle for too long.
- Returns:
- the maximum period of idleness for a connection, defaults to null.
- See Also:
ConnectionConfig.Builder.setIdleTimeout(Timeout)
-
getValidateAfterInactivity
public org.apache.hc.core5.util.TimeValue getValidateAfterInactivity()
Gets the period of inactivity after which persistent connections must be re-validated.- Returns:
- the period of inactivity after which persistent connections must be re-validated, defaults to null.
- See Also:
ConnectionConfig.Builder.setValidateAfterInactivity(TimeValue)
-
getTimeToLive
public org.apache.hc.core5.util.TimeValue getTimeToLive()
Gets the total span of time connections can be kept alive or execute requests.- Returns:
- the total span of time connections can be kept alive or execute requests, defaults to null.
- See Also:
(TimeValue)
-
clone
protected ConnectionConfig clone() throws java.lang.CloneNotSupportedException
- Overrides:
clonein classjava.lang.Object- Throws:
java.lang.CloneNotSupportedException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
custom
public static ConnectionConfig.Builder custom()
Creates a new builder forConnectionConfig.- Returns:
- a new builder for
ConnectionConfig.
-
copy
public static ConnectionConfig.Builder copy(ConnectionConfig config)
Creates a new builder forConnectionConfigbased on an existing instance.- Parameters:
config- the instance to copy.- Returns:
- a new builder for
ConnectionConfig.
-
-