Class HttpRequest.Builder

java.lang.Object
org.eclipse.rdf4j.http.client.spi.HttpRequest.Builder
Enclosing class:
HttpRequest

public static final class HttpRequest.Builder extends Object
Builder for HttpRequest.

The HTTP method and target URI are required and must be supplied at construction time via HttpRequest.newBuilder(String, URI). Headers and body are optional and may be added incrementally before calling build().

  • Method Details

    • header

      public HttpRequest.Builder header(String name, String value)
      Appends a single header to the request. Multiple calls with the same name are additive; no deduplication is performed.
      Parameters:
      name - the header name; must not be null
      value - the header value; must not be null
      Returns:
      this builder
    • headers

      public HttpRequest.Builder headers(List<HttpHeader> hdrs)
      Appends all headers from the given list to the request. Multiple calls are additive.
      Parameters:
      hdrs - the list of HttpHeaders to add; must not be null
      Returns:
      this builder
    • headers

      public HttpRequest.Builder headers(HttpHeader... hdrs)
      Appends one or more headers to the request. Multiple calls are additive.
      Parameters:
      hdrs - the HttpHeaders to add; must not be null
      Returns:
      this builder
    • body

      Sets the request body. Pass null or omit this call for bodyless requests (e.g. GET, DELETE).
      Parameters:
      body - the HttpRequestBody to set, or null for no body
      Returns:
      this builder
    • responseTimeout

      public HttpRequest.Builder responseTimeout(Duration timeout)
      Sets the response timeout for this request. When set, the HTTP client must abort the request if no response data arrives within this duration, overriding any client-level socket timeout. Pass null to clear a previously set timeout.
      Parameters:
      timeout - the response timeout, or null for no per-request timeout
      Returns:
      this builder
    • build

      public HttpRequest build()
      Builds and returns the immutable HttpRequest.
      Returns:
      a new HttpRequest