-
public interface HttpCallResponseAllows the client code to choose to execute the request asynchronously or synchronously.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description HttpCall<HttpResponse<byte[]>>asByteArray()Process as response HttpResponse<byte[]>.HttpCall<HttpResponse<Void>>asDiscarding()Process discarding response body as HttpResponse<Void>.HttpCall<HttpResponse<InputStream>>asInputStream()Process as response HttpResponse<InputStream>.HttpCall<HttpResponse<Stream<String>>>asLines()Process as response HttpResponse<Stream<String>>.HttpCall<HttpResponse<String>>asString()Process as String response body HttpResponse<String>.HttpCall<HttpResponse<Void>>asVoid()Process the response with check for 200 range status code returning as HttpResponse<Void>.<E> HttpCall<E>bean(Class<E> type)A bean response to execute async or sync.<E> HttpCall<List<E>>list(Class<E> type)Process expecting a list of beans response body (typically from json content).<E> HttpCall<Stream<E>>stream(Class<E> type)Process expecting a stream of beans response body (typically from json content).<E> HttpCall<HttpResponse<E>>withHandler(HttpResponse.BodyHandler<E> bodyHandler)Call using any givenHttpResponse.BodyHandler.
-
-
-
Method Detail
-
asVoid
HttpCall<HttpResponse<Void>> asVoid()
Process the response with check for 200 range status code returning as HttpResponse<Void>.Unlike
asDiscarding()this request will read any response content as bytes with the view that the response content can be an error message that could be read via for exampleHttpException.bean(Class).Will throw an HttpException if the status code is in the error range allowing the caller to access the error message body via for example
HttpException.bean(Class)This is intended to be used for POST, PUT, DELETE requests where the caller is only interested in the response body when an error occurs (status code not in 200 range).
HttpCall<HttpResponse<Void>> call = clientContext.request() .path("hello/world") .GET() .call().asVoid();- Returns:
- The HttpCall to allow sync or async execution
-
asDiscarding
HttpCall<HttpResponse<Void>> asDiscarding()
Process discarding response body as HttpResponse<Void>.Unlike
asVoid()this will discard any response body including any error response body. We should instead useasVoid()if we might get an error response body that we want to read via for exampleHttpException.bean(Class).HttpCall<HttpResponse<Void>> call = clientContext.request() .path("hello/world") .GET() .call().asDiscarding();- Returns:
- The HttpCall to allow sync or async execution
-
asString
HttpCall<HttpResponse<String>> asString()
Process as String response body HttpResponse<String>.HttpCall<HttpResponse<String>> call = clientContext.request() .path("hello/world") .GET() .call().asString();- Returns:
- The HttpCall to allow sync or async execution
-
asByteArray
HttpCall<HttpResponse<byte[]>> asByteArray()
Process as response HttpResponse<byte[]>.- Returns:
- The CompletableFuture of the response
-
asLines
HttpCall<HttpResponse<Stream<String>>> asLines()
Process as response HttpResponse<Stream<String>>.- Returns:
- The CompletableFuture of the response
-
asInputStream
HttpCall<HttpResponse<InputStream>> asInputStream()
Process as response HttpResponse<InputStream>.- Returns:
- The CompletableFuture of the response
-
withHandler
<E> HttpCall<HttpResponse<E>> withHandler(HttpResponse.BodyHandler<E> bodyHandler)
Call using any givenHttpResponse.BodyHandler.HttpCall<E> call = clientContext.request() .path("hello/lineStream") .GET() .call().withHandler(HttpResponse.BodyHandler<E> ...);- Parameters:
bodyHandler- The response body handler to use- Returns:
- The HttpCall to allow sync or async execution
-
bean
<E> HttpCall<E> bean(Class<E> type)
A bean response to execute async or sync.If the HTTP statusCode is not in the 2XX range a HttpException is throw which contains the HttpResponse. This is the cause in the CompletionException.
HttpCall<HelloDto> call = clientContext.request() ... .POST() .call().bean(HelloDto.class);- Parameters:
type- The bean type to convert the content to- Returns:
- The HttpCall to allow sync or async execution
-
list
<E> HttpCall<List<E>> list(Class<E> type)
Process expecting a list of beans response body (typically from json content).If the HTTP statusCode is not in the 2XX range a HttpException is throw which contains the HttpResponse. This is the cause in the CompletionException.
HttpCall<List<HelloDto>> call = clientContext.request() ... .GET() .call().list(HelloDto.class);- Parameters:
type- The bean type to convert the content to- Returns:
- The HttpCall to execute sync or async
-
stream
<E> HttpCall<Stream<E>> stream(Class<E> type)
Process expecting a stream of beans response body (typically from json content).If the HTTP statusCode is not in the 2XX range a HttpException is throw which contains the HttpResponse. This is the cause in the CompletionException.
HttpCall<Stream<HelloDto>> call = clientContext.request() ... .GET() .call().stream(HelloDto.class);- Parameters:
type- The bean type to convert the content to- Returns:
- The HttpCall to execute sync or async
-
-