Class RESTClient


  • public class RESTClient
    extends HTTPBuilder
    Extension to HTTPBuilder that basically attempts to provide a slightly more REST-ful face on top of HTTPBuilder. The differences between this class and HTTPBuilder are such:
    • Access to response headers. All "request" methods on this class by default return an instance of HttpResponseDecorator, which allows for simple evaluation of the response.
    • No streaming responses. Responses are expected to either not carry data (in the case of HEAD or DELETE) or be parse-able into some sort of object. That object is accessible via HttpResponseDecorator.getData().

    By default, all request method methods will return a HttpResponseDecorator instance, which provides convenient access to response headers and the parsed response body. The response body is parsed based on content-type, identical to how HTTPBuilder's default response handler functions.

    Failed requests (i.e. responses which return a status code > 399) will by default throw a HttpResponseException. This exception may be used to retrieve additional information regarding the response as well.

    Since:
    0.5
    Author:
    Tom Nichols