Class ApacheHc5Transport
- All Implemented Interfaces:
Closeable,AutoCloseable,HttpTransport
HttpTransport implementation backed by Apache HttpClient 5.x.
This transport is auto-discovered via ServiceLoader when
org.apache.httpcomponents.client5:httpclient5 is on the classpath. You can also instantiate it explicitly:
The transport passes each ordinary request a per-request context that removes the caller's credential headers
(RedirectSecurity.stripOnCrossOrigin()) from a redirect hop to another origin and from every later hop. On
the client the transport creates itself, a redirect to another origin is therefore followed without those headers.
With a caller-supplied client, the client's own redirect settings and RedirectStrategy decide which redirects
are followed, and the context guards whatever strategy the client was built with, including
LaxRedirectStrategy.
See Also:
- Since:
- 9.2.1
-
Method Summary
Modifier and TypeMethodDescriptionstatic ApacheHc5TransportBuilderbuilder()Returns a new builder for this transport.voidclose()Releases resources held by this transport (connection pools, threads, etc.).static ApacheHc5Transportcreate()Returns a new instance backed by a defaultCloseableHttpClient.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 defaultCloseableHttpClient.- Returns:
- A new instance. Never
null .
-
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
-