-
public interface WebClientRequestBuilder
Fluent API builder that is used byWebClient
to create an outgoing request.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
WebClientRequestBuilder.ClientRequest
Request to a server.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description WebClientRequestBuilder
accept(MediaType... mediaTypes)
Media types which are accepted in the response.default WebClientRequestBuilder
addHeader(String name, Iterable<String> values)
Adds header values for a specified name.default WebClientRequestBuilder
addHeader(String name, String... values)
Adds header values for a specified name.default WebClientRequestBuilder
addHeaders(Parameters parameters)
Copies all of the mappings from the specifiedparameters
to this response headers instance.WebClientRequestBuilder
allowChunkedEncoding(boolean allowChunkedEncoding)
Whether chunkedHttp.Header.TRANSFER_ENCODING
should be added to the headers if the entity is chunked.WebClientRequestBuilder
connectTimeout(long amount, TimeUnit unit)
Sets new connection timeout for this request.WebClientRequestBuilder
contentType(MediaType contentType)
Content type of the request.WebClientRequestBuilder
context(Context context)
Explicitly configure a context to use.WebClientRequestBuilder
followRedirects(boolean followRedirects)
Sets if redirects should be followed at this request or not.WebClientRequestBuilder
fragment(String fragment)
Fragment of the request.WebClientRequestHeaders
headers()
Get a (mutable) instance of outgoing headers.WebClientRequestBuilder
headers(Headers headers)
Configure headers.WebClientRequestBuilder
headers(Function<WebClientRequestHeaders,Headers> headers)
Function from parameter is executed on top of stored headers.WebClientRequestBuilder
httpVersion(Http.Version httpVersion)
Sets http version.WebClientRequestBuilder
keepAlive(boolean keepAlive)
Whether connection should be kept alive after request.WebClientRequestBuilder
path(HttpRequest.Path path)
Path of the request.WebClientRequestBuilder
path(String path)
Path of the request.WebClientRequestBuilder
property(String propertyName, String propertyValue)
Add a property to be used by aWebClientService
.WebClientRequestBuilder
proxy(Proxy proxy)
Override client proxy configuration.WebClientRequestBuilder
queryParam(String name, String... values)
Add a query parameter.WebClientRequestBuilder
queryParams(Parameters queryParams)
Configure query parameters.MessageBodyReaderContext
readerContext()
Returns reader context of the request builder.WebClientRequestBuilder
readTimeout(long amount, TimeUnit unit)
Sets new read timeout for this request.Single<WebClientResponse>
request()
Performs prepared request without expecting to receive any specific type.<T> Single<T>
request(GenericType<T> responseType)
Performs prepared request and transforms response to requested type.<T> Single<T>
request(Class<T> responseType)
Performs prepared request and transforms response to requested type.WebClientRequestBuilder
requestId(long requestId)
Set new request id.WebClientRequestBuilder
skipUriEncoding()
Disables final uri encoding.Single<WebClientResponse>
submit()
Performs prepared request.Single<WebClientResponse>
submit(Object requestEntity)
Performs prepared request and submitting request entity.<T> Single<T>
submit(Object requestEntity, Class<T> responseType)
Performs prepared request and submitting request entity.Single<WebClientResponse>
submit(Flow.Publisher<DataChunk> requestEntity)
Performs prepared request and submitting request entity usingFlow.Publisher
.<T> Single<T>
submit(Flow.Publisher<DataChunk> requestEntity, Class<T> responseType)
Performs prepared request and submitting request entity usingFlow.Publisher
.Single<WebClientResponse>
submit(Function<MessageBodyWriterContext,Flow.Publisher<DataChunk>> function)
Performs prepared request and submitting request entity using a marshalling function.WebClientRequestBuilder
uri(String uri)
String representation of request uri.WebClientRequestBuilder
uri(URI uri)
RequestURI
.WebClientRequestBuilder
uri(URL url)
RequestURL
.MessageBodyWriterContext
writerContext()
Returns writer context of the request builder.
-
-
-
Method Detail
-
uri
WebClientRequestBuilder uri(String uri)
String representation of request uri. Replaces baseUri defined in client builder.- Parameters:
uri
- request uri- Returns:
- updated builder instance
-
uri
WebClientRequestBuilder uri(URL url)
RequestURL
. Replaces baseUri defined in client builder.- Parameters:
url
- request url- Returns:
- updated builder instance
-
uri
WebClientRequestBuilder uri(URI uri)
RequestURI
. Replaces baseUri defined in client builder.- Parameters:
uri
- request uri- Returns:
- updated builder instance
-
skipUriEncoding
WebClientRequestBuilder skipUriEncoding()
Disables final uri encoding. This setting skips all parts ofURI
from encoding.- Returns:
- updated builder instance
-
followRedirects
WebClientRequestBuilder followRedirects(boolean followRedirects)
Sets if redirects should be followed at this request or not.- Parameters:
followRedirects
- follow redirects- Returns:
- updated builder instance
-
property
WebClientRequestBuilder property(String propertyName, String propertyValue)
Add a property to be used by aWebClientService
.- Parameters:
propertyName
- property namepropertyValue
- property value- Returns:
- updated builder instance
-
context
WebClientRequestBuilder context(Context context)
Explicitly configure a context to use. This method is not needed when running within a scope of a Helidon server, such as Web Server, gRPC Server, MicroProfile Server, or when processing a Helidon message consumer.- Parameters:
context
- context to be used by the outbound request, to look for security context, parent tracing span and similar- Returns:
- updated builder instance
-
headers
WebClientRequestHeaders headers()
Get a (mutable) instance of outgoing headers.- Returns:
- client request headers
-
queryParam
WebClientRequestBuilder queryParam(String name, String... values)
Add a query parameter. Appends these query parameters to the query parameters defined in the request uri.- Parameters:
name
- query namevalues
- query value- Returns:
- updated builder instance
-
proxy
WebClientRequestBuilder proxy(Proxy proxy)
Override client proxy configuration.- Parameters:
proxy
- request proxy- Returns:
- updated builder instance
-
headers
WebClientRequestBuilder headers(Headers headers)
Configure headers. Copy all headers from suppliedHeaders
instance.- Parameters:
headers
- to copy- Returns:
- updated builder instance
-
headers
WebClientRequestBuilder headers(Function<WebClientRequestHeaders,Headers> headers)
Function from parameter is executed on top of stored headers. This approach is here to allow as to add any header via specialized method while using builder pattern.- Parameters:
headers
- function which adds headers- Returns:
- updated builder instance
-
addHeader
default WebClientRequestBuilder addHeader(String name, String... values)
Adds header values for a specified name.- Parameters:
name
- header namevalues
- header values- Returns:
- this instance of
WebClientRequestBuilder
- Throws:
NullPointerException
- if the specified name is null.- See Also:
headers()
,Parameters.add(String, String...)
,header names constants
-
addHeader
default WebClientRequestBuilder addHeader(String name, Iterable<String> values)
Adds header values for a specified name.- Parameters:
name
- header namevalues
- header values- Returns:
- this instance of
WebClientRequestBuilder
- Throws:
NullPointerException
- if the specified name is null.- See Also:
headers()
,Parameters.add(String, Iterable)
,header names constants
-
addHeaders
default WebClientRequestBuilder addHeaders(Parameters parameters)
Copies all of the mappings from the specifiedparameters
to this response headers instance.- Parameters:
parameters
- to copy.- Returns:
- this instance of
WebClientRequestBuilder
- Throws:
NullPointerException
- if the specifiedparameters
are null.- See Also:
headers()
,Parameters.addAll(Parameters)
-
queryParams
WebClientRequestBuilder queryParams(Parameters queryParams)
Configure query parameters. Appends these query parameters to the query parameters defined in the request uri. Copy all query parameters from suppliedParameters
instance.- Parameters:
queryParams
- to copy- Returns:
- updated builder instance
-
readerContext
MessageBodyReaderContext readerContext()
Returns reader context of the request builder.- Returns:
- request reader context
-
writerContext
MessageBodyWriterContext writerContext()
Returns writer context of the request builder.- Returns:
- request writer context
-
httpVersion
WebClientRequestBuilder httpVersion(Http.Version httpVersion)
Sets http version.- Parameters:
httpVersion
- http version- Returns:
- updated builder instance
-
connectTimeout
WebClientRequestBuilder connectTimeout(long amount, TimeUnit unit)
Sets new connection timeout for this request.- Parameters:
amount
- amount of timeunit
- time unit- Returns:
- updated builder instance
-
readTimeout
WebClientRequestBuilder readTimeout(long amount, TimeUnit unit)
Sets new read timeout for this request.- Parameters:
amount
- amount of timeunit
- time unit- Returns:
- updated builder instance
-
fragment
WebClientRequestBuilder fragment(String fragment)
Fragment of the request. Replaces fragment defined in the request uri.- Parameters:
fragment
- request fragment- Returns:
- updated builder instance
-
path
WebClientRequestBuilder path(HttpRequest.Path path)
Path of the request. Appends this path to the path defined in the request uri.- Parameters:
path
- path- Returns:
- updated builder instance
-
path
WebClientRequestBuilder path(String path)
Path of the request. Appends this path to the path defined in the request uri.- Parameters:
path
- path- Returns:
- updated builder instance
-
contentType
WebClientRequestBuilder contentType(MediaType contentType)
Content type of the request.- Parameters:
contentType
- content type- Returns:
- updated builder instance
-
accept
WebClientRequestBuilder accept(MediaType... mediaTypes)
Media types which are accepted in the response.- Parameters:
mediaTypes
- media types- Returns:
- updated builder instance
-
keepAlive
WebClientRequestBuilder keepAlive(boolean keepAlive)
Whether connection should be kept alive after request.- Parameters:
keepAlive
- keep alive- Returns:
- updated builder instance
-
requestId
WebClientRequestBuilder requestId(long requestId)
Set new request id. This id is used in logging messages.- Parameters:
requestId
- new request id- Returns:
- updated builder instance
-
allowChunkedEncoding
WebClientRequestBuilder allowChunkedEncoding(boolean allowChunkedEncoding)
Whether chunkedHttp.Header.TRANSFER_ENCODING
should be added to the headers if the entity is chunked.- Parameters:
allowChunkedEncoding
- allow chunked encoding to be added- Returns:
- updated builder instance
-
request
<T> Single<T> request(Class<T> responseType)
Performs prepared request and transforms response to requested type. When transformation is done the returnedCompletionStage
is notified.- Type Parameters:
T
- response type- Parameters:
responseType
- requested response type- Returns:
- request completion stage
-
request
<T> Single<T> request(GenericType<T> responseType)
Performs prepared request and transforms response to requested type. When transformation is done the returnedCompletionStage
is notified.- Type Parameters:
T
- response type- Parameters:
responseType
- requested response type- Returns:
- request completion stage
-
request
Single<WebClientResponse> request()
Performs prepared request without expecting to receive any specific type. Response is not converted and returnedCompletionStage
is notified.- Returns:
- request completion stage
-
submit
Single<WebClientResponse> submit()
Performs prepared request. When response is received, it is not converted to any other specific type and returnedCompletionStage
is notified.- Returns:
- request completion stage
-
submit
<T> Single<T> submit(Flow.Publisher<DataChunk> requestEntity, Class<T> responseType)
Performs prepared request and submitting request entity usingFlow.Publisher
. When response is received, it is converted to response type and returnedCompletionStage
is notified.- Type Parameters:
T
- response type- Parameters:
requestEntity
- request entityresponseType
- requested response type- Returns:
- request completion stage
-
submit
<T> Single<T> submit(Object requestEntity, Class<T> responseType)
Performs prepared request and submitting request entity. When response is received, it is converted to response type and returnedCompletionStage
is notified.- Type Parameters:
T
- response type- Parameters:
requestEntity
- request entityresponseType
- requested response type- Returns:
- request completion stage
-
submit
Single<WebClientResponse> submit(Flow.Publisher<DataChunk> requestEntity)
Performs prepared request and submitting request entity usingFlow.Publisher
. When response is received, it is not converted to any other specific type and returnedCompletionStage
is notified.- Parameters:
requestEntity
- request entity- Returns:
- request completion stage
-
submit
Single<WebClientResponse> submit(Object requestEntity)
Performs prepared request and submitting request entity. When response is received, it is not converted to any other specific type and returnedCompletionStage
is notified.- Parameters:
requestEntity
- request entity- Returns:
- request completion stage
-
submit
Single<WebClientResponse> submit(Function<MessageBodyWriterContext,Flow.Publisher<DataChunk>> function)
Performs prepared request and submitting request entity using a marshalling function. When response is received, it is not converted to any other specific type and returnedCompletionStage
is notified.- Parameters:
function
- marshalling function- Returns:
- request completion stage
-
-