Class HttpSender.Request.Builder

java.lang.Object
io.micrometer.core.ipc.http.HttpSender.Request.Builder
Enclosing class:
HttpSender.Request

public static class HttpSender.Request.Builder extends Object
  • Method Details

    • withHeader

      public final HttpSender.Request.Builder withHeader(String name, String value)
      Add a header to the request.
      Parameters:
      name - The name of the header.
      value - The value of the header.
      Returns:
      This request builder.
    • withBasicAuthentication

      public final HttpSender.Request.Builder withBasicAuthentication(@Nullable String user, @Nullable String password)
      If user and password are non-empty, set basic authentication on the request.
      Parameters:
      user - A user name, if available.
      password - A password, if available.
      Returns:
      This request builder.
    • withAuthentication

      public final HttpSender.Request.Builder withAuthentication(String type, @Nullable String credentials)
      Configures the Authorization HTTP header with the given type and credentials. The format will be:
      Authorization: <type> <credentials>
      No encoding will be performed on the credentials, so if the authentication scheme expects credentials to be encoded, encode them before passing them to this method.
      Parameters:
      type - authentication type
      credentials - authentication credentials
      Returns:
      This request builder.
      Since:
      1.8.0
    • withJsonContent

      public final HttpSender.Request.Builder withJsonContent(String content)
      Set the request body as JSON content type.
      Parameters:
      content - The request body.
      Returns:
      This request builder.
    • withPlainText

      public final HttpSender.Request.Builder withPlainText(String content)
      Set the request body as plain text content type.
      Parameters:
      content - The request body.
      Returns:
      This request builder.
    • withContent

      public final HttpSender.Request.Builder withContent(String type, String content)
      Set the request body.
      Parameters:
      type - The value of the "Content-Type" header to add.
      content - The request body.
      Returns:
      This request builder.
    • withContent

      public final HttpSender.Request.Builder withContent(String type, byte[] content)
      Set the request body.
      Parameters:
      type - The value of the "Content-Type" header to add.
      content - The request body.
      Returns:
      This request builder.
    • acceptJson

      public HttpSender.Request.Builder acceptJson()
      Add header to accept application/json data.
      Returns:
      This request builder.
    • accept

      public HttpSender.Request.Builder accept(String type)
      Add accept header.
      Parameters:
      type - The value of the "Accept" header to add.
      Returns:
      This request builder.
    • withMethod

      public final HttpSender.Request.Builder withMethod(HttpSender.Method method)
      Set the request method.
      Parameters:
      method - An HTTP method.
      Returns:
      This request builder.
    • compress

      public final HttpSender.Request.Builder compress() throws IOException
      Add a "Content-Encoding" header of "gzip" and compress the request body.
      Returns:
      This request builder.
      Throws:
      IOException - If compression fails.
    • compressWhen

      public final HttpSender.Request.Builder compressWhen(Supplier<Boolean> when) throws IOException
      Add a "Content-Encoding" header of "gzip" and compress the request body when the supplied condition is true.
      Parameters:
      when - Condition that governs when to compress the request body.
      Returns:
      This request builder.
      Throws:
      IOException - If compression fails.
    • print

      public final HttpSender.Request.Builder print()
    • send

      public HttpSender.Response send() throws Throwable
      Throws:
      Throwable