-
public interface WebClientRequestBuilderFluent API builder that is used byWebClientto create an outgoing request.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceWebClientRequestBuilder.ClientRequestRequest to a server.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description WebClientRequestBuilderaccept(MediaType... mediaTypes)Media types which are accepted in the response.default WebClientRequestBuilderaddHeader(String name, Iterable<String> values)Adds header values for a specified name.default WebClientRequestBuilderaddHeader(String name, String... values)Adds header values for a specified name.default WebClientRequestBuilderaddHeaders(Parameters parameters)Copies all of the mappings from the specifiedparametersto this response headers instance.WebClientRequestBuilderallowChunkedEncoding(boolean allowChunkedEncoding)Whether chunkedHttp.Header.TRANSFER_ENCODINGshould be added to the headers if the entity is chunked.WebClientRequestBuilderconnectTimeout(long amount, TimeUnit unit)Sets new connection timeout for this request.WebClientRequestBuildercontentType(MediaType contentType)Content type of the request.WebClientRequestBuildercontext(Context context)Explicitly configure a context to use.WebClientRequestBuilderfollowRedirects(boolean followRedirects)Sets if redirects should be followed at this request or not.WebClientRequestBuilderfragment(String fragment)Fragment of the request.WebClientRequestHeadersheaders()Get a (mutable) instance of outgoing headers.WebClientRequestBuilderheaders(Headers headers)Configure headers.WebClientRequestBuilderheaders(Function<WebClientRequestHeaders,Headers> headers)Function from parameter is executed on top of stored headers.WebClientRequestBuilderhttpVersion(Http.Version httpVersion)Sets http version.WebClientRequestBuilderkeepAlive(boolean keepAlive)Whether connection should be kept alive after request.WebClientRequestBuilderpath(HttpRequest.Path path)Path of the request.WebClientRequestBuilderpath(String path)Path of the request.WebClientRequestBuilderproperty(String propertyName, String propertyValue)Add a property to be used by aWebClientService.WebClientRequestBuilderproxy(Proxy proxy)Override client proxy configuration.WebClientRequestBuilderqueryParam(String name, String... values)Add a query parameter.WebClientRequestBuilderqueryParams(Parameters queryParams)Configure query parameters.MessageBodyReaderContextreaderContext()Returns reader context of the request builder.WebClientRequestBuilderreadTimeout(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.WebClientRequestBuilderrequestId(long requestId)Set new request id.WebClientRequestBuilderskipUriEncoding()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.WebClientRequestBuilderuri(String uri)String representation of request uri.WebClientRequestBuilderuri(URI uri)RequestURI.WebClientRequestBuilderuri(URL url)RequestURL.MessageBodyWriterContextwriterContext()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 ofURIfrom 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 suppliedHeadersinstance.- 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 specifiedparametersto this response headers instance.- Parameters:
parameters- to copy.- Returns:
- this instance of
WebClientRequestBuilder - Throws:
NullPointerException- if the specifiedparametersare 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 suppliedParametersinstance.- 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_ENCODINGshould 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 returnedCompletionStageis 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 returnedCompletionStageis 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 returnedCompletionStageis 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 returnedCompletionStageis 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 returnedCompletionStageis 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 returnedCompletionStageis 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 returnedCompletionStageis 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 returnedCompletionStageis 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 returnedCompletionStageis notified.- Parameters:
function- marshalling function- Returns:
- request completion stage
-
-