- Enclosing interface:
- HttpClientContext
public static interface HttpClientContext.Builder
Builds the HttpClientContext.
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Build and return the context.with(HttpClient client)
Set the underlying HttpClient to use.withBaseUrl(String baseUrl)
Set the base URL to use for requests created from the context.withBodyAdapter(BodyAdapter adapter)
Set the body adapter to use to convert beans to body content and response content back to beans.withCookieHandler(CookieHandler cookieHandler)
Specify a cookie handler to use on the HttpClient.withExecutor(Executor executor)
Specify the Executor to use for asynchronous tasks.withRedirect(HttpClient.Redirect redirect)
Specify the redirect policy.withRequestTimeout(Duration requestTimeout)
Set the default request timeout.withResponseListener(ResponseListener requestListener)
Add a response listener.withVersion(HttpClient.Version version)
Specify the HTTP version.
-
Method Details
-
with
Set the underlying HttpClient to use.Used when we wish to control all options of the HttpClient.
-
withBaseUrl
Set the base URL to use for requests created from the context. -
withRequestTimeout
Set the default request timeout.- See Also:
HttpRequest.Builder.timeout(Duration)
-
withBodyAdapter
Set the body adapter to use to convert beans to body content and response content back to beans. -
withResponseListener
Add a response listener. Note thatRequestLogger
is an implementation for debug logging request/response headers and content. -
withCookieHandler
Specify a cookie handler to use on the HttpClient. This would override the default cookie handler. -
withRedirect
Specify the redirect policy. Defaults to HttpClient.Redirect.NORMAL. -
withVersion
Specify the HTTP version. Defaults to not set. -
withExecutor
Specify the Executor to use for asynchronous tasks. If not specified a default executor will be used.- See Also:
HttpClient.Builder.executor(Executor)
-
build
HttpClientContext build()Build and return the context.
-