Interface HttpCallResponse


public interface HttpCallResponse
Allows the client code to choose to execute the request asynchronously or synchronously.
  • Method Details

    • 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 example HttpException.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 =
           client.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 use asVoid() if we might get an error response body that we want to read via for example HttpException.bean(Class).

      
      
         HttpCall<HttpResponse<Void>> call =
           client.request()
             .path("hello/world")
             .GET()
             .call().asDiscarding();
      
       
      Returns:
      The HttpCall to allow sync or async execution
    • asString

      Process as String response body HttpResponse<String>.
      
      
         HttpCall<HttpResponse<String>> call =
           client.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

      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
    • handler

      <E> HttpCall<HttpResponse<E>> handler(HttpResponse.BodyHandler<E> bodyHandler)
      Call using any given HttpResponse.BodyHandler.
      
      
          HttpCall<E> call = client.request()
             .path("hello/lineStream")
             .GET()
             .call().handler(HttpResponse.BodyHandler<E> ...);
       
      Parameters:
      bodyHandler - The response body handler to use
      Returns:
      The HttpCall to allow sync or async execution
    • as

      <E> HttpCall<HttpResponse<E>> as(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<HttpResponse<HelloDto>> call =
          client.request()
             ...
             .POST()
             .call().as(HelloDto.class);
      
       
      Parameters:
      type - The bean type to convert the content to
      Returns:
      The HttpCall to allow sync or async execution
    • as

      <E> HttpCall<HttpResponse<E>> as(Type type)
      Same as as(Class) but takes a generic parameterized type.
    • asList

      <E> HttpCall<HttpResponse<List<E>>> asList(Class<E> type)
      Same as as(Class) but returns HttpResponse<List<E>>.
    • asList

      <E> HttpCall<HttpResponse<List<E>>> asList(Type type)
      Same as as(Class) but returns HttpResponse<List<E>>.
    • asStream

      <E> HttpCall<HttpResponse<Stream<E>>> asStream(Class<E> type)
      Same as as(Class) but returns HttpResponse<Stream<E>>.
    • asStream

      <E> HttpCall<HttpResponse<Stream<E>>> asStream(Type type)
      Same as as(Class) but returns HttpResponse<Stream<E>>.
    • 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 =
          client.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 =
          client.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 =
          client.request()
             ...
             .GET()
             .call().stream(HelloDto.class);
       
      Parameters:
      type - The bean type to convert the content to
      Returns:
      The HttpCall to execute sync or async
    • bean

      <E> HttpCall<E> bean(Type type)
      A bean response to execute async or sync.
      Parameters:
      type - The parameterized type to convert the content to
      Returns:
      The HttpCall to allow sync or async execution
    • list

      <E> HttpCall<List<E>> list(Type type)
      Process expecting a list of beans response body (typically from json content).
      Parameters:
      type - The parameterized type to convert the content to
      Returns:
      The HttpCall to execute sync or async
    • stream

      <E> HttpCall<Stream<E>> stream(Type type)
      Process expecting a stream of beans response body (typically from json content).
      Parameters:
      type - The parameterized type to convert the content to
      Returns:
      The HttpCall to execute sync or async