Interface RDF4JHttpClient

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
ApacheHC5RDF4JHttpClient, JdkRDF4JHttpClient

public interface RDF4JHttpClient extends AutoCloseable
HTTP-client-agnostic facade for executing HTTP requests.

Implementations wrap a concrete HTTP client library (e.g., JDK java.net.http.HttpClient or Apache HttpComponents 5). The caller is responsible for closing the returned HttpResponse.

Implementations may support transparent retry behavior. For example, a connection-pool-backed implementation may retry a request once when a stale pooled connection is detected (i.e., the server has closed the connection while it was idle), and may additionally retry on HTTP 408 (Request Timeout) responses up to a limit derived from the pool size. Redirect following (including preserving the original HTTP method across 301/302/307/308 responses) is also handled transparently by capable implementations.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes this client and releases any resources held (e.g., connection pools, threads).
    Executes the given HTTP request and returns the response.
  • Method Details

    • execute

      HttpResponse execute(HttpRequest request) throws IOException
      Executes the given HTTP request and returns the response.

      The caller must close the returned HttpResponse after use to release connection resources.

      Parameters:
      request - the request to execute.
      Returns:
      the HTTP response.
      Throws:
      IOException - if a network or I/O error occurs.
    • close

      void close()
      Closes this client and releases any resources held (e.g., connection pools, threads).
      Specified by:
      close in interface AutoCloseable