Interface HttpRequest.Builder

Enclosing interface:
HttpRequest

public static interface HttpRequest.Builder
Builder of HTTP requests.
  • Method Details

    • body

    • expectContinue

      HttpRequest.Builder expectContinue(boolean enable)
    • header

      HttpRequest.Builder header(String headerName, String value)
      Set a header value.

      Any other values previously set are overwritten.

      Parameters:
      headerName - name of the header
      value - value of the header
      Returns:
      this builder
    • header

      HttpRequest.Builder header(String... headers)
    • header

      HttpRequest.Builder header(String headerName, Set<String> values)
      Set several values for a header.

      Any other values previously set are overwritten.

      Parameters:
      headerName - name of the header
      values - values of the header
      Returns:
      this builder
    • accept

      HttpRequest.Builder accept(String acceptHeader)
      Set the Accept header.
      Parameters:
      acceptHeader - value for the Accept header
      Returns:
      this builder
      See Also:
    • contentType

      HttpRequest.Builder contentType(String contentType)
      Set the Content-Type header.

      When calling this method, ensure to set the body to be sent.

      Parameters:
      contentType - content type of the request body.
      Returns:
      this builder
    • timeout

      HttpRequest.Builder timeout(Duration duration)
      Set a timeout for this request.
      Parameters:
      duration - maximum duration to wait for a response
      Returns:
      this builder
    • socketTimeout

      HttpRequest.Builder socketTimeout(Duration duration)
      Set a timeout for receiving data after connection has been established for this request. Normally, timeouts are configured per Http client, however their might be some exceptional use-cases for which setting a timeout for a specific request is desired.
      Parameters:
      duration - maximum duration to wait for data
      Returns:
      this builder
      Since:
      5.3.0
    • followRedirects

      HttpRequest.Builder followRedirects(HttpClient.Redirect policy)
      Parameters:
      policy - the redirect policy for this request
      Returns:
      this builder
    • withoutAlarms

      HttpRequest.Builder withoutAlarms()
      Don't raise or clear any alarms for this request.
      Returns:
      this builder
      Since:
      5.2.0
    • withoutAlarm

      HttpRequest.Builder withoutAlarm(AlarmType alarmType)
      Don't raise or clear any alarms of the given AlarmType for this request. Calling this method multiple times has a cumulative effect.
      Parameters:
      alarmType - the type of alarm not to raise or clear
      Returns:
      this builder
      Since:
      5.3.0
    • method

      HttpRequest method(String method)
      Send a request to the configured endpoint using the given HTTP method.
      Parameters:
      method - HTTP method
      Returns:
      http response
    • get

      Send a GET request to the configured endpoint.
      Returns:
      http response
    • post

      HttpRequest post()
      Send a POST request to the configured endpoint.
      Returns:
      http response
    • put

      Send a PUT request to the configured endpoint.
      Returns:
      http response