Class ApacheHc45Transport

java.lang.Object
org.apache.juneau.rest.client.apachehttpclient45.ApacheHc45Transport
All Implemented Interfaces:
Closeable, AutoCloseable, HttpTransport

public final class ApacheHc45Transport extends Object implements HttpTransport
HttpTransport implementation backed by Apache HttpClient 4.5.

This transport is auto-discovered via ServiceLoader when org.apache.httpcomponents:httpclient is on the classpath. You can also instantiate it explicitly:

transport = ApacheHc45Transport.builder() .httpClient(HttpClients.createDefault()) .build(); client = RestClient.builder() .transport(transport) .build();

See Also:
Since:
9.2.1
  • Method Details

    • builder

      Returns a new builder for this transport.
      Returns:
      A new builder. Never null.
    • create

      public static ApacheHc45Transport create()
      Returns a new instance backed by a default CloseableHttpClient.
      Returns:
      A new instance. Never null.
    • execute

      Description copied from interface: HttpTransport
      Executes the given request and returns the response.

      The caller is responsible for closing the returned TransportResponse after consuming the body.

      Specified by:
      execute in interface HttpTransport
      Parameters:
      request - The fully-resolved request. Must not be null.
      Returns:
      The response. Never null.
      Throws:
      TransportException - If a network-level error occurs.
    • supportsUrlPolicy

      public boolean supportsUrlPolicy()
      Description copied from interface: HttpTransport
      Returns true if this transport can honor the SSRF guardrail's connect-time contract for a policy-covered request (TransportRequest.isSsrfGuardActive()): pin-on-connect to a resolved address that has passed the deny-private policy, and Juneau-controlled redirect revalidation (no fallback to the transport's own auto-follow).

      The default implementation returns false (fail closed): an unknown/caller-supplied transport that has not affirmatively opted in is presumed unable to honor the contract, so RestRequest#run() rejects policy-covered requests against it rather than silently connecting without the guardrail. First-party transports that construct and fully control their own underlying HTTP client override this to return true.

      Specified by:
      supportsUrlPolicy in interface HttpTransport
      Returns:
      true if this transport supports pin-on-connect + redirect revalidation for policy-covered requests.
    • close

      public void close() throws IOException
      Description copied from interface: HttpTransport
      Releases resources held by this transport (connection pools, threads, etc.).

      The default implementation is a no-op.

      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface HttpTransport
      Throws:
      IOException