Module io.helidon.webclient.api
Package io.helidon.webclient.api
Class ClientRequestBase<T extends ClientRequest<T>,R extends HttpClientResponse>
java.lang.Object
io.helidon.webclient.api.ClientRequestBase<T,R>
- Type Parameters:
T
- type of the requestR
- type of the response
- All Implemented Interfaces:
ClientRequest<T>
,FullClientRequest<T>
- Direct Known Subclasses:
HttpClientRequest
public abstract class ClientRequestBase<T extends ClientRequest<T>,R extends HttpClientResponse>
extends Object
implements FullClientRequest<T>
Abstract base implementation of an HTTP client. Provides helpful methods to handle cookies, client services etc.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.helidon.webclient.api.ClientRequest
ClientRequest.OutputStreamHandler
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
ClientRequestBase
(HttpClientConfig clientConfig, WebClientCookieManager cookieManager, String protocolId, Method method, ClientUri clientUri, Map<String, String> properties) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Append additional headers before sending the request.protected HttpClientConfig
Associated client configuration.Possible explicit connection to use (such as when using a proxy).connection
(ClientConnection connection) This method is for explicit connection use by this request.protected abstract R
doOutputStream
(ClientRequest.OutputStreamHandler outputStreamHandler) protected abstract R
boolean
Whether to follow redirects.followRedirects
(boolean followRedirects) Whether to follow redirects.fragment
(UriFragment fragment) Set fragment of the URI.Set an HTTP header.headers()
Get a (mutable) instance of outgoing headers.Configure headers.headers
(Consumer<ClientRequestHeaders> headersConsumer) Update headers.protected WebClientServiceResponse
invokeServices
(WebClientService.Chain httpCallChain, CompletableFuture<WebClientServiceRequest> whenSent, CompletableFuture<WebClientServiceResponse> whenComplete, ClientUri usedUri) Invoke configured client services.boolean
Whether to use keep-alive connection (if relevant for the used HTTP version).keepAlive
(boolean keepAlive) Whether to use keep alive with this request.int
Maximal number of redirects to follow.maxRedirects
(int maxRedirects) Max number of the followed redirects.protected MediaContext
Media context configured for this request.method()
HTTP method to be invoked.final R
outputStream
(ClientRequest.OutputStreamHandler outputStreamConsumer) Handle output stream and submit the request.Configure path to call.Replace a placeholder in URI with an actual value.Replace a placeholder in URI with an actual value.Properties configured by a user or by other components.Add a property to be used by this request.proxy()
Proxy configuration (may be no-proxy).Proxy configuration for this specific request.queryParam
(String name, String... values) Add query parameter.Read 100-Continue timeout.readContinueTimeout
(Duration readContinueTimeout) Read 100-Continue timeout for this request.Read timeout.readTimeout
(Duration readTimeout) Read timeout for this request.request()
Request without an entity.Request ID.Resolved URI that will be used to invoke this request.protected ClientUri
resolveUri
(ClientUri toResolve) Resolve possible templated URI definition against the providedClientUri
, extracting possible query information into the provided writable query.boolean
Whether to skip URI encoding.skipUriEncoding
(boolean skip) Disable uri encoding.final R
Submit an entity.tls()
TLS configuration (may be disabled - e.g.TLS configuration for this specific request.uri()
URI of this request.Configure request URI.Configure URI.Configure URI.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.helidon.webclient.api.ClientRequest
accept, accept, contentType, fragment, header, header, outputStream, request, requestEntity, submit
-
Field Details
-
USER_AGENT_HEADER
Helidon user agent request header. -
PROXY_CONNECTION
Proxy connection header.
-
-
Constructor Details
-
ClientRequestBase
protected ClientRequestBase(HttpClientConfig clientConfig, WebClientCookieManager cookieManager, String protocolId, Method method, ClientUri clientUri, Map<String, String> properties)
-
-
Method Details
-
tls
Description copied from interface:ClientRequest
TLS configuration for this specific request.- Specified by:
tls
in interfaceClientRequest<T extends ClientRequest<T>>
- Parameters:
tls
- tls configuration- Returns:
- updated request
-
uri
Description copied from interface:ClientRequest
Configure URI.- Specified by:
uri
in interfaceClientRequest<T extends ClientRequest<T>>
- Parameters:
uri
- uri to resolve against base URI, or to use if absolute- Returns:
- updated request
-
uri
Description copied from interface:ClientRequest
Configure request URI. This always replaces the existing URI (even if base URI is configured).- Specified by:
uri
in interfaceClientRequest<T extends ClientRequest<T>>
- Parameters:
uri
- uri to resolve against base URI, or to use if absolute- Returns:
- updated request
-
path
Description copied from interface:ClientRequest
Configure path to call.- Specified by:
path
in interfaceClientRequest<T extends ClientRequest<T>>
- Parameters:
uri
- path- Returns:
- updated request
-
uri
Description copied from interface:ClientRequest
Configure URI.- Specified by:
uri
in interfaceClientRequest<T extends ClientRequest<T>>
- Parameters:
uri
- uri to resolve against base URI, or to use if absolute- Returns:
- updated request
-
resolvedUri
Description copied from interface:ClientRequest
Resolved URI that will be used to invoke this request.- Specified by:
resolvedUri
in interfaceClientRequest<T extends ClientRequest<T>>
- Returns:
- URI to invoke
-
headers
Description copied from interface:ClientRequest
Get a (mutable) instance of outgoing headers.- Specified by:
headers
in interfaceClientRequest<T extends ClientRequest<T>>
- Returns:
- client request headers
-
header
Description copied from interface:ClientRequest
Set an HTTP header.- Specified by:
header
in interfaceClientRequest<T extends ClientRequest<T>>
- Parameters:
header
- header to set- Returns:
- updated request
-
headers
Description copied from interface:ClientRequest
Configure headers. Copy all headers from suppliedHeaders
instance.- Specified by:
headers
in interfaceClientRequest<T extends ClientRequest<T>>
- Parameters:
headers
- to copy- Returns:
- updated request
-
headers
Description copied from interface:ClientRequest
Update headers.- Specified by:
headers
in interfaceClientRequest<T extends ClientRequest<T>>
- Parameters:
headersConsumer
- consumer of client request headers- Returns:
- updated request
-
fragment
Description copied from interface:ClientRequest
Set fragment of the URI.- Specified by:
fragment
in interfaceClientRequest<T extends ClientRequest<T>>
- Parameters:
fragment
- fragment- Returns:
- updated request
-
skipUriEncoding
Description copied from interface:ClientRequest
Disable uri encoding.- Specified by:
skipUriEncoding
in interfaceClientRequest<T extends ClientRequest<T>>
- Parameters:
skip
- set totrue
to disable URI encoding (false
by default)- Returns:
- updated client request
-
queryParam
Description copied from interface:ClientRequest
Add query parameter.- Specified by:
queryParam
in interfaceClientRequest<T extends ClientRequest<T>>
- Parameters:
name
- name of parametervalues
- value(s) of parameter- Returns:
- updated request
-
property
Description copied from interface:ClientRequest
Add a property to be used by this request.- Specified by:
property
in interfaceClientRequest<T extends ClientRequest<T>>
- Parameters:
propertyName
- property namepropertyValue
- property value- Returns:
- updated builder instance
-
pathParam
Description copied from interface:ClientRequest
Replace a placeholder in URI with an actual value.- Specified by:
pathParam
in interfaceClientRequest<T extends ClientRequest<T>>
- Parameters:
name
- name of parametervalue
- value of parameter- Returns:
- updated request
-
followRedirects
Description copied from interface:ClientRequest
Whether to follow redirects.- Specified by:
followRedirects
in interfaceClientRequest<T extends ClientRequest<T>>
- Parameters:
followRedirects
- follow redirects- Returns:
- updated request
-
maxRedirects
Description copied from interface:ClientRequest
Max number of the followed redirects.- Specified by:
maxRedirects
in interfaceClientRequest<T extends ClientRequest<T>>
- Parameters:
maxRedirects
- max followed redirects- Returns:
- updated request
-
connection
Description copied from interface:ClientRequest
This method is for explicit connection use by this request.- Specified by:
connection
in interfaceClientRequest<T extends ClientRequest<T>>
- Parameters:
connection
- connection to use for this request- Returns:
- updated client request
-
keepAlive
Description copied from interface:ClientRequest
Whether to use keep alive with this request.- Specified by:
keepAlive
in interfaceClientRequest<T extends ClientRequest<T>>
- Parameters:
keepAlive
- use keep alive- Returns:
- updated client request
-
readTimeout
Description copied from interface:ClientRequest
Read timeout for this request.- Specified by:
readTimeout
in interfaceClientRequest<T extends ClientRequest<T>>
- Parameters:
readTimeout
- response read timeout- Returns:
- updated client request
-
readContinueTimeout
Description copied from interface:ClientRequest
Read 100-Continue timeout for this request. This read timeout is used when 100-Continue is sent by the client, before it sends an entity.- Specified by:
readContinueTimeout
in interfaceClientRequest<T extends ClientRequest<T>>
- Parameters:
readContinueTimeout
- read 100-Continue timeout duration- Returns:
- updated client request
- See Also:
-
proxy
Description copied from interface:ClientRequest
Proxy configuration for this specific request.- Specified by:
proxy
in interfaceClientRequest<T extends ClientRequest<T>>
- Parameters:
proxy
- proxy configuration- Returns:
- updated request
-
request
Description copied from interface:ClientRequest
Request without an entity.- Specified by:
request
in interfaceClientRequest<T extends ClientRequest<T>>
- Returns:
- response
-
submit
Description copied from interface:ClientRequest
Submit an entity.- Specified by:
submit
in interfaceClientRequest<T extends ClientRequest<T>>
- Parameters:
entity
- request entity- Returns:
- response
-
outputStream
Description copied from interface:ClientRequest
Handle output stream and submit the request.- Specified by:
outputStream
in interfaceClientRequest<T extends ClientRequest<T>>
- Parameters:
outputStreamConsumer
- output stream to write request entity- Returns:
- response
-
additionalHeaders
protected void additionalHeaders()Append additional headers before sending the request. -
method
HTTP method to be invoked.- Specified by:
method
in interfaceFullClientRequest<T extends ClientRequest<T>>
- Returns:
- HTTP method
-
properties
Properties configured by a user or by other components.- Specified by:
properties
in interfaceFullClientRequest<T extends ClientRequest<T>>
- Returns:
- properties
-
followRedirects
public boolean followRedirects()Description copied from interface:ClientRequest
Whether to follow redirects.- Specified by:
followRedirects
in interfaceClientRequest<T extends ClientRequest<T>>
- Returns:
- follow redirects
-
maxRedirects
public int maxRedirects()Description copied from interface:ClientRequest
Maximal number of redirects to follow. This is to prevent infinite redirects.- Specified by:
maxRedirects
in interfaceClientRequest<T extends ClientRequest<T>>
- Returns:
- max number of redirects
-
tls
Description copied from interface:FullClientRequest
TLS configuration (may be disabled - e.g. use plaintext).- Specified by:
tls
in interfaceFullClientRequest<T extends ClientRequest<T>>
- Returns:
- TLS configuration
-
proxy
Description copied from interface:FullClientRequest
Proxy configuration (may be no-proxy).- Specified by:
proxy
in interfaceFullClientRequest<T extends ClientRequest<T>>
- Returns:
- proxy
-
connection
Description copied from interface:FullClientRequest
Possible explicit connection to use (such as when using a proxy).- Specified by:
connection
in interfaceFullClientRequest<T extends ClientRequest<T>>
- Returns:
- client connection if explicitly defined
-
pathParams
Description copied from interface:FullClientRequest
Replace a placeholder in URI with an actual value.- Specified by:
pathParams
in interfaceFullClientRequest<T extends ClientRequest<T>>
- Returns:
- a map of path parameters
-
uri
Description copied from interface:FullClientRequest
URI of this request.- Specified by:
uri
in interfaceFullClientRequest<T extends ClientRequest<T>>
- Returns:
- client URI
-
requestId
Description copied from interface:FullClientRequest
Request ID.- Specified by:
requestId
in interfaceFullClientRequest<T extends ClientRequest<T>>
- Returns:
- id of this request
-
readTimeout
Description copied from interface:FullClientRequest
Read timeout.- Specified by:
readTimeout
in interfaceFullClientRequest<T extends ClientRequest<T>>
- Returns:
- read timeout of this request
-
readContinueTimeout
Description copied from interface:FullClientRequest
Read 100-Continue timeout.- Specified by:
readContinueTimeout
in interfaceFullClientRequest<T extends ClientRequest<T>>
- Returns:
- read 100-Continue timeout of this request
-
keepAlive
public boolean keepAlive()Description copied from interface:FullClientRequest
Whether to use keep-alive connection (if relevant for the used HTTP version).- Specified by:
keepAlive
in interfaceFullClientRequest<T extends ClientRequest<T>>
- Returns:
- whether to use keep alive
-
skipUriEncoding
public boolean skipUriEncoding()Description copied from interface:FullClientRequest
Whether to skip URI encoding.- Specified by:
skipUriEncoding
in interfaceFullClientRequest<T extends ClientRequest<T>>
- Returns:
- whether to skip encoding
-
doSubmit
-
doOutputStream
-
invokeServices
protected WebClientServiceResponse invokeServices(WebClientService.Chain httpCallChain, CompletableFuture<WebClientServiceRequest> whenSent, CompletableFuture<WebClientServiceResponse> whenComplete, ClientUri usedUri) Invoke configured client services.- Parameters:
httpCallChain
- invocation of the HTTP request (the actual network call)whenSent
- completable future to be completed when the request is sent over the networkwhenComplete
- completable future to be completed when the request/response interaction finishesusedUri
- URI configured on the request, combined with the base URI of the client- Returns:
- web client service response
-
clientConfig
Associated client configuration.- Returns:
- client config
-
mediaContext
Media context configured for this request.- Returns:
- media context
-
resolveUri
Resolve possible templated URI definition against the providedClientUri
, extracting possible query information into the provided writable query.- Parameters:
toResolve
- client uri to update from the template- Returns:
- updated client uri
-