Class HttpClientConfig

java.lang.Object
io.vertx.core.http.HttpClientConfig
Direct Known Subclasses:
WebClientConfig

@Unstable public class HttpClientConfig extends Object
Configuration of a HttpClient
Author:
Julien Viet
  • Field Details

    • DEFAULT_SUPPORTED_VERSIONS

      public static final List<HttpVersion> DEFAULT_SUPPORTED_VERSIONS
    • DEFAULT_QUIC_INITIAL_MAX_DATA

      public static final long DEFAULT_QUIC_INITIAL_MAX_DATA
      See Also:
    • DEFAULT_QUIC_INITIAL_MAX_STREAM_DATA_BIDI_LOCAL

      public static final long DEFAULT_QUIC_INITIAL_MAX_STREAM_DATA_BIDI_LOCAL
      See Also:
    • DEFAULT_QUIC_INITIAL_MAX_STREAM_DATA_BIDI_REMOTE

      public static final long DEFAULT_QUIC_INITIAL_MAX_STREAM_DATA_BIDI_REMOTE
      See Also:
    • DEFAULT_QUIC_INITIAL_MAX_STREAM_DATA_UNI

      public static final long DEFAULT_QUIC_INITIAL_MAX_STREAM_DATA_UNI
      See Also:
    • DEFAULT_QUIC_INITIAL_MAX_STREAM_BIDI

      public static final long DEFAULT_QUIC_INITIAL_MAX_STREAM_BIDI
      See Also:
    • DEFAULT_QUIC_INITIAL_MAX_STREAM_UNI

      public static final long DEFAULT_QUIC_INITIAL_MAX_STREAM_UNI
      See Also:
  • Constructor Details

    • HttpClientConfig

      public HttpClientConfig()
    • HttpClientConfig

      public HttpClientConfig(HttpClientConfig other)
    • HttpClientConfig

      public HttpClientConfig(HttpClientOptions options)
  • Method Details

    • getTcpConfig

      public TcpClientConfig getTcpConfig()
      Returns:
      the client TCP transport config
    • getQuicConfig

      public QuicClientConfig getQuicConfig()
      Returns:
      the client QUIC transport config
    • setConnectTimeout

      public HttpClientConfig setConnectTimeout(Duration connectTimeout)
      Set the connect timeout
      Parameters:
      connectTimeout - connect timeout, in ms
      Returns:
      a reference to this, so the API can be used fluently
    • setKeepAliveTimeout

      public HttpClientConfig setKeepAliveTimeout(Duration keepAliveTimeout)

      Set the keep alive timeout for HTTP connections. This value determines how long a connection remains unused in the pool before being evicted and closed. A timeout of zero or null means there is no timeout.

      This configures each HTTP version with the same value, you can override this and configure each version separately.

      Parameters:
      keepAliveTimeout - the timeout, in seconds
      Returns:
      a reference to this, so the API can be used fluently
    • setIdleTimeout

      public HttpClientConfig setIdleTimeout(Duration idleTimeout)
      Set the idle timeout, zero or null means don't time out. This determines if a connection will timeout and be closed if no data is received nor sent within the timeout.

      This configures both TCP and QUIC nested configurations, you can configure each of them separately if you need to.

      Parameters:
      idleTimeout - the timeout
      Returns:
      a reference to this, so the API can be used fluently
    • setReadIdleTimeout

      public HttpClientConfig setReadIdleTimeout(Duration idleTimeout)

      Set the read idle timeout, zero or null means or null means don't time out. This determines if a connection will timeout and be closed if no data is received within the timeout.

      This configures both TCP and QUIC nested configurations, you can configure each of them separately if you need to.

      Parameters:
      idleTimeout - the read timeout
      Returns:
      a reference to this, so the API can be used fluently
    • setWriteIdleTimeout

      public HttpClientConfig setWriteIdleTimeout(Duration idleTimeout)

      Set the write idle timeout, zero or null means don't time out. This determines if a connection will timeout and be closed if no data is sent within the timeout.

      This configures both TCP and QUIC nested configurations, you can configure each of them separately if you need to.

      Parameters:
      idleTimeout - the write timeout
      Returns:
      a reference to this, so the API can be used fluently
    • setLogConfig

      public HttpClientConfig setLogConfig(LogConfig config)

      Configure the per stream networking logging: Netty's stream pipeline is configured for logging on Netty's logger.

      This configures both TCP and QUIC nested configurations, you can configure each of them separately if you need to.

      Parameters:
      config - the stream network logging config, null means disabled
      Returns:
      a reference to this, so the API can be used fluently
    • isSsl

      public boolean isSsl()
      Returns:
      is SSL/TLS enabled?
    • setSsl

      public HttpClientConfig setSsl(boolean ssl)
      Set whether SSL/TLS is enabled
      Parameters:
      ssl - true if enabled
      Returns:
      a reference to this, so the API can be used fluently
    • getVersions

      public List<HttpVersion> getVersions()
      Returns:
      the ordered list of the versions supported by the client
    • setVersions

      public HttpClientConfig setVersions(List<HttpVersion> versions)

      Set the list of HttpVersion supported by the client, the first element of the list is considered as the default protocol to choose when none is specified at the request level.

      Parameters:
      versions - the ordered list of supported versions
      Returns:
      a reference to this, so the API can be used fluently
    • setVersions

      public HttpClientConfig setVersions(HttpVersion... versions)
      Like setVersions(List) using an array.
      Parameters:
      versions - the ordered list of supported versions
      Returns:
      a reference to this, so the API can be used fluently
    • getHttp1Config

      public Http1ClientConfig getHttp1Config()
      Returns:
      the configuration specific to the HTTP/1.x protocol.
    • setHttp1Config

      public HttpClientConfig setHttp1Config(Http1ClientConfig config)
      Set the HTTP/1.x configuration to use
      Parameters:
      config - the config
      Returns:
      a reference to this, so the API can be used fluently
    • getHttp2Config

      public Http2ClientConfig getHttp2Config()
      Returns:
      the configuration specific to the HTTP/2 protocol.
    • setHttp2Config

      public HttpClientConfig setHttp2Config(Http2ClientConfig config)
      Set the HTTP/2 configuration to use
      Parameters:
      config - the config
      Returns:
      a reference to this, so the API can be used fluently
    • getHttp3Config

      public Http3ClientConfig getHttp3Config()
      Returns:
      the configuration specific to the HTTP/3 protocol.
    • setHttp3Config

      public HttpClientConfig setHttp3Config(Http3ClientConfig config)
      Set the HTTP/2 configuration to use
      Parameters:
      config - the config
      Returns:
      a reference to this, so the API can be used fluently
    • isVerifyHost

      public boolean isVerifyHost()
      Is hostname verification (for SSL/TLS) enabled?
      Returns:
      true if enabled
    • setVerifyHost

      public HttpClientConfig setVerifyHost(boolean verifyHost)
      Set whether hostname verification is enabled
      Parameters:
      verifyHost - true if enabled
      Returns:
      a reference to this, so the API can be used fluently
    • isDecompressionEnabled

      public boolean isDecompressionEnabled()
      Returns:
      true if the client should send requests with an accepting-encoding header set to a compression algorithm, false otherwise
    • setDecompressionEnabled

      public HttpClientConfig setDecompressionEnabled(boolean decompressionEnabled)
      Whether the client should send requests with an accepting-encoding header set to a compression algorithm.
      Parameters:
      decompressionEnabled - true if the client should send a request with an accepting-encoding header set to a compression algorithm, false otherwise
      Returns:
      a reference to this, so the API can be used fluently
    • getDefaultHost

      public String getDefaultHost()
      Get the default host name to be used by this client in requests if none is provided when making the request.
      Returns:
      the default host name
    • setDefaultHost

      public HttpClientConfig setDefaultHost(String defaultHost)
      Set the default host name to be used by this client in requests if none is provided when making the request.
      Returns:
      a reference to this, so the API can be used fluently
    • getDefaultPort

      public int getDefaultPort()
      Get the default port to be used by this client in requests if none is provided when making the request.
      Returns:
      the default port
    • setDefaultPort

      public HttpClientConfig setDefaultPort(int defaultPort)
      Set the default port to be used by this client in requests if none is provided when making the request.
      Returns:
      a reference to this, so the API can be used fluently
    • getMaxRedirects

      public int getMaxRedirects()
      Returns:
      the maximum number of redirection a request can follow
    • setMaxRedirects

      public HttpClientConfig setMaxRedirects(int maxRedirects)
      Set to maxRedirects the maximum number of redirection a request can follow.
      Parameters:
      maxRedirects - the maximum number of redirection
      Returns:
      a reference to this, so the API can be used fluently
    • getObservabilityConfig

      public ObservabilityConfig getObservabilityConfig()
      Returns:
      the client observability config.
    • setObservabilityConfig

      public HttpClientConfig setObservabilityConfig(ObservabilityConfig observabilityConfig)
      Set the client observability config.
      Parameters:
      observabilityConfig - the server observability config
      Returns:
      a reference to this, so the API can be used fluently
    • isShared

      public boolean isShared()
      Returns:
      whether the pool is shared
    • setShared

      public HttpClientConfig setShared(boolean shared)
      Set to true to share the client.

      There can be multiple shared clients distinguished by getName(), when no specific name is set, the HttpClientOptions.DEFAULT_NAME is used.

      Parameters:
      shared - true to use a shared client
      Returns:
      a reference to this, so the API can be used fluently
    • getName

      public String getName()
      Returns:
      the client name used for sharing
    • setName

      public HttpClientConfig setName(String name)
      Set the client name, used when the client is shared, otherwise ignored.
      Parameters:
      name - the new name
      Returns:
      a reference to this, so the API can be used fluently
    • getFollowAlternativeServices

      public boolean getFollowAlternativeServices()
      Returns:
      whether the client follows alternative services advertisements
    • setFollowAlternativeServices

      public HttpClientConfig setFollowAlternativeServices(boolean followAlternativeServices)

      Configure whether the client follows alternative services advertisements, the default setting does not.

      Setting this to true, instructs the client to use most appropriate alternative services advertised by HTTP servers.

      The client only follows alternative services it can trust for a given origin, in practice this means this only the https scheme is supported and alternatives handshake uses the alternative origin.

      Parameters:
      followAlternativeServices - the config value