Interface RestCallHandler

All Known Implementing Classes:

public interface RestCallHandler
Interface that allows you to override the handling of HTTP requests.

Providing this implementation is the equivalent to overriding the RestClient.execute(HttpHost,HttpRequest,HttpContext).
This can also be accomplished by providing your own connection manager or subclassing RestClient, but this provides a simpler way of handling the requests yourself.

The constructor on the implementation class can optionally take in any of the following parameters:

The BasicRestCallHandler shows an example of a simple pass-through handler. Note that you must handle the case where HttpHost is null.

public class BasicRestCallHandler implements RestCallHandler { private final RestClient client; public BasicRestCallHandler(RestClient client) { this.client = client; } @Override public HttpResponse run(HttpHost target, HttpRequest request, HttpContext context) throws IOException { if (target == null) return client.execute((HttpUriRequest)request, context); return client.execute(target, request, context); } }

See Also:
  • Method Details

    • run

      Execute the specified request.

      Subclasses can override this method to provide specialized handling.

      target - The target host for the request.
      Implementations may accept null if they can still determine a route, for example to a default target or by inspecting the request.
      request - The request to execute. Must be an instance of HttpUriRequest if the target is null.
      context - The context to use for the execution, or null to use the default context.
      The response to the request.
      This is always a final response, never an intermediate response with an 1xx status code.
      Whether redirects or authentication challenges will be returned or handled automatically depends on the implementation and configuration of this client.
      IOException - In case of a problem or the connection was aborted.
      ClientProtocolException - In case of an http protocol error.