Class DefaultHttpClientEngine

java.lang.Object
io.mochaapi.client.internal.DefaultHttpClientEngine
All Implemented Interfaces:
HttpClientEngine

public class DefaultHttpClientEngine extends Object implements HttpClientEngine
Default implementation of HttpClientEngine using Java 11+ HttpClient. Handles HTTP requests with automatic JSON serialization, timeouts, and error handling.
Since:
1.0.0 Enhanced with configurable timeouts and improved error handling
  • Constructor Details

    • DefaultHttpClientEngine

      public DefaultHttpClientEngine()
      Creates a new DefaultHttpClientEngine with default configuration. Uses 30-second timeouts for all operations.
    • DefaultHttpClientEngine

      public DefaultHttpClientEngine(Duration connectTimeout, Duration readTimeout, Duration writeTimeout)
      Creates a new DefaultHttpClientEngine with custom timeout configuration.
      Parameters:
      connectTimeout - the connection timeout
      readTimeout - the read timeout
      writeTimeout - the write timeout
    • DefaultHttpClientEngine

      public DefaultHttpClientEngine(HttpClient httpClient, JsonMapper jsonMapper)
      Creates a new DefaultHttpClientEngine with custom HttpClient and JsonMapper.
      Parameters:
      httpClient - the custom HttpClient instance
      jsonMapper - the custom JsonMapper instance
  • Method Details

    • execute

      public ApiResponse execute(ApiRequest request)
      Description copied from interface: HttpClientEngine
      Executes an HTTP request and returns the response.
      Specified by:
      execute in interface HttpClientEngine
      Parameters:
      request - the configured request
      Returns:
      ApiResponse containing the result