Class JavaHttpTransportBuilder

java.lang.Object
org.apache.juneau.rest.client.JavaHttpTransportBuilder

public final class JavaHttpTransportBuilder extends Object
Fluent builder for JavaHttpTransport.

Obtain an instance via JavaHttpTransport.builder().

See Also:

Since:
9.2.1
  • Method Details

    • allowHostHeaderOverride

      Opts in to sending a caller-controlled Host header, which pinning a policy-covered HTTP request needs.

      The JDK HttpClient rejects a Host header unless the JVM property jdk.httpclient.allowRestrictedHeaders lists it. Without this opt-in a policy-covered HTTP request that needs a Host override fails closed.

      This setting changes a JVM-wide property. Building the transport adds host to the system property jdk.httpclient.allowRestrictedHeaders, which affects every HttpClient in the JVM. The JDK reads the property once, the first time any code builds a request header, so it only takes effect if that has not happened yet; otherwise start the JVM with -Djdk.httpclient.allowRestrictedHeaders=host.

      Returns:
      This object.
    • maxResponseBytes

      Sets the maximum number of response body bytes the transport delivers; reading further fails with an IOException.
      Parameters:
      value - The cap in bytes. Zero or negative means unlimited. Defaults to JavaHttpTransport.DEFAULT_MAX_RESPONSE_BYTES.
      Returns:
      This object.
    • httpClient

      Sets the underlying HttpClient to use.

      If not set, a default client is created via HttpClient.newHttpClient().

      Parameters:
      value - The client to use. Can be null (a default client is created via HttpClient.newHttpClient()).
      Returns:
      This object.
    • build

      Builds and returns the JavaHttpTransport.
      Returns:
      A new instance. Never null.