java.lang.Object
io.helidon.webclient.WebClient.Builder
- All Implemented Interfaces:
Builder<WebClient.Builder,
,WebClient> MediaContextBuilder<WebClient.Builder>
,ParentingMediaContextBuilder<WebClient.Builder>
,Supplier<WebClient>
- Enclosing interface:
- WebClient
public static final class WebClient.Builder
extends Object
implements Builder<WebClient.Builder,WebClient>, ParentingMediaContextBuilder<WebClient.Builder>, MediaContextBuilder<WebClient.Builder>
Fluent API builder for
WebClient
.-
Method Summary
Modifier and TypeMethodDescriptionAdd a default cookie.Add a default header (such as accept).addMediaSupport
(MediaSupport mediaSupport) Adds new instance ofMediaSupport
.addReader
(MessageBodyReader<?> reader) Registers new reader.addService
(WebClientService service) Register new instance ofWebClientService
.addService
(Supplier<? extends WebClientService> serviceSupplier) Register new instance ofWebClientService
.addStreamReader
(MessageBodyStreamReader<?> streamReader) Registers new stream reader.addStreamWriter
(MessageBodyStreamWriter<?> streamWriter) Registers new stream writer.addWriter
(MessageBodyWriter<?> writer) Registers new writer.Sets base uri for each request.Sets base uri for each request.Sets base url for each request.build()
Build the instance from this builder.Config of this client.connectTimeout
(long amount, TimeUnit unit) Sets new connection timeout.Sets specific context which should be used in requests.dnsResolverType
(DnsResolverType dnsResolverType) Set which type of DNS resolver should be used.enableAutomaticCookieStore
(boolean enableAutomaticCookieStore) Set whether cookies should be automatically saved to the store.followRedirects
(boolean follow) Sets if redirects should be followed or not.keepAlive
(boolean keepAlive) Set whether connection to server should be kept alive after request.mediaContext
(MediaContext mediaContext) Sets theMediaContext
parent and overrides the existing one.mediaTypeParserRelaxed
(boolean relaxedMode) Configure media type parsing mode for HTTPContent-Type
header.Sets new proxy which will used for the requests.readTimeout
(long amount, TimeUnit unit) Sets new read timeout.relativeUris
(boolean relativeUris) Can be set totrue
to force the use of relative URIs in all requests, regardless of the presence or absence of proxies or no-proxy lists.tls
(WebClientTls webClientTls) Sets newWebClientTls
instance which contains ssl configuration.Sets user agent name.useSystemServiceLoader
(boolean useServiceLoader) Sets if Java Service loader should be used to load allWebClientServiceProvider
.validateHeaders
(boolean validate) Whether to validate header names.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.helidon.media.common.MediaContextBuilder
addMediaSupport, addReader, addStreamReader, addStreamWriter, addWriter
Methods inherited from interface io.helidon.media.common.ParentingMediaContextBuilder
mediaContext
-
Method Details
-
build
Description copied from interface:Builder
Build the instance from this builder.- Specified by:
build
in interfaceBuilder<WebClient.Builder,
WebClient> - Returns:
- instance of the built type
-
addService
Register new instance ofWebClientService
.- Parameters:
service
- client service instance- Returns:
- updated builder instance
-
addService
Register new instance ofWebClientService
.- Parameters:
serviceSupplier
- client service instance- Returns:
- updated builder instance
-
useSystemServiceLoader
Sets if Java Service loader should be used to load allWebClientServiceProvider
.- Parameters:
useServiceLoader
- whether to use the Java Service loader- Returns:
- updated builder instance
-
proxy
Sets new proxy which will used for the requests.- Parameters:
proxy
- proxy instance- Returns:
- updated builder instance
-
relativeUris
Can be set totrue
to force the use of relative URIs in all requests, regardless of the presence or absence of proxies or no-proxy lists.- Parameters:
relativeUris
- relative URIs flag- Returns:
- updated builder instance
-
mediaContext
Description copied from interface:ParentingMediaContextBuilder
Sets theMediaContext
parent and overrides the existing one. This method discards all previously registered readers and writers via builder.- Specified by:
mediaContext
in interfaceParentingMediaContextBuilder<WebClient.Builder>
- Parameters:
mediaContext
- media context- Returns:
- updated instance of the builder
-
addMediaSupport
Description copied from interface:MediaContextBuilder
Adds new instance ofMediaSupport
.- Specified by:
addMediaSupport
in interfaceMediaContextBuilder<WebClient.Builder>
- Parameters:
mediaSupport
- media support- Returns:
- updated instance of the builder
-
addReader
Description copied from interface:MediaContextBuilder
Registers new reader.- Specified by:
addReader
in interfaceMediaContextBuilder<WebClient.Builder>
- Parameters:
reader
- reader- Returns:
- updated instance of the builder
-
addStreamReader
Description copied from interface:MediaContextBuilder
Registers new stream reader.- Specified by:
addStreamReader
in interfaceMediaContextBuilder<WebClient.Builder>
- Parameters:
streamReader
- stream reader- Returns:
- updated instance of the builder
-
addWriter
Description copied from interface:MediaContextBuilder
Registers new writer.- Specified by:
addWriter
in interfaceMediaContextBuilder<WebClient.Builder>
- Parameters:
writer
- writer- Returns:
- updated instance of the builder
-
addStreamWriter
Description copied from interface:MediaContextBuilder
Registers new stream writer.- Specified by:
addStreamWriter
in interfaceMediaContextBuilder<WebClient.Builder>
- Parameters:
streamWriter
- stream writer- Returns:
- updated instance of the builder
-
config
Config of this client.- Parameters:
config
- client config- Returns:
- updated builder instance
-
connectTimeout
Sets new connection timeout.- Parameters:
amount
- amount of timeunit
- time unit- Returns:
- updated builder instance
-
readTimeout
Sets new read timeout.- Parameters:
amount
- amount of timeunit
- time unit- Returns:
- updated builder instance
-
tls
Sets newWebClientTls
instance which contains ssl configuration.- Parameters:
webClientTls
- tls instance- Returns:
- updated builder instance
-
context
Sets specific context which should be used in requests.- Parameters:
context
- context- Returns:
- updated builder instance
-
addCookie
Add a default cookie.- Parameters:
name
- cookie namevalue
- cookie value- Returns:
- updated builder instance
-
addHeader
Add a default header (such as accept).- Parameters:
header
- header namevalue
- header values- Returns:
- updated builder instance
-
baseUri
Sets base uri for each request.- Parameters:
uri
- base uri- Returns:
- updated builder instance
-
baseUri
Sets base uri for each request.- Parameters:
uri
- base uri- Returns:
- updated builder instance
-
baseUri
Sets base url for each request.- Parameters:
url
- base url- Returns:
- updated builder instance
-
followRedirects
Sets if redirects should be followed or not.- Parameters:
follow
- follow redirects- Returns:
- updated builder instance
-
userAgent
Sets user agent name.- Parameters:
userAgent
- user agent- Returns:
- updated builder instance
-
keepAlive
Set whether connection to server should be kept alive after request. This also sets headerHttp.Header.CONNECTION
tokeep-alive
.- Parameters:
keepAlive
- keep connection alive- Returns:
- updated builder instance
-
validateHeaders
Whether to validate header names. Defaults totrue
.- Parameters:
validate
- whether to validate the header name contains only allowed characters- Returns:
- updated builder instance
-
dnsResolverType
Set which type of DNS resolver should be used.- Parameters:
dnsResolverType
- type of the DNS resolver to be used- Returns:
- updated builder instance
-
enableAutomaticCookieStore
Set whether cookies should be automatically saved to the store.- Parameters:
enableAutomaticCookieStore
- whether to save cookies, default is false- Returns:
- updated builder instance
-
mediaTypeParserRelaxed
Configure media type parsing mode for HTTPContent-Type
header. Media type parsing in relaxed mode accepts incomplete Content-Type values like"text"
, which are accepted as corresponding complete value, e.g."text/plain"
. Parsing in strict mode (default) expect exactContent-Type
matching.- Parameters:
relaxedMode
- value oftrue
sets relaxed media type parsing mode, value offalse
sets strict media type parsing mode- Returns:
- updated builder instance
-