Class HttpRequester

java.lang.Object
com.algolia.internal.HttpRequester
All Implemented Interfaces:
Requester, Closeable, AutoCloseable

public final class HttpRequester extends Object implements Requester
HttpRequester is responsible for making HTTP requests using the OkHttp client. It provides a mechanism for request serialization and deserialization using a given JsonSerializer.
  • Method Details

    • execute

      public <T> T execute(HttpRequest httpRequest, RequestOptions requestOptions, Class<?> returnType, Class<?> innerType)
      Description copied from interface: Requester
      Executes an HTTP request and deserializes the response into a specified Java type.
      Specified by:
      execute in interface Requester
      Type Parameters:
      T - The type of the returned object.
      Parameters:
      httpRequest - The HTTP request to be executed.
      requestOptions - Optional request options.
      returnType - The class of the response.
      innerType - The inner class type if the response is a container type.
      Returns:
      The deserialized response.
    • execute

      public <T> T execute(HttpRequest httpRequest, RequestOptions requestOptions, com.fasterxml.jackson.core.type.TypeReference<?> returnType)
      Description copied from interface: Requester
      Executes an HTTP request and deserializes the response into a specified type reference.
      Specified by:
      execute in interface Requester
      Type Parameters:
      T - The type of the returned object.
      Parameters:
      httpRequest - The HTTP request to be executed.
      requestOptions - Optional request options.
      returnType - The type reference of the response.
      Returns:
      The deserialized response.
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException