public final class WebClientBuilder extends Object
URI using the builder pattern.
Use the factory methods in WebClient if you do not have many options to override.
Please refer to ClientBuilder for how decorators and HTTP headers are configured| Modifier and Type | Method and Description |
|---|---|
B |
addHttpHeader(CharSequence name,
Object value)
Adds the specified HTTP header.
|
B |
addHttpHeaders(Iterable<? extends Map.Entry<? extends CharSequence,?>> httpHeaders)
Adds the specified HTTP headers.
|
WebClient |
build()
Returns a newly-created web client based on the properties of this builder.
|
B |
contentPreview(int length)
Sets the
ContentPreviewerFactory for creating a ContentPreviewer which produces the
preview with the maximum length limit for a request and a response. |
B |
contentPreview(int length,
Charset defaultCharset)
Sets the
ContentPreviewerFactory for creating a ContentPreviewer which produces the
preview with the maximum length limit for a request and a response. |
B |
contentPreviewerFactory(ContentPreviewerFactory factory)
Sets the
ContentPreviewerFactory for a request and a response. |
B |
decorator(DecoratingHttpClientFunction decorator)
Adds the specified HTTP-level
decorator. |
B |
decorator(Function<? super HttpClient,? extends HttpClient> decorator)
Adds the specified HTTP-level
decorator. |
B |
defaultMaxResponseLength(long maxResponseLength)
Deprecated.
|
B |
defaultResponseTimeout(Duration responseTimeout)
Deprecated.
|
B |
defaultResponseTimeoutMillis(long responseTimeoutMillis)
Deprecated.
|
B |
defaultWriteTimeout(Duration writeTimeout)
Deprecated.
|
B |
defaultWriteTimeoutMillis(long writeTimeoutMillis)
Deprecated.
|
WebClientBuilder |
factory(ClientFactory factory)
Sets the
ClientFactory of the client. |
B |
maxResponseLength(long maxResponseLength)
Sets the maximum allowed length of a server response in bytes.
|
<T> B |
option(ClientOption<T> option,
T value)
Adds the specified
ClientOption and its value. |
<T> B |
option(ClientOptionValue<T> optionValue)
Adds the specified
ClientOptionValue. |
B |
options(ClientOptions options)
Adds the specified
ClientOptions. |
B |
options(ClientOptionValue<?>... options)
Adds the specified
ClientOptionValues. |
B |
options(Iterable<ClientOptionValue<?>> options)
Adds the specified
ClientOptionValues. |
WebClientBuilder |
path(String path)
Sets the
path of the client. |
B |
requestContentPreviewerFactory(ContentPreviewerFactory factory)
Sets the
ContentPreviewerFactory for a request. |
B |
requestIdGenerator(Supplier<RequestId> requestIdGenerator)
|
B |
responseContentPreviewerFactory(ContentPreviewerFactory factory)
Sets the
ContentPreviewerFactory for a response. |
B |
responseTimeout(Duration responseTimeout)
Sets the timeout of a response.
|
B |
responseTimeoutMillis(long responseTimeoutMillis)
Sets the timeout of a response in milliseconds.
|
WebClientBuilder |
rpcDecorator(DecoratingRpcClientFunction decorator)
Adds the specified RPC-level
decorator. |
WebClientBuilder |
rpcDecorator(Function<? super RpcClient,? extends RpcClient> decorator)
Adds the specified RPC-level
decorator. |
B |
setHttpHeader(CharSequence name,
Object value)
Sets the specified HTTP header.
|
B |
setHttpHeaders(Iterable<? extends Map.Entry<? extends CharSequence,?>> httpHeaders)
Sets the specified HTTP headers.
|
B |
writeTimeout(Duration writeTimeout)
Sets the timeout of a socket write attempt.
|
B |
writeTimeoutMillis(long writeTimeoutMillis)
Sets the timeout of a socket write attempt in milliseconds.
|
public WebClientBuilder factory(ClientFactory factory)
ClientFactory of the client. The default is ClientFactory.ofDefault().public WebClientBuilder path(String path)
path of the client.public WebClient build()
IllegalArgumentException - if the scheme of the uri specified in
WebClient.builder(String) or
WebClient.builder(URI) is not an HTTP schemepublic WebClientBuilder rpcDecorator(Function<? super RpcClient,? extends RpcClient> decorator)
decorator.public WebClientBuilder rpcDecorator(DecoratingRpcClientFunction decorator)
decorator.decorator - the DecoratingRpcClientFunction that intercepts an invocationpublic B options(ClientOptions options)
ClientOptions.public B options(ClientOptionValue<?>... options)
ClientOptionValues.public B options(Iterable<ClientOptionValue<?>> options)
ClientOptionValues.public <T> B option(ClientOption<T> option, T value)
ClientOption and its value.public <T> B option(ClientOptionValue<T> optionValue)
ClientOptionValue.@Deprecated public B defaultWriteTimeout(Duration writeTimeout)
writeTimeout(Duration).writeTimeout - the timeout. 0 disables the timeout.@Deprecated public B defaultWriteTimeoutMillis(long writeTimeoutMillis)
writeTimeoutMillis(long).writeTimeoutMillis - the timeout in milliseconds. 0 disables the timeout.public B writeTimeout(Duration writeTimeout)
writeTimeout - the timeout. 0 disables the timeout.public B writeTimeoutMillis(long writeTimeoutMillis)
writeTimeoutMillis - the timeout in milliseconds. 0 disables the timeout.@Deprecated public B defaultResponseTimeout(Duration responseTimeout)
responseTimeout(Duration).responseTimeout - the timeout. 0 disables the timeout.@Deprecated public B defaultResponseTimeoutMillis(long responseTimeoutMillis)
responseTimeoutMillis(long).responseTimeoutMillis - the timeout in milliseconds. 0 disables the timeout.public B responseTimeout(Duration responseTimeout)
responseTimeout - the timeout. 0 disables the timeout.public B responseTimeoutMillis(long responseTimeoutMillis)
responseTimeoutMillis - the timeout in milliseconds. 0 disables the timeout.@Deprecated public B defaultMaxResponseLength(long maxResponseLength)
maxResponseLength(long).maxResponseLength - the maximum length in bytes. 0 disables the limit.public B maxResponseLength(long maxResponseLength)
maxResponseLength - the maximum length in bytes. 0 disables the limit.public B requestContentPreviewerFactory(ContentPreviewerFactory factory)
ContentPreviewerFactory for a request.public B responseContentPreviewerFactory(ContentPreviewerFactory factory)
ContentPreviewerFactory for a response.public B contentPreviewerFactory(ContentPreviewerFactory factory)
ContentPreviewerFactory for a request and a response.public B contentPreview(int length,
Charset defaultCharset)
ContentPreviewerFactory for creating a ContentPreviewer which produces the
preview with the maximum length limit for a request and a response.
The previewer is enabled only if the content type of a request/response meets
any of the following conditions:
text/* or application/x-www-form-urlencoded"xml" or "json""+xml" or "+json"length - the maximum length of the previewdefaultCharset - the default charset used when a charset is not specified in the
"content-type" headerpublic B contentPreview(int length)
ContentPreviewerFactory for creating a ContentPreviewer which produces the
preview with the maximum length limit for a request and a response.
The previewer is enabled only if the content type of a request/response meets
any of the following conditions:
text/* or application/x-www-form-urlencoded"xml" or "json""+xml" or "+json"length - the maximum length of the preview.public B decorator(Function<? super HttpClient,? extends HttpClient> decorator)
decorator.decorator - the Function that transforms an HttpClient to anotherpublic B decorator(DecoratingHttpClientFunction decorator)
decorator.decorator - the DecoratingHttpClientFunction that intercepts an invocationpublic B addHttpHeader(CharSequence name, Object value)
public B addHttpHeaders(Iterable<? extends Map.Entry<? extends CharSequence,?>> httpHeaders)
public B setHttpHeader(CharSequence name, Object value)
public B setHttpHeaders(Iterable<? extends Map.Entry<? extends CharSequence,?>> httpHeaders)
Copyright © 2020 LeanCloud. All rights reserved.