Class JavaClient

java.lang.Object
kong.unirest.core.java.JavaClient
All Implemented Interfaces:
Client

public class JavaClient extends Object implements Client
  • Constructor Details

    • JavaClient

      public JavaClient(Config config)
    • JavaClient

      public JavaClient(Config config, HttpClient client)
  • Method Details

    • getClient

      public HttpClient getClient()
      Specified by:
      getClient in interface Client
      Returns:
      the underlying client if this instance is wrapping another library.
    • request

      public <T> HttpResponse<T> request(HttpRequest request, Function<RawResponse, HttpResponse<T>> transformer, Class<?> resultType)
      Description copied from interface: Client
      Make a request
      Specified by:
      request in interface Client
      Type Parameters:
      T - The type of the body
      Parameters:
      request - the prepared request object
      transformer - the function to transform the response
      resultType - the final body result type. This is a hint to downstream systems to make up for type erasure.
      Returns:
      a HttpResponse with a transformed body
    • request

      public <T> CompletableFuture<HttpResponse<T>> request(HttpRequest request, Function<RawResponse, HttpResponse<T>> transformer, CompletableFuture<HttpResponse<T>> callback, Class<?> resultType)
      Description copied from interface: Client
      Make a Async request
      Specified by:
      request in interface Client
      Type Parameters:
      T - The type of the body
      Parameters:
      request - the prepared request object
      transformer - the function to transform the response
      callback - the CompletableFuture that will handle the eventual response
      resultType - the final body result type. This is a hint to downstream systems to make up for type erasure.
      Returns:
      a CompletableFuture of a response
    • websocket

      public WebSocketResponse websocket(WebSocketRequest request, WebSocket.Listener listener)
      Description copied from interface: Client
      Create a websocket connection
      Specified by:
      websocket in interface Client
      Parameters:
      request - the connection
      listener - (in the voice of Cicero) the listener
      Returns:
      a WebSocketResponse
    • sse

      public CompletableFuture<Void> sse(SseRequest request, SseHandler handler)
      Description copied from interface: Client
      execute a SSE Event connection. Because these events are a stream they are processed async and take a handler you can use to consume the events
      Specified by:
      sse in interface Client
      Parameters:
      request - the request details
      handler - the SseHandler
      Returns:
      a CompletableFuture
    • sse

      public Stream<Event> sse(SseRequest request)
      Specified by:
      sse in interface Client
    • transformBody

      protected <T> HttpResponse<T> transformBody(Function<RawResponse, HttpResponse<T>> transformer, RawResponse rr)