Class RDF4JHttpClientConfig.Builder

java.lang.Object
org.eclipse.rdf4j.http.client.spi.RDF4JHttpClientConfig.Builder
Enclosing class:
RDF4JHttpClientConfig

public static class RDF4JHttpClientConfig.Builder extends Object
Builder for RDF4JHttpClientConfig.

Default values:

  • connectTimeoutMs = 30,000 ms
  • socketTimeoutMs = 0 (infinite)
  • connectionRequestTimeoutMs = 3,600,000 ms (1 hour)
  • maxConnectionsPerRoute = 25
  • maxConnectionsTotal = 50
  • maxRedirects = 5
  • followRedirects = true
  • idleConnectionTimeoutMs = 300,000 ms (5 minutes)
  • sslContext = none (uses JVM default)
  • disableHostnameVerification = false
  • Constructor Details

    • Builder

      protected Builder()
  • Method Details

    • connectTimeoutMs

      public RDF4JHttpClientConfig.Builder connectTimeoutMs(int connectTimeoutMs)
      Sets the connection timeout in milliseconds.
      Parameters:
      connectTimeoutMs - connection timeout in milliseconds; must be non-negative
      Returns:
      this builder
    • socketTimeoutMs

      public RDF4JHttpClientConfig.Builder socketTimeoutMs(int socketTimeoutMs)
      Sets the socket (read) timeout in milliseconds. Use 0 for an infinite timeout.
      Parameters:
      socketTimeoutMs - socket timeout in milliseconds; must be non-negative
      Returns:
      this builder
    • connectionRequestTimeoutMs

      public RDF4JHttpClientConfig.Builder connectionRequestTimeoutMs(int connectionRequestTimeoutMs)
      Sets the connection request timeout in milliseconds. This is the maximum time to wait when requesting a connection from the connection pool.
      Parameters:
      connectionRequestTimeoutMs - connection request timeout in milliseconds; must be non-negative
      Returns:
      this builder
    • maxConnectionsPerRoute

      public RDF4JHttpClientConfig.Builder maxConnectionsPerRoute(int maxConnectionsPerRoute)
      Sets the maximum number of concurrent connections per route (i.e. per target host).
      Parameters:
      maxConnectionsPerRoute - maximum connections per route; must be positive
      Returns:
      this builder
    • maxConnectionsTotal

      public RDF4JHttpClientConfig.Builder maxConnectionsTotal(int maxConnectionsTotal)
      Sets the maximum total number of concurrent connections across all routes.
      Parameters:
      maxConnectionsTotal - maximum total connections; must be positive
      Returns:
      this builder
    • maxRedirects

      public RDF4JHttpClientConfig.Builder maxRedirects(int maxRedirects)
      Sets the maximum number of redirects to follow when redirect following is enabled.
      Parameters:
      maxRedirects - maximum number of redirects; must be non-negative
      Returns:
      this builder
    • followRedirects

      public RDF4JHttpClientConfig.Builder followRedirects(boolean followRedirects)
      Sets whether HTTP redirects should be followed automatically.
      Parameters:
      followRedirects - true to follow redirects, false to disable
      Returns:
      this builder
    • idleConnectionTimeoutMs

      public RDF4JHttpClientConfig.Builder idleConnectionTimeoutMs(long idleConnectionTimeoutMs)
      Sets the maximum time that a pooled connection may remain idle before being evicted. Use 0 to disable idle eviction.
      Parameters:
      idleConnectionTimeoutMs - idle timeout in milliseconds; must be non-negative
      Returns:
      this builder
    • sslContext

      public RDF4JHttpClientConfig.Builder sslContext(SSLContext sslContext)
      Sets a custom SSLContext for HTTPS connections. If not set, the JVM default SSL context is used.
      Parameters:
      sslContext - the SSLContext to use, or null to use the JVM default
      Returns:
      this builder
    • disableHostnameVerification

      public RDF4JHttpClientConfig.Builder disableHostnameVerification(boolean disableHostnameVerification)
      Disables TLS hostname verification. When set to true, the client will accept certificates even if the hostname does not match the certificate's CN/SAN fields.

      Warning: disabling hostname verification removes an important security check. Only use this in controlled environments (e.g. testing against self-signed certificates with hostname mismatches).

      Parameters:
      disableHostnameVerification - true to disable hostname verification
      Returns:
      this builder
    • defaultHeaders

      public RDF4JHttpClientConfig.Builder defaultHeaders(List<HttpHeader> defaultHeaders)
      Sets the default HTTP headers to be sent with every request.
      Parameters:
      defaultHeaders - the headers to send by default; must not be null
      Returns:
      this builder
    • defaultHeader

      public RDF4JHttpClientConfig.Builder defaultHeader(String name, String value)
      Adds a single default HTTP header to be sent with every request.
      Parameters:
      name - the header name; must not be null
      value - the header value; must not be null
      Returns:
      this builder
    • build

      public RDF4JHttpClientConfig build()
      Builds a new RDF4JHttpClientConfig from the current builder state.
      Returns:
      a new RDF4JHttpClientConfig