static final class HttpBuilder.Config
extends Object
Configuration DSL used to create an HttpBuilder.
| Type | Name and description |
|---|---|
URI |
baseUriAbsolute base URI used to resolve relative request URIs. |
Closure<?> |
clientConfigurerOptional hook for advanced HttpClient.Builder customization. |
boolean |
confineToBaseUriWhether request URIs are confined to baseUri. |
Duration |
connectTimeoutTimeout applied when opening connections. |
boolean |
followRedirectsWhether redirects should be followed automatically. |
Map<String, String> |
headersHeaders added to every request created by the builder. |
Duration |
requestTimeoutTimeout applied to each request when not overridden. |
| Constructor and description |
|---|
HttpBuilder.Config() |
| Type Params | Return Type | Name and description |
|---|---|---|
|
void |
baseUri(Object value)Sets the absolute base URI used for relative requests. |
|
void |
clientConfig(Closure<?> configurer)Provides direct access to the underlying HttpClient.Builder
for advanced configuration (authenticator, SSL context, proxy, cookie handler, etc.). |
|
void |
confineToBaseUri(boolean value)Confines every request to the configured baseUri. |
|
void |
connectTimeout(Duration value)Sets the client connect timeout. |
|
void |
followRedirects(boolean value)Enables or disables automatic redirect following. |
|
void |
header(String name, Object value)Adds a default header to every request. |
|
void |
headers(Map<String, ?> values)Adds multiple default headers to every request. |
|
void |
requestTimeout(Duration value)Sets the default request timeout. |
Absolute base URI used to resolve relative request URIs.
Optional hook for advanced HttpClient.Builder customization.
Whether request URIs are confined to baseUri. When enabled,
requests that resolve to a different origin (scheme, host, or effective
port) or escape the base path prefix are rejected with a
SecurityException. Requires baseUri to be configured.
Timeout applied when opening connections.
Whether redirects should be followed automatically. When enabled, a hop that
leaves the origin of the first request sheds the caller's headers; see
followRedirects(boolean) for the full policy. Defaults to false,
returning any 3xx response to the caller as-is.
Timeout applied to each request when not overridden.
Sets the absolute base URI used for relative requests.
value - the base URI as a URI or coercible string Provides direct access to the underlying HttpClient.Builder
for advanced configuration (authenticator, SSL context, proxy, cookie handler, etc.).
Redirect policy is the exception: it is owned by followRedirects so that every hop can be gated against confinement and against the origin the caller's headers were set for. A redirect policy set on the raw builder here is overridden.
configurer - a closure taking an HttpClient.Builder Confines every request to the configured baseUri. Absolute
request URIs pointing at another origin, and relative URIs that walk
above the base path (e.g. via .. or a leading /), are
rejected with a SecurityException instead of being executed.
value - true to reject requests that escape the base URISets the client connect timeout.
value - the connection timeout Enables or disables automatic redirect following. When enabled, at most five
hops are followed, rewriting methods like HttpClient.Redirect#NORMAL:
301/302 downgrade POST to GET (dropping the body), 303
downgrades everything except HEAD to GET, and 307/308 preserve
the method and body.
Headers are treated as configured for one origin: the scheme, host, and
effective port of the first request. A hop that stays on that origin keeps
every header. A hop that leaves it sheds all caller-supplied headers — builder
defaults and per-request headers alike — for the remainder of the chain,
including any later hop back to the original origin. The one exception is
Content-Type, which stays with a 307/308 hop that forwards the body it
describes. A hop from an https URL to a plain http one is never followed; the
3xx is returned to the caller. Callers who need credentials sent to a redirect
target on another origin should issue a request to that target directly.
value - true to follow redirectsAdds a default header to every request.
name - the header namevalue - the header valueAdds multiple default headers to every request.
values - the headers to addSets the default request timeout.
value - the request timeoutCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.