Class JavaNetHttpRequester

  • All Implemented Interfaces:
    HttpRequester

    public final class JavaNetHttpRequester
    extends Object
    implements HttpRequester
    Implementation of HttpRequester for the built-in Java.net 11 HTTP Client
    • Constructor Detail

      • JavaNetHttpRequester

        public JavaNetHttpRequester​(@Nonnull
                                    ConfigBase config)
        Build the reusable instance of httpClient with the given configuration.
        Parameters:
        config - HTTPClient agnostic Algolia's configuration.
      • JavaNetHttpRequester

        public JavaNetHttpRequester​(@Nonnull
                                    ConfigBase config,
                                    HttpClient.Builder builder)
        Build the reusable instance of httpClient with the given configuration.
        Parameters:
        config - HTTPClient agnostic Algolia's configuration
        builder - Builder for HTTP Clients
    • Method Detail

      • performRequestAsync

        public CompletableFuture<HttpResponse> performRequestAsync​(@Nonnull
                                                                   HttpRequest request)
        Sends the http request asynchronously to the API If the request is time out it creates a new response object with timeout set to true Otherwise it throws a run time exception
        Specified by:
        performRequestAsync in interface HttpRequester
        Parameters:
        request - the request to send
        Throws:
        AlgoliaRuntimeException - When an error occurred processing the request on the server side
      • close

        public void close()
        Nothing to do here. Java.net HTTP Client is not closeable.
        Specified by:
        close in interface HttpRequester