- All Known Implementing Classes:
DefaultHttpTransport
This is the type an application, a platform or a test implements to replace the SDK's HTTP stack —
for a corporate proxy, mTLS, tracing, or to run on Android, where java.net.http does not
exist at any API level.
An implementer must satisfy the following; everything not listed is free.
- A non-2xx status is a successful exchange.
404and503come back as anHttpResponsecarrying their status code. The transport must not fail on a status code; the layer above reads it and decides. - Only a failure to obtain a response fails the call, and it fails with an
HttpTransportExceptioncarrying one of theHttpTransportErrorKindidentifiers. A failure the layer above cannot classify is treated as non-retryable. - No policy at this layer. No retry, no backoff, no rate limiting, no circuit breaking, no status interpretation.
roundTrip(com.hedera.hashgraph.sdk.HttpRequest, com.hedera.hashgraph.sdk.Cancellation)is safe to call concurrently, including concurrently withclose(java.time.Duration).- The body is fully buffered before the returned stage completes, bounded by
HttpTransportConfiguration.getMaxResponseBytes(). That is what lets the layer above replay a request without body-lifecycle discipline at every call site. close(java.time.Duration)aborts, draining first where it can. It stops accepting new work, waits up to its timeout for exchanges in flight, then cancels whatever remains. It is idempotent and never reports failure — a bounded shutdown is the guarantee, not an outcome.close(java.time.Duration)releases only what the transport itself owns. A transport wrapping a client the application built must not shut that client down; aclosethat does nothing is a conformingclose.- After
close(java.time.Duration),roundTrip(com.hedera.hashgraph.sdk.HttpRequest, com.hedera.hashgraph.sdk.Cancellation)fails fast withHttpTransportErrorKind.CLIENT_CLOSED_ERRORand must not open a new connection or construct a replacement client.
Ownership follows construction. A Client closes only a transport it built itself; an
injected transport is never closed by the SDK, because it is almost always a wrapper over a
process-wide client the application also uses.
-
Method Summary
Modifier and TypeMethodDescriptionvoidRelease whatever this transport owns, within a bounded grace period.roundTrip(HttpRequest request, Cancellation cancellation) Perform one exchange.
-
Method Details
-
roundTrip
Perform one exchange.Never throws: a failure completes the returned stage exceptionally with an
HttpTransportException.- Parameters:
request- the request to performcancellation- 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
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.- Parameters:
closeTimeout- how long to wait for exchanges already in flight before cancelling them
-