Class HttpHandler.HttpHandlerBuilder

java.lang.Object
de.cuioss.http.client.handler.HttpHandler.HttpHandlerBuilder
Enclosing class:
HttpHandler

public static class HttpHandler.HttpHandlerBuilder extends Object
Builder for creating HttpHandler instances.
  • Constructor Details

  • Method Details

    • uri

      Sets the URI as a string.
      Parameters:
      uriString - The string representation of the URI. Must not be null or empty.
      Returns:
      This builder instance.
      Throws:
      IllegalArgumentException - if the URI string is null, empty, or malformed (thrown during the build() method execution, not by this setter method)
    • uri

      Sets the URI directly.

      Note: If both URI and URL are set, the URI takes precedence.

      Parameters:
      uri - The URI to be used for HTTP requests. Must not be null.
      Returns:
      This builder instance.
    • url

      Sets the URL as a string.

      Note: This method is provided for backward compatibility. Consider using uri(String) instead.

      Parameters:
      urlString - The string representation of the URL. Must not be null or empty.
      Returns:
      This builder instance.
      Throws:
      IllegalArgumentException - if the URL string is null, empty, or malformed (thrown during the build() method execution, not by this setter method)
    • url

      Sets the URL directly.

      Note: This method is provided for backward compatibility. Consider using uri(URI) instead.

      If both URI and URL are set, the URI takes precedence.

      Parameters:
      url - The URL to be used for HTTP requests. Must not be null.
      Returns:
      This builder instance.
    • sslContext

      public HttpHandler.HttpHandlerBuilder sslContext(@Nullable SSLContext sslContext)
      Sets the SSL context to use for HTTPS connections.

      If not set, a default secure SSL context will be created.

      Parameters:
      sslContext - The SSL context to use.
      Returns:
      This builder instance.
    • tlsVersions

      public HttpHandler.HttpHandlerBuilder tlsVersions(@Nullable SecureSSLContextProvider secureSSLContextProvider)
      Sets the TLS versions configuration.
      Parameters:
      secureSSLContextProvider - The TLS versions configuration to use.
      Returns:
      This builder instance.
    • connectionTimeoutSeconds

      public HttpHandler.HttpHandlerBuilder connectionTimeoutSeconds(int connectionTimeoutSeconds)
      Sets the connection timeout in seconds for HTTP requests.

      If not set, a default timeout of 10 seconds will be used.

      Parameters:
      connectionTimeoutSeconds - The connection timeout in seconds. Must be positive.
      Returns:
      This builder instance.
    • readTimeoutSeconds

      public HttpHandler.HttpHandlerBuilder readTimeoutSeconds(int readTimeoutSeconds)
      Sets the read timeout in seconds for HTTP requests.

      If not set, a default timeout of 10 seconds will be used.

      Parameters:
      readTimeoutSeconds - The read timeout in seconds. Must be positive.
      Returns:
      This builder instance.
    • build

      public HttpHandler build()
      Builds a new HttpHandler instance with the configured parameters.
      Returns:
      A new HttpHandler instance.
      Throws:
      IllegalArgumentException - If any parameter is invalid.