Class CachingWebClientConfig


public class CachingWebClientConfig extends WebClientConfig
Author:
Craig Day
  • Field Details

    • DEFAULT_CACHED_STATUS_CODES

      public static final Set<Integer> DEFAULT_CACHED_STATUS_CODES
    • DEFAULT_CACHED_METHODS

      public static final Set<HttpMethod> DEFAULT_CACHED_METHODS
  • Constructor Details

    • CachingWebClientConfig

      public CachingWebClientConfig()
    • CachingWebClientConfig

      public CachingWebClientConfig(WebClientConfig other)
  • Method Details

    • setEnableVaryCaching

      public CachingWebClientConfig setEnableVaryCaching(boolean enabled)
      Configure the client cache behavior for Vary responses.
      Parameters:
      enabled - true to enable caching varying responses
      Returns:
      a reference to this, so the API can be used fluently
    • getCachedStatusCodes

      public Set<Integer> getCachedStatusCodes()
      Returns:
      the set of status codes to consider cacheable.
    • setCachedStatusCodes

      public CachingWebClientConfig setCachedStatusCodes(Set<Integer> codes)
      Configure the status codes that can be cached.
      Parameters:
      codes - the cacheable status code numbers
      Returns:
      a reference to this, so the API can be used fluently
    • addCachedStatusCode

      public CachingWebClientConfig addCachedStatusCode(Integer code)
      Add a status code that is cacheable.
      Parameters:
      code - the additional code number
      Returns:
      a reference to this, so the API can be used fluently
    • removeCachedStatusCode

      public CachingWebClientConfig removeCachedStatusCode(Integer code)
      Remove a status code that is cacheable.
      Parameters:
      code - the code number to remove
      Returns:
      a reference to this, so the API can be used fluently
    • getCachedMethods

      public Set<HttpMethod> getCachedMethods()
      Returns:
      the set of HTTP methods to consider cacheable.
    • setCachedMethods

      public CachingWebClientConfig setCachedMethods(Set<HttpMethod> methods)
      Configure the HTTP methods that can be cached.
      Parameters:
      methods - the HTTP methods to cache
      Returns:
      a reference to this, so the API can be used fluently
    • addCachedMethod

      public CachingWebClientConfig addCachedMethod(HttpMethod method)
      Add an HTTP method that is cacheable.
      Parameters:
      method - the method to add
      Returns:
      a reference to this, so the API can be used fluently
    • removeCachedMethod

      public CachingWebClientConfig removeCachedMethod(HttpMethod method)
      Remove an HTTP method that is cacheable.
      Parameters:
      method - the method to remove
      Returns:
      a reference to this, so the API can be used fluently
    • isVaryCachingEnabled

      public boolean isVaryCachingEnabled()
      Returns:
      true if the client will cache responses with the Vary header, false otherwise
    • setUserAgentEnabled

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

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

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

      public CachingWebClientConfig setTemplateExpandOptions(ExpandOptions templateExpandOptions)
      Overrides:
      setTemplateExpandOptions in class WebClientConfig
    • setConnectTimeout

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

      public CachingWebClientConfig 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 WebClientConfig
      Parameters:
      idleTimeout - the timeout
      Returns:
      a reference to this, so the API can be used fluently
    • setReadIdleTimeout

      public CachingWebClientConfig 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 WebClientConfig
      Parameters:
      idleTimeout - the read timeout
      Returns:
      a reference to this, so the API can be used fluently
    • setWriteIdleTimeout

      public CachingWebClientConfig 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 WebClientConfig
      Parameters:
      idleTimeout - the write timeout
      Returns:
      a reference to this, so the API can be used fluently
    • setLogConfig

      public CachingWebClientConfig 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 WebClientConfig
      Parameters:
      config - the stream network logging config, null means disabled
      Returns:
      a reference to this, so the API can be used fluently
    • setSsl

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

      public CachingWebClientConfig 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 WebClientConfig
      Parameters:
      versions - the ordered list of supported versions
      Returns:
      a reference to this, so the API can be used fluently
    • setHttp1Config

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

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

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

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

      public CachingWebClientConfig 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 WebClientConfig
      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 CachingWebClientConfig 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 WebClientConfig
      Returns:
      a reference to this, so the API can be used fluently
    • setDefaultPort

      public CachingWebClientConfig 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 WebClientConfig
      Returns:
      a reference to this, so the API can be used fluently
    • setMaxRedirects

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

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

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

      public CachingWebClientConfig 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 WebClientConfig
      Parameters:
      keepAliveTimeout - the timeout, in seconds
      Returns:
      a reference to this, so the API can be used fluently
    • setShared

      public CachingWebClientConfig 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 WebClientConfig
      Parameters:
      shared - true to use a shared client
      Returns:
      a reference to this, so the API can be used fluently
    • setName

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

      public CachingWebClientConfig 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 WebClientConfig
      Parameters:
      followAlternativeServices - the config value