Interface ClientRequest<T extends ClientRequest<T>>
- Type Parameters:
T- type of the implementation, to support fluent API
- All Known Subinterfaces:
FullClientRequest<T>, Http1ClientRequest, Http2ClientRequest, JsonRpcClientRequest
- All Known Implementing Classes:
ClientRequestBase, HttpClientRequest
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceHandle output stream. -
Method Summary
Modifier and TypeMethodDescriptiondefault TAccepted media types.default Taccept(HttpMediaType... accepted) Accepted media types.default Taddress(SocketAddress socketAddress) Socket address to use.connection(ClientConnection connection) This method is for explicit connection use by this request.default TcontentType(MediaType contentType) Sets the content type of the request.booleanWhether to follow redirects.followRedirects(boolean followRedirects) Whether to follow redirects.fragment(UriFragment fragment) Set fragment of the URI.default TSet fragment of the URI.Set an HTTP header.default Theader(HeaderName name, String... values) Set an HTTP header.default Theader(HeaderName name, List<String> values) Set an HTTP header with multiple values.headers()Get a (mutable) instance of outgoing headers.Configure headers.headers(Consumer<ClientRequestHeaders> headersConsumer) Update headers.keepAlive(boolean keepAlive) Whether to use keep alive with this request.intMaximal number of redirects to follow.maxRedirects(int maxRedirects) Max number of the followed redirects.outputStream(ClientRequest.OutputStreamHandler outputStreamConsumer) Handle output stream and submit the request.default <T> ClientResponseTyped<T> outputStream(ClientRequest.OutputStreamHandler outputStreamConsumer, Class<T> requestedType) Handle output stream and request a specific type.default TConfigure path to call.Replace a placeholder in URI with an actual value.Add a property to be used by this request.Proxy configuration for this specific request.queryParam(String name, String... values) Add query parameter.readContinueTimeout(Duration readContinueTimeout) Read 100-Continue timeout for this request.readTimeout(Duration readTimeout) Read timeout for this request.default HttpClientResponserequest()Request without an entity.default <E> ClientResponseTyped<E> request(GenericType<E> type) Request without sending an entity.default <E> ClientResponseTyped<E> Request without sending an entity.default <E> ErequestEntity(GenericType<E> type) Request entity without sending a request entity, asking for entity only.default <E> ErequestEntity(Class<E> type) Request entity without sending a request entity, asking for entity only.default TrequestTarget(HttpPrologue prologue) Replace the request path and query with the target from an HTTP prologue.Resolved URI that will be used to invoke this request.sendExpectContinue(boolean sendExpectContinue) Whether Expect 100-Continue header is sent to verify server availability before sending an entity.skipUriEncoding(boolean skip) Disable uri encoding.default TConfigure client-side TLS SNI for this request.default Tsni(Consumer<SniConfig.Builder> sni) Configure client-side TLS SNI for this request.Submit an entity.default <E> ClientResponseTyped<E> submit(Object entity, GenericType<E> requestedType) Submit an entity and request a specific type.default <E> ClientResponseTyped<E> Submit an entity and request a specific type.TLS configuration for this specific request.Configure request URI.default TConfigure URI.Configure an existing URI.
-
Method Details
-
uri
Configure URI. The string is encoded before it is resolved. To forward a server request target, userequestTarget(io.helidon.http.HttpPrologue).- Parameters:
uri- uri to resolve against base URI, or to use if absolute- Returns:
- updated request
-
path
-
tls
-
sni
-
sni
Configure client-side TLS SNI for this request.Request-level SNI overrides client-level SNI. A configured SNI host is also used as the TLS peer host for endpoint identification.
- Parameters:
sni- SNI configuration builder- Returns:
- updated request
-
proxy
-
uri
-
requestTarget
Replace the request path and query with the target from an HTTP prologue. This can be used to forward a server request using itsprologue()while retaining this client's destination scheme, host, and port. The configured base path, query, fragment, and URI template are replaced; the method, headers, and URI encoding setting are unchanged.With URI encoding enabled (the default), the raw path and query are preserved, including percent-escape spelling, matrix parameters, query ordering, repeated parameters, and an empty query delimiter. Reading query parameters does not change the target. Explicit query parameter mutations rebuild the query; changing the path leaves an unmodified query intact. The prologue's fragment is not copied.
Origin-form targets must start with
/. For absolute-form HTTP or HTTPS targets, only the raw path and query are copied; an empty path is sent as/. Asterisk-form and authority-form targets are not supported.The default implementation throws
UnsupportedOperationException. Implementations that support forwarding must override this method.- Parameters:
prologue- prologue containing the request target to forward- Returns:
- updated request
- Throws:
IllegalArgumentException- if the target form is unsupported or the raw path or query is invalidUnsupportedOperationException- if this request implementation does not support request-target forwarding
-
address
Socket address to use. This can be used to connect to a UNIX domain socket. Note that if UNIX domain socket address is configured, all other address configuration is ignored. This includes if it is configured as a base address on the client.An
InetSocketAddressupdates the logical URI host and port. AUnixDomainSocketAddressoverrides the physical transport only, so the request URI, resolved against the client base URI, still provides the logical HTTP authority. For TLS over a UNIX domain socket, the resolved URI host and port are used for SNI and endpoint identification, while the UNIX domain socket path is used only for transport.- Parameters:
socketAddress- socket address to use, this will override any other address configuration- Returns:
- updated request
-
uri
-
header
-
header
Set an HTTP header.- Parameters:
name- header namevalues- header values- Returns:
- updated request
-
header
Set an HTTP header with multiple values.- Parameters:
name- header namevalues- header values- Returns:
- updated request
-
headers
-
headers
Update headers.- Parameters:
headersConsumer- consumer of client request headers- Returns:
- updated request
-
accept
Accepted media types. Supports quality factor and wildcards.- Parameters:
accepted- media types to accept- Returns:
- updated request
-
accept
-
contentType
-
pathParam
-
queryParam
-
fragment
-
fragment
Set fragment of the URI.- Parameters:
fragment- fragment- Returns:
- updated request
-
followRedirects
Whether to follow redirects.- Parameters:
followRedirects- follow redirects- Returns:
- updated request
-
maxRedirects
Max number of the followed redirects.- Parameters:
maxRedirects- max followed redirects- Returns:
- updated request
-
followRedirects
boolean followRedirects()Whether to follow redirects.- Returns:
- follow redirects
-
maxRedirects
int maxRedirects()Maximal number of redirects to follow. This is to prevent infinite redirects.- Returns:
- max number of redirects
-
request
-
headers
ClientRequestHeaders headers()Get a (mutable) instance of outgoing headers.- Returns:
- client request headers
-
request
Request without sending an entity.- Type Parameters:
E- type of entity- Parameters:
type- type of entity- Returns:
- correctly typed response
- See Also:
-
request
Request without sending an entity.- Type Parameters:
E- type of entity- Parameters:
type- generic type of entity- Returns:
- correctly typed response
- See Also:
-
requestEntity
Request entity without sending a request entity, asking for entity only. This method will fail if the status is not in successful family.- Type Parameters:
E- type of the entity to read from the response- Parameters:
type- type of requested entity- Returns:
- correctly typed entity
- Throws:
HttpException- in case the response status is not success
-
requestEntity
Request entity without sending a request entity, asking for entity only. This method will fail if the status is not in successful family.- Type Parameters:
E- type of the entity to read from the response- Parameters:
type- generic type of requested entity- Returns:
- correctly typed entity
- Throws:
HttpException- in case the response status is not success
-
submit
Submit an entity. For HTTP/1.1 streamed entities, entity writing can run on a helper virtual thread using the current Helidon context. This includesInstanceWriter.write(java.io.OutputStream)andEntityWriterimplementations without instance-writer support. The writer can prepare request headers before its first output, and this method waits for the writer to terminate, including when an early response cancels the upload. Writers must release owned resources when output fails. Custom writers must not assume caller-thread affinity or propagation of arbitrary thread-local state.- Parameters:
entity- request entity- Returns:
- response
-
submit
Submit an entity and request a specific type. The entity-writing behavior described bysubmit(Object)also applies.- Type Parameters:
E- type of response entity- Parameters:
entity- request entityrequestedType- type of response entity- Returns:
- correctly typed response
-
submit
Submit an entity and request a specific type. The entity-writing behavior described bysubmit(Object)also applies.- Type Parameters:
E- type of response entity- Parameters:
entity- request entityrequestedType- generic type of response entity- Returns:
- correctly typed response
-
outputStream
Handle output stream and submit the request. For HTTP/1.1, request headers are sent before invoking the handler when negotiatingExpect: 100-continue. An early final response or a redirect that discards the request entity can therefore bypass the handler entirely. Configure request headers before calling this method, rather than inside the handler.A handler that writes no bytes can still trigger the HTTP/1.1 handshake when the content length is unknown. An explicit content length of zero bypasses the handshake. A method-preserving redirect received after an upload can invoke the handler again to replay the entity. Account for both bypass and replay when the handler has side effects or consumes a one-shot source.
- Parameters:
outputStreamConsumer- handler that writes and closes the request output stream- Returns:
- response
-
outputStream
default <T> ClientResponseTyped<T> outputStream(ClientRequest.OutputStreamHandler outputStreamConsumer, Class<T> requestedType) Handle output stream and request a specific type. The handler behavior described byoutputStream(OutputStreamHandler)also applies.- Type Parameters:
T- type of response entity- Parameters:
outputStreamConsumer- output stream consumer to write request entityrequestedType- type of response entity- Returns:
- correctly typed response
-
resolvedUri
-
connection
This method is for explicit connection use by this request.- Parameters:
connection- connection to use for this request- Returns:
- updated client request
-
skipUriEncoding
Disable uri encoding.- Parameters:
skip- set totrueto disable URI encoding (falseby default)- Returns:
- updated client request
-
property
-
keepAlive
Whether to use keep alive with this request.- Parameters:
keepAlive- use keep alive- Returns:
- updated client request
-
readTimeout
-
readContinueTimeout
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.- Parameters:
readContinueTimeout- read 100-Continue timeout duration- Returns:
- updated client request
- See Also:
-
sendExpectContinue
Whether Expect 100-Continue header is sent to verify server availability before sending an entity. Can be used to override the setting inherited fromHttpClientConfig.sendExpectContinue()on a per-request basis.- Parameters:
sendExpectContinue- value to override behavior for a single request- Returns:
- updated client request
-