Package io.micrometer.core.ipc.http
Class HttpSender.Request.Builder
java.lang.Object
io.micrometer.core.ipc.http.HttpSender.Request.Builder
- Enclosing class:
- HttpSender.Request
-
Method Summary
Modifier and TypeMethodDescriptionAdd accept header.Add header to acceptapplication/json
data.compress()
Add a "Content-Encoding" header of "gzip" and compress the request body.compressWhen(Supplier<Boolean> when)
Add a "Content-Encoding" header of "gzip" and compress the request body when the supplied condition is true.print()
send()
withBasicAuthentication(String user, String password)
If user and password are non-empty, set basic authentication on the request.withContent(String type, byte[] content)
Set the request body.withContent(String type, String content)
Set the request body.withHeader(String name, String value)
Add a header to the request.withJsonContent(String content)
Set the request body as JSON content type.withMethod(HttpSender.Method method)
Set the request method.withPlainText(String content)
Set the request body as plain text content type.
-
Method Details
-
withHeader
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.
-
withJsonContent
Set the request body as JSON content type.- Parameters:
content
- The request body.- Returns:
- This request builder.
-
withPlainText
Set the request body as plain text content type.- Parameters:
content
- The request body.- Returns:
- This request builder.
-
withContent
Set the request body.- Parameters:
type
- The value of the "Content-Type" header to add.content
- The request body.- Returns:
- This request builder.
-
withContent
Set the request body.- Parameters:
type
- The value of the "Content-Type" header to add.content
- The request body.- Returns:
- This request builder.
-
acceptJson
Add header to acceptapplication/json
data.- Returns:
- This request builder.
-
accept
Add accept header.- Parameters:
type
- The value of the "Accept" header to add.- Returns:
- This request builder.
-
withMethod
Set the request method.- Parameters:
method
- An HTTP method.- Returns:
- This request builder.
-
compress
Add a "Content-Encoding" header of "gzip" and compress the request body.- Returns:
- This request builder.
- Throws:
IOException
- If compression fails.
-
compressWhen
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
-
send
- Throws:
Throwable
-