Class DefaultHttpTransport

java.lang.Object
com.hedera.hashgraph.sdk.DefaultHttpTransport
All Implemented Interfaces:
HttpTransport

public final class DefaultHttpTransport extends Object implements HttpTransport
The SDK-supplied HttpTransport, used when no transport is injected.

This is the only class in the SDK's new transport layer that names java.net.http, and it always names it fully qualified — the SDK's own HttpRequest and HttpResponse live in this package and would otherwise be ambiguous to a reader. Please do not "tidy" the qualified names into imports. Keeping every java.net.http reference inside this one class is also what lets an Android application inject an OkHttp-backed transport and never load this class, on a platform where java.net.http does not exist at any API level.

  • Method Details

    • create

      public static DefaultHttpTransport create(HttpTransportConfiguration configuration)
      Build a transport with a private connection pool, so pool limits and TLS settings belong to the SDK and are not affected by anything else in the process.

      The pool is private but not isolated from the environment: like the JDK's own default client it honours the http.proxyHost family of system properties.

      Parameters:
      configuration - how to build it
      Returns:
      the new transport
    • roundTrip

      public CompletionStage<HttpResponse> roundTrip(HttpRequest request, Cancellation cancellation)
      Description copied from interface: HttpTransport
      Perform one exchange.

      Never throws: a failure completes the returned stage exceptionally with an HttpTransportException.

      Specified by:
      roundTrip in interface HttpTransport
      Parameters:
      request - the request to perform
      cancellation - the caller's cancellation; Cancellation.none() when there is none. An implementation must release its registration when the exchange ends.
      Returns:
      a stage completing with the response, or exceptionally with an HttpTransportException
    • close

      public void close(Duration closeTimeout)
      Description copied from interface: HttpTransport
      Release whatever this transport owns, within a bounded grace period.

      Not asynchronous, because every SDK's Client.close() is synchronous and making this one asynchronous would make that one asynchronous too.

      Specified by:
      close in interface HttpTransport
      Parameters:
      closeTimeout - how long to wait for exchanges already in flight before cancelling them