- java.lang.Object
-
- io.helidon.webclient.WebClient.Builder
-
- All Implemented Interfaces:
Builder<WebClient>
,MediaContextBuilder<WebClient.Builder>
,ParentingMediaContextBuilder<WebClient.Builder>
,Supplier<WebClient>
- Enclosing interface:
- WebClient
public static final class WebClient.Builder extends Object implements Builder<WebClient>, ParentingMediaContextBuilder<WebClient.Builder>, MediaContextBuilder<WebClient.Builder>
Fluent API builder forWebClient
.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WebClient.Builder
addCookie(String name, String value)
Add a default cookie.WebClient.Builder
addHeader(String header, String... value)
Add a default header (such as accept).WebClient.Builder
addMediaSupport(MediaSupport mediaSupport)
Adds new instance ofMediaSupport
.WebClient.Builder
addReader(MessageBodyReader<?> reader)
Registers new reader.WebClient.Builder
addService(WebClientService service)
Register new instance ofWebClientService
.WebClient.Builder
addService(Supplier<? extends WebClientService> serviceSupplier)
Register new instance ofWebClientService
.WebClient.Builder
addStreamReader(MessageBodyStreamReader<?> streamReader)
Registers new stream reader.WebClient.Builder
addStreamWriter(MessageBodyStreamWriter<?> streamWriter)
Registers new stream writer.WebClient.Builder
addWriter(MessageBodyWriter<?> writer)
Registers new writer.WebClient.Builder
baseUri(String uri)
Sets base uri for each request.WebClient.Builder
baseUri(URI uri)
Sets base uri for each request.WebClient.Builder
baseUri(URL url)
Sets base url for each request.WebClient
build()
Build the instance from this builder.WebClient.Builder
config(Config config)
Config of this client.WebClient.Builder
connectTimeout(long amount, TimeUnit unit)
Sets new connection timeout.WebClient.Builder
context(Context context)
Sets specific context which should be used in requests.WebClient.Builder
dnsResolverType(DnsResolverType dnsResolverType)
Set which type of DNS resolver should be used.WebClient.Builder
enableAutomaticCookieStore(boolean enableAutomaticCookieStore)
Set whether cookies should be automatically saved to the store.WebClient.Builder
followRedirects(boolean follow)
Sets if redirects should be followed or not.WebClient.Builder
keepAlive(boolean keepAlive)
Set whether connection to server should be kept alive after request.WebClient.Builder
mediaContext(MediaContext mediaContext)
Sets theMediaContext
parent and overrides the existing one.WebClient.Builder
mediaTypeParserRelaxed(boolean relaxedMode)
Configure media type parsing mode for HTTPContent-Type
header.WebClient.Builder
proxy(Proxy proxy)
Sets new proxy which will used for the requests.WebClient.Builder
readTimeout(long amount, TimeUnit unit)
Sets new read timeout.WebClient.Builder
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.WebClient.Builder
tls(WebClientTls webClientTls)
Sets newWebClientTls
instance which contains ssl configuration.WebClient.Builder
userAgent(String userAgent)
Sets user agent name.WebClient.Builder
useSystemServiceLoader(boolean useServiceLoader)
Sets if Java Service loader should be used to load allWebClientServiceProvider
.WebClient.Builder
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 Detail
-
build
public WebClient build()
Description copied from interface:Builder
Build the instance from this builder.
-
addService
public WebClient.Builder addService(WebClientService service)
Register new instance ofWebClientService
.- Parameters:
service
- client service instance- Returns:
- updated builder instance
-
addService
public WebClient.Builder addService(Supplier<? extends WebClientService> serviceSupplier)
Register new instance ofWebClientService
.- Parameters:
serviceSupplier
- client service instance- Returns:
- updated builder instance
-
useSystemServiceLoader
public WebClient.Builder useSystemServiceLoader(boolean useServiceLoader)
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
public WebClient.Builder proxy(Proxy proxy)
Sets new proxy which will used for the requests.- Parameters:
proxy
- proxy instance- Returns:
- updated builder instance
-
relativeUris
public WebClient.Builder 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.- Parameters:
relativeUris
- relative URIs flag- Returns:
- updated builder instance
-
mediaContext
public WebClient.Builder mediaContext(MediaContext 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
public WebClient.Builder addMediaSupport(MediaSupport mediaSupport)
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
public WebClient.Builder addReader(MessageBodyReader<?> reader)
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
public WebClient.Builder addStreamReader(MessageBodyStreamReader<?> streamReader)
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
public WebClient.Builder addWriter(MessageBodyWriter<?> writer)
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
public WebClient.Builder addStreamWriter(MessageBodyStreamWriter<?> streamWriter)
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
public WebClient.Builder config(Config config)
Config of this client.- Parameters:
config
- client config- Returns:
- updated builder instance
-
connectTimeout
public WebClient.Builder connectTimeout(long amount, TimeUnit unit)
Sets new connection timeout.- Parameters:
amount
- amount of timeunit
- time unit- Returns:
- updated builder instance
-
readTimeout
public WebClient.Builder readTimeout(long amount, TimeUnit unit)
Sets new read timeout.- Parameters:
amount
- amount of timeunit
- time unit- Returns:
- updated builder instance
-
tls
public WebClient.Builder tls(WebClientTls webClientTls)
Sets newWebClientTls
instance which contains ssl configuration.- Parameters:
webClientTls
- tls instance- Returns:
- updated builder instance
-
context
public WebClient.Builder context(Context context)
Sets specific context which should be used in requests.- Parameters:
context
- context- Returns:
- updated builder instance
-
addCookie
public WebClient.Builder addCookie(String name, String value)
Add a default cookie.- Parameters:
name
- cookie namevalue
- cookie value- Returns:
- updated builder instance
-
addHeader
public WebClient.Builder addHeader(String header, String... value)
Add a default header (such as accept).- Parameters:
header
- header namevalue
- header values- Returns:
- updated builder instance
-
baseUri
public WebClient.Builder baseUri(URI uri)
Sets base uri for each request.- Parameters:
uri
- base uri- Returns:
- updated builder instance
-
baseUri
public WebClient.Builder baseUri(String uri)
Sets base uri for each request.- Parameters:
uri
- base uri- Returns:
- updated builder instance
-
baseUri
public WebClient.Builder baseUri(URL url)
Sets base url for each request.- Parameters:
url
- base url- Returns:
- updated builder instance
-
followRedirects
public WebClient.Builder followRedirects(boolean follow)
Sets if redirects should be followed or not.- Parameters:
follow
- follow redirects- Returns:
- updated builder instance
-
userAgent
public WebClient.Builder userAgent(String userAgent)
Sets user agent name.- Parameters:
userAgent
- user agent- Returns:
- updated builder instance
-
keepAlive
public WebClient.Builder keepAlive(boolean 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
public WebClient.Builder validateHeaders(boolean validate)
Whether to validate header names. Defaults totrue
.- Parameters:
validate
- whether to validate the header name contains only allowed characters- Returns:
- updated builder instance
-
dnsResolverType
public WebClient.Builder dnsResolverType(DnsResolverType 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
public WebClient.Builder enableAutomaticCookieStore(boolean 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
public WebClient.Builder mediaTypeParserRelaxed(boolean relaxedMode)
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
-
-