Interface HttpClientResponse


  • public interface HttpClientResponse
    Controls how the response is processed including potential conversion into beans.
    • Method Detail

      • read

        <T> T read​(BodyReader<T> reader)
        Returning the response using the given response reader.
        Type Parameters:
        T - The type that the content is converted to.
        Parameters:
        reader - The response reader.
        Returns:
        The response converted into the appropriate bean via the reader.
        Throws:
        HttpException - when the response has error status codes
      • bean

        <T> T bean​(Class<T> type)
        Return the response as a single bean.
        Type Parameters:
        T - The type that the content is converted to.
        Parameters:
        type - The type of the bean to convert the response content into.
        Returns:
        The bean the response is converted into.
        Throws:
        HttpException - when the response has error status codes
      • list

        <T> List<T> list​(Class<T> type)
        Return the response as a list of beans.
        Type Parameters:
        T - The type that the content is converted to.
        Parameters:
        type - The type of the bean to convert the response content into.
        Returns:
        The list of beans the response is converted into.
        Throws:
        HttpException - when the response has error status codes
      • asVoid

        HttpResponse<Void> asVoid()
        Return the response with check for 200 range status code.

        Will throw an HttpException if the status code is in the error range allowing the caller to access the error message body via 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).

        Throws:
        HttpException - when the response has error status codes
      • asDiscarding

        HttpResponse<Void> asDiscarding()
        Return the response discarding the response content.
      • asByteArray

        HttpResponse<byte[]> asByteArray()
        Return the content as byte array.