Interface WebClient

All Superinterfaces:
HttpClient<HttpClientRequest>, ReleasableResource, RuntimeType.Api<WebClientConfig>
All Known Implementing Classes:
DirectWebClient

public interface WebClient extends RuntimeType.Api<WebClientConfig>, HttpClient<HttpClientRequest>
HTTP client.
  • Method Details

    • builder

      static WebClientConfig.Builder builder()
      Create a new builder of the HTTP protocol, that can be used with any supported version. Which versions are supported is determined by the classpath, HTTP/1.1 is always supported. To support a specific HTTP version only, you can use WebClientConfig.BuilderBase.addProtocolPreference(java.util.List).
      Returns:
      new HTTP client builder
    • create

      static WebClient create()
      Create a new web client with default configuration.
      Returns:
      a new web client
    • create

      static WebClient create(WebClientConfig config)
      Create a new webclient with customized configuration.
      Parameters:
      config - configuration to use
      Returns:
      a new web client
    • create

      static WebClient create(Consumer<WebClientConfig.Builder> consumer)
      Create a new webclient, customizing its configuration.
      Parameters:
      consumer - configuration consumer
      Returns:
      a new web client
    • client

      <T, C extends ProtocolConfig> T client(Protocol<T,C> protocol, C protocolConfig)
      To switch to a non-HTTP protocol client (or a client of a specific HTTP version). The resulting protocol will use this client as a base, so it will share all configuration that is relevant for the protocol.
      Type Parameters:
      T - type of the protocol client
      C - type of the protocol config
      Parameters:
      protocol - protocol instance, usually defined as a constant on the protocol interface
      protocolConfig - configuration of the protocol to be used (if customization is required)
      Returns:
      a new protocol client instance
    • client

      <T, C extends ProtocolConfig> T client(Protocol<T,C> protocol)
      To switch to a non-HTTP protocol client (or a client of a specific HTTP version) using its config configured when creating the client, or default config if none configured. The resulting protocol will use this client as a base, so it will share all configuration that is relevant for the protocol.
      Type Parameters:
      T - type of the protocol client
      C - type of the protocol config
      Parameters:
      protocol - protocol instance, usually defined as a constant on the protocol interface
      Returns:
      a new protocol client instance
    • executor

      ExecutorService executor()
      Executor services, uses virtual threads.
      Returns:
      executor service
    • cookieManager

      WebClientCookieManager cookieManager()
      Cookie manager to use by this client.
      Returns:
      cookie manager