@NoImplement
public interface HttpClient
| Modifier and Type | Method and Description |
|---|---|
default CompletableFuture<WebSocket> |
openWebSocket(HttpRequest request,
HttpRequestOptions requestOptions,
String socketId,
WebSocketCallback callback)
Opens a new WebSocket by adding the proper upgrade header to the given
request |
HttpResponse |
send(HttpRequest request,
int responseTimeout,
boolean followRedirects,
HttpAuthentication authentication)
Sends a HttpRequest blocking the current thread until a response is available or the request times out.
|
CompletableFuture<HttpResponse> |
sendAsync(HttpRequest request,
int responseTimeout,
boolean followRedirects,
HttpAuthentication authentication)
Sends a HttpRequest without blocking the current thread.
|
void |
start()
Fully configures the client, leaving it ready to use.
|
void |
stop()
Disables the client.
|
void start()
void stop()
HttpResponse send(HttpRequest request, int responseTimeout, boolean followRedirects, HttpAuthentication authentication) throws IOException, TimeoutException
request - the HttpRequest to sendresponseTimeout - the time (in milliseconds) to wait for a responsefollowRedirects - whether or not to follow redirect responsesauthentication - the optional HttpAuthentication to useHttpResponseIOException - if an error occurs while executingTimeoutException - if responseTimeout is exceededCompletableFuture<HttpResponse> sendAsync(HttpRequest request, int responseTimeout, boolean followRedirects, HttpAuthentication authentication)
CompletableFuture will be completed. Be aware that the response body processing will be deferred so that the response can
be processed even when a large body is still being received. If the full response is needed right away then the provided
HttpResponse must be read in a different thread so that it does not block the HttpClient threads handling the
response. It's therefore recommended to use CompletableFuture.get() or any of the async methods available, such as
CompletableFuture.whenCompleteAsync(BiConsumer, Executor), to handle the response is those scenarios since they guarantee
executing on a different thread.request - the HttpRequest to sendresponseTimeout - the time (in milliseconds) to wait for a responsefollowRedirects - whether or not to follow redirect responsesauthentication - the optional HttpAuthentication to useCompletableFuture that will complete once the HttpResponse is available@Experimental default CompletableFuture<WebSocket> openWebSocket(HttpRequest request, HttpRequestOptions requestOptions, String socketId, WebSocketCallback callback)
requestrequest - a HttpRequest to the target WebSocket endpointrequestOptions - the request optionssocketId - the id of the obtained socketcallback - the callback that will receive the associated socket eventsWebSocketCopyright © 2003–2019 MuleSoft, Inc.. All rights reserved.