Deprecated.
default
HttpResponse
send(
HttpRequest
request,
int responseTimeout,
boolean followRedirects,
HttpAuthentication
authentication)
throws
IOException
,
TimeoutException
Deprecated.
Sends a HttpRequest blocking the current thread until a response is available or the request times out.
Parameters:
request
- the
HttpRequest
to send
responseTimeout
- the time (in milliseconds) to wait for a response
followRedirects
- whether or not to follow redirect responses
authentication
- the optional
HttpAuthentication
to use
Returns:
the received
HttpResponse
Throws:
IOException
- if an error occurs while executing
TimeoutException
- if
responseTimeout
is exceeded
throws
IOException
,
TimeoutException
Parameters:
request
- the
HttpRequest
to send
Returns:
the received
HttpResponse
Throws:
IOException
- if an error occurs while executing
TimeoutException
- if
responseTimeout
is exceeded
HttpResponse send(HttpRequest request,
HttpRequestOptions options)
throws IOException,
TimeoutException
Sends a HttpRequest blocking the current thread until a response is available or the request times out.
Parameters:
request
- the
HttpRequest
to send
options
- the
HttpRequestOptions
to use
Returns:
the received
HttpResponse
Throws:
IOException
- if an error occurs while executing
TimeoutException
- if
responseTimeout
is exceeded
sendAsync
@Deprecated
default CompletableFuture<HttpResponse> sendAsync(HttpRequest request,
int responseTimeout,
boolean followRedirects,
HttpAuthentication authentication)
Deprecated.
Sends a HttpRequest without blocking the current thread. When a response is available or the request times out the returned
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.
Parameters:
request
- the
HttpRequest
to send
responseTimeout
- the time (in milliseconds) to wait for a response
followRedirects
- whether or not to follow redirect responses
authentication
- the optional
HttpAuthentication
to use
Returns:
a
CompletableFuture
that will complete once the
HttpResponse
is available
sendAsync
default CompletableFuture<HttpResponse> sendAsync(HttpRequest request)
Parameters:
request
- the
HttpRequest
to send
Returns:
a
CompletableFuture
that will complete once the
HttpResponse
is available
sendAsync
CompletableFuture<HttpResponse> sendAsync(HttpRequest request,
HttpRequestOptions options)
Sends a HttpRequest without blocking the current thread. When a response is available or the request times out the returned
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.
Parameters:
request
- the
HttpRequest
to send
options
- the
HttpRequestOptions
to use
Returns:
a
CompletableFuture
that will complete once the
HttpResponse
is available
openWebSocket
default CompletableFuture<WebSocket> openWebSocket(HttpRequest request,
String socketId,
WebSocketCallback callback)
Opens a new WebSocket by adding the proper upgrade header to the given
request
Parameters:
request
- a
HttpRequest
to the target WebSocket endpoint
socketId
- the id of the obtained socket
callback
- the callback that will receive the associated socket events
Returns:
a future
WebSocket
Since:
4.2.0
openWebSocket
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
Parameters:
request
- a
HttpRequest
to the target WebSocket endpoint
requestOptions
- the request options
socketId
- the id of the obtained socket
callback
- the callback that will receive the associated socket events
Returns:
a future
WebSocket
Since:
4.2.0