Interface HttpTransport
- All Superinterfaces:
AutoCloseable,Closeable
- All Known Implementing Classes:
ApacheHc45Transport,ApacheHc5Transport,JavaHttpTransport,JettyHttpTransport,MockHttpTransport,OkHttpTransport
An HttpTransport is responsible for executing a fully-resolved TransportRequest and returning a
TransportResponse. Implementations include:
ApacheHc45Transport(modulejuneau-rest-client-apache-httpclient-45)ApacheHc5Transport(modulejuneau-rest-client-apache-httpclient-50)JavaHttpTransport(modulejuneau-rest-client-java-httpclient)OkHttpTransport(modulejuneau-rest-client-okhttp)JettyHttpTransport(modulejuneau-rest-client-jetty)MockHttpTransport(modulejuneau-rest-mock)
Implementations are discovered automatically via HttpTransportProvider using ServiceLoader,
or set explicitly via RestClient.Builder#transport(HttpTransport).
See Also:
- Since:
- 9.2.1
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidclose()Releases resources held by this transport (connection pools, threads, etc.).execute(TransportRequest request) Executes the given request and returns the response.default booleanReturnstrueif 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).
-
Method Details
-
execute
Executes the given request and returns the response.The caller is responsible for closing the returned
TransportResponseafter consuming the body.- Parameters:
request- The fully-resolved request. Must not benull .- Returns:
- The response. Never
null . - Throws:
TransportException- If a network-level error occurs.
-
supportsUrlPolicy
Returnstrueif 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, soRestRequest#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 returntrue.- Returns:
trueif this transport supports pin-on-connect + redirect revalidation for policy-covered requests.
-
close
Releases resources held by this transport (connection pools, threads, etc.).The default implementation is a no-op.
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-