Interface HttpCallResponse


  • public interface HttpCallResponse
    Allows the client code to choose to execute the request asynchronously or synchronously.
    • 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 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 =
             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 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 =
             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
      • 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 given HttpResponse.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