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