Class JettyHttpTransport
- All Implemented Interfaces:
Closeable,AutoCloseable,HttpTransport
HttpTransport implementation backed by Jetty 12 HttpClient.
This transport is auto-discovered via ServiceLoader when
org.eclipse.jetty:jetty-client is on the classpath. You can also instantiate it explicitly:
The Jetty HttpClient is started automatically when the transport is created and stopped when
close() is called. The request body is streamed via OutputStreamRequestContent using
a background thread, avoiding full in-memory buffering. The response header timeout defaults to 30 seconds
and is configurable via JettyHttpTransportBuilder.responseTimeoutMs(long).
See Also:
- Since:
- 9.2.1
-
Method Summary
Modifier and TypeMethodDescriptionstatic JettyHttpTransportBuilderbuilder()Returns a new builder for this transport.voidclose()Releases resources held by this transport (connection pools, threads, etc.).static JettyHttpTransportcreate()Returns a new instance backed by a defaultHttpClient.execute(TransportRequest request) Executes the given request and returns the response.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
-
builder
Returns a new builder for this transport.- Returns:
- A new builder. Never
null .
-
create
Returns a new instance backed by a defaultHttpClient.- Returns:
- A new instance. Never
null . - Throws:
Exception- If the JettyHttpClientcannot be started.
-
execute
Description copied from interface:HttpTransportExecutes the given request and returns the response.The caller is responsible for closing the returned
TransportResponseafter consuming the body.- Specified by:
executein interfaceHttpTransport- Parameters:
request- The fully-resolved request. Must not benull .- Returns:
- The response. Never
null . - Throws:
TransportException- If a network-level error occurs.
-
supportsUrlPolicy
Description copied from interface:HttpTransportReturnstrueif 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.- Specified by:
supportsUrlPolicyin interfaceHttpTransport- Returns:
trueif this transport supports pin-on-connect + redirect revalidation for policy-covered requests.
-
close
Description copied from interface:HttpTransportReleases resources held by this transport (connection pools, threads, etc.).The default implementation is a no-op.
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceHttpTransport- Throws:
IOException
-