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
public static class HttpSender.Request.Builder
extends java.lang.Object
-
Method Summary
Modifier and Type Method Description HttpSender.Request.Builderaccept(java.lang.String type)Add accept header.HttpSender.Request.BuilderacceptJson()Add header to acceptapplication/jsondata.HttpSender.Request.Buildercompress()Add a "Content-Encoding" header of "gzip" and compress the request body.HttpSender.Request.BuildercompressWhen(java.util.function.Supplier<java.lang.Boolean> when)Add a "Content-Encoding" header of "gzip" and compress the request body when the supplied condition is true.HttpSender.Request.Builderprint()HttpSender.Responsesend()HttpSender.Request.BuilderwithBasicAuthentication(java.lang.String user, java.lang.String password)If user and password are non-empty, set basic authentication on the request.HttpSender.Request.BuilderwithContent(java.lang.String type, byte[] content)Set the request body.HttpSender.Request.BuilderwithContent(java.lang.String type, java.lang.String content)Set the request body.HttpSender.Request.BuilderwithHeader(java.lang.String name, java.lang.String value)Add a header to the request.HttpSender.Request.BuilderwithJsonContent(java.lang.String content)Set the request body as JSON content type.HttpSender.Request.BuilderwithMethod(HttpSender.Method method)Set the request method.HttpSender.Request.BuilderwithPlainText(java.lang.String content)Set the request body as plain text content type.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
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 java.lang.String user, @Nullable java.lang.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
public final HttpSender.Request.Builder withContent(java.lang.String type, java.lang.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
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/jsondata.- 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:
java.io.IOException- If compression fails.
-
compressWhen
public final HttpSender.Request.Builder compressWhen(java.util.function.Supplier<java.lang.Boolean> when) throws java.io.IOExceptionAdd 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:
java.io.IOException- If compression fails.
-
print
-
send
- Throws:
java.lang.Throwable
-