Class ConnectionConfig

java.lang.Object
org.apache.hc.client5.http.config.ConnectionConfig
All Implemented Interfaces:
Cloneable

@Contract(threading=IMMUTABLE) public class ConnectionConfig extends Object implements Cloneable
Immutable class encapsulating connection initialization and management settings.
Since:
5.2
  • Field Details

    • 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 Details

    • 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 Details

    • 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:
    • 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:
    • 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:
    • 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:
    • 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:
    • clone

      protected ConnectionConfig clone() throws CloneNotSupportedException
      Overrides:
      clone in class Object
      Throws:
      CloneNotSupportedException
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • custom

      public static ConnectionConfig.Builder custom()
      Creates a new builder for ConnectionConfig.
      Returns:
      a new builder for ConnectionConfig.
    • copy

      public static ConnectionConfig.Builder copy(ConnectionConfig config)
      Creates a new builder for ConnectionConfig based on an existing instance.
      Parameters:
      config - the instance to copy.
      Returns:
      a new builder for ConnectionConfig.