public static class HttpSender.Request.Builder extends Object
Modifier and Type | Method and Description |
---|---|
HttpSender.Request.Builder |
accept(String type)
Add accept header.
|
HttpSender.Request.Builder |
acceptJson()
Add header to accept
application/json data. |
HttpSender.Request.Builder |
compress()
Add a "Content-Encoding" header of "gzip" and compress the request body.
|
HttpSender.Request.Builder |
compressWhen(Supplier<Boolean> when)
Add a "Content-Encoding" header of "gzip" and compress the request body when the supplied
condition is true.
|
HttpSender.Request.Builder |
print() |
HttpSender.Response |
send() |
HttpSender.Request.Builder |
withBasicAuthentication(String user,
String password)
If user and password are non-empty, set basic authentication on the request.
|
HttpSender.Request.Builder |
withContent(String type,
byte[] content)
Set the request body.
|
HttpSender.Request.Builder |
withContent(String type,
String content)
Set the request body.
|
HttpSender.Request.Builder |
withHeader(String name,
String value)
Add a header to the request.
|
HttpSender.Request.Builder |
withJsonContent(String content)
Set the request body as JSON.
|
HttpSender.Request.Builder |
withMethod(HttpSender.Method method)
Set the request method.
|
HttpSender.Request.Builder |
withPlainText(String content)
Set the request body as JSON.
|
public final HttpSender.Request.Builder withHeader(String name, String value)
name
- The name of the header.value
- The value of the header.public final HttpSender.Request.Builder withBasicAuthentication(@Nullable String user, @Nullable String password)
user
- A user name, if available.password
- A password, if available.public final HttpSender.Request.Builder withJsonContent(String content)
content
- The request body.public final HttpSender.Request.Builder withPlainText(String content)
content
- The request body.public final HttpSender.Request.Builder withContent(String type, String content)
type
- The value of the "Content-Type" header to add.content
- The request body.public final HttpSender.Request.Builder withContent(String type, byte[] content)
type
- The value of the "Content-Type" header to add.content
- The request body.public HttpSender.Request.Builder acceptJson()
application/json
data.public HttpSender.Request.Builder accept(String type)
type
- The value of the "Accept" header to add.public final HttpSender.Request.Builder withMethod(HttpSender.Method method)
method
- An HTTP method.public final HttpSender.Request.Builder compress() throws IOException
IOException
- If compression fails.public final HttpSender.Request.Builder compressWhen(Supplier<Boolean> when) throws IOException
when
- Condition that governs when to compress the request body.IOException
- If compression fails.public final HttpSender.Request.Builder print()
public HttpSender.Response send() throws Throwable
Throwable
Copyright © 2019. All rights reserved.