Class WebClientConfig

java.lang.Object
io.vertx.core.http.HttpClientConfig
io.vertx.ext.web.client.WebClientConfig
Direct Known Subclasses:
CachingWebClientConfig

public class WebClientConfig extends HttpClientConfig
Author:
Thomas Segismont
  • Constructor Details

    • WebClientConfig

      public WebClientConfig()
    • WebClientConfig

      public WebClientConfig(WebClientConfig other)
      Copy constructor.
      Parameters:
      other - the options to copy
    • WebClientConfig

      public WebClientConfig(HttpClientConfig other)
      Copy constructor.
      Parameters:
      other - the options to copy
  • Method Details

    • isUserAgentEnabled

      public boolean isUserAgentEnabled()
      Returns:
      true if the Web Client should send a user agent header, false otherwise
    • setUserAgentEnabled

      public WebClientConfig setUserAgentEnabled(boolean userAgentEnabled)
      Sets whether the Web Client should send a user agent header. Defaults to true.
      Parameters:
      userAgentEnabled - true to send a user agent header, false otherwise
      Returns:
      a reference to this, so the API can be used fluently
    • getUserAgent

      public String getUserAgent()
      Returns:
      the user agent header string
    • setUserAgent

      public WebClientConfig setUserAgent(String userAgent)
      Sets the Web Client user agent header. Defaults to Vert.x-WebClient/<version>.
      Parameters:
      userAgent - user agent header value
      Returns:
      a reference to this, so the API can be used fluently
    • isFollowRedirects

      public boolean isFollowRedirects()
      Returns:
      the default behavior of the client for following HTTP 30x redirections
    • setFollowRedirects

      public WebClientConfig setFollowRedirects(boolean followRedirects)
      Configure the default behavior of the client to follow HTTP 30x redirections.
      Parameters:
      followRedirects - true when a redirect is followed
      Returns:
      a reference to this, so the API can be used fluently
    • getTemplateExpandOptions

      public ExpandOptions getTemplateExpandOptions()
    • setTemplateExpandOptions

      public WebClientConfig setTemplateExpandOptions(ExpandOptions templateExpandOptions)
    • setKeepAliveTimeout

      public WebClientConfig setKeepAliveTimeout(Duration keepAliveTimeout)
      Description copied from class: HttpClientConfig

      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.

      Overrides:
      setKeepAliveTimeout in class HttpClientConfig
      Parameters:
      keepAliveTimeout - the timeout, in seconds
      Returns:
      a reference to this, so the API can be used fluently
    • setVersions

      public WebClientConfig setVersions(HttpVersion... versions)
      Description copied from class: HttpClientConfig
      Overrides:
      setVersions in class HttpClientConfig
      Parameters:
      versions - the ordered list of supported versions
      Returns:
      a reference to this, so the API can be used fluently
    • setConnectTimeout

      public WebClientConfig setConnectTimeout(Duration connectTimeout)
      Description copied from class: HttpClientConfig
      Set the connect timeout
      Overrides:
      setConnectTimeout in class HttpClientConfig
      Parameters:
      connectTimeout - connect timeout, in ms
      Returns:
      a reference to this, so the API can be used fluently
    • setIdleTimeout

      public WebClientConfig setIdleTimeout(Duration idleTimeout)
      Description copied from class: HttpClientConfig
      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.

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

      public WebClientConfig setReadIdleTimeout(Duration idleTimeout)
      Description copied from class: HttpClientConfig

      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.

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

      public WebClientConfig setWriteIdleTimeout(Duration idleTimeout)
      Description copied from class: HttpClientConfig

      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.

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

      public WebClientConfig setLogConfig(LogConfig config)
      Description copied from class: HttpClientConfig

      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.

      Overrides:
      setLogConfig in class HttpClientConfig
      Parameters:
      config - the stream network logging config, null means disabled
      Returns:
      a reference to this, so the API can be used fluently
    • setSsl

      public WebClientConfig setSsl(boolean ssl)
      Description copied from class: HttpClientConfig
      Set whether SSL/TLS is enabled
      Overrides:
      setSsl in class HttpClientConfig
      Parameters:
      ssl - true if enabled
      Returns:
      a reference to this, so the API can be used fluently
    • setVersions

      public WebClientConfig setVersions(List<HttpVersion> versions)
      Description copied from class: HttpClientConfig

      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.

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

      public WebClientConfig setHttp1Config(Http1ClientConfig config)
      Description copied from class: HttpClientConfig
      Set the HTTP/1.x configuration to use
      Overrides:
      setHttp1Config in class HttpClientConfig
      Parameters:
      config - the config
      Returns:
      a reference to this, so the API can be used fluently
    • setHttp2Config

      public WebClientConfig setHttp2Config(Http2ClientConfig config)
      Description copied from class: HttpClientConfig
      Set the HTTP/2 configuration to use
      Overrides:
      setHttp2Config in class HttpClientConfig
      Parameters:
      config - the config
      Returns:
      a reference to this, so the API can be used fluently
    • setHttp3Config

      public WebClientConfig setHttp3Config(Http3ClientConfig config)
      Description copied from class: HttpClientConfig
      Set the HTTP/2 configuration to use
      Overrides:
      setHttp3Config in class HttpClientConfig
      Parameters:
      config - the config
      Returns:
      a reference to this, so the API can be used fluently
    • setVerifyHost

      public WebClientConfig setVerifyHost(boolean verifyHost)
      Description copied from class: HttpClientConfig
      Set whether hostname verification is enabled
      Overrides:
      setVerifyHost in class HttpClientConfig
      Parameters:
      verifyHost - true if enabled
      Returns:
      a reference to this, so the API can be used fluently
    • setDecompressionEnabled

      public WebClientConfig setDecompressionEnabled(boolean decompressionEnabled)
      Description copied from class: HttpClientConfig
      Whether the client should send requests with an accepting-encoding header set to a compression algorithm.
      Overrides:
      setDecompressionEnabled in class HttpClientConfig
      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
    • setDefaultHost

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

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

      public WebClientConfig setMaxRedirects(int maxRedirects)
      Description copied from class: HttpClientConfig
      Set to maxRedirects the maximum number of redirection a request can follow.
      Overrides:
      setMaxRedirects in class HttpClientConfig
      Parameters:
      maxRedirects - the maximum number of redirection
      Returns:
      a reference to this, so the API can be used fluently
    • setObservabilityConfig

      public WebClientConfig setObservabilityConfig(ObservabilityConfig observabilityConfig)
      Description copied from class: HttpClientConfig
      Set the client observability config.
      Overrides:
      setObservabilityConfig in class HttpClientConfig
      Parameters:
      observabilityConfig - the server observability config
      Returns:
      a reference to this, so the API can be used fluently
    • setShared

      public WebClientConfig setShared(boolean shared)
      Description copied from class: HttpClientConfig
      Set to true to share the client.

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

      Overrides:
      setShared in class HttpClientConfig
      Parameters:
      shared - true to use a shared client
      Returns:
      a reference to this, so the API can be used fluently
    • setName

      public WebClientConfig setName(String name)
      Description copied from class: HttpClientConfig
      Set the client name, used when the client is shared, otherwise ignored.
      Overrides:
      setName in class HttpClientConfig
      Parameters:
      name - the new name
      Returns:
      a reference to this, so the API can be used fluently
    • setFollowAlternativeServices

      public WebClientConfig setFollowAlternativeServices(boolean followAlternativeServices)
      Description copied from class: HttpClientConfig

      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.

      Overrides:
      setFollowAlternativeServices in class HttpClientConfig
      Parameters:
      followAlternativeServices - the config value