Package io.avaje.http.client
Interface HttpClientRequest
-
public interface HttpClientRequest
Http request that is built and sent to the server.Largely wraps the standard JDK HttpRequest with additional support for converting beans to body content and converting beans from response content.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description HttpClientRequest
body(byte[] body)
Set the body content as a bytes.HttpClientRequest
body(BodyContent bodyContent)
Set encoded body content.HttpClientRequest
body(Object bean)
Set the body as a bean using the default content type.HttpClientRequest
body(Object bean, String contentType)
Set the body as a bean with the given content type using a BodyWriter.HttpClientRequest
body(String body)
Set the body content as a string.HttpClientRequest
body(HttpRequest.BodyPublisher body)
Set the body content using http BodyPublisher.HttpClientRequest
body(Path file)
Set the body content with supplied InputStream.HttpClientRequest
body(Supplier<? extends InputStream> supplier)
Set the body content with supplied InputStream.HttpClientResponse
delete()
Execute the request as a DELETE.HttpClientRequest
formParam(String name, String value)
Add a form parameter.HttpClientResponse
get()
Execute the request as a GET.HttpClientRequest
gzip(boolean gzip)
Set if body content should be gzip encoded.HttpClientRequest
header(String name, String value)
Add the header to the request.HttpClientRequest
matrixParam(String name, String value)
Add a matrix parameter to the current path segment.HttpClientRequest
param(String name, String value)
Add a query parameterHttpClientRequest
path(String path)
Add a path segment to the URL.HttpClientResponse
post()
Execute the request as a POST.HttpClientResponse
put()
Execute the request as a PUT.HttpClientRequest
requestTimeout(Duration requestTimeout)
Set the request timeout to use for this request.
-
-
-
Method Detail
-
requestTimeout
HttpClientRequest requestTimeout(Duration requestTimeout)
Set the request timeout to use for this request. When not set the default request timeout will be used.- Parameters:
requestTimeout
- The request timeout to use for this request.- Returns:
- The request being built
-
header
HttpClientRequest header(String name, String value)
Add the header to the request.- Parameters:
name
- The header namevalue
- The header value- Returns:
- The request being built
-
gzip
HttpClientRequest gzip(boolean gzip)
Set if body content should be gzip encoded.- Parameters:
gzip
- Set true to gzip encode the body content.- Returns:
- The request being built
-
path
HttpClientRequest path(String path)
Add a path segment to the URL.- Parameters:
path
- The path segment to add to the URL path.- Returns:
- The request being built
-
matrixParam
HttpClientRequest matrixParam(String name, String value)
Add a matrix parameter to the current path segment.- Parameters:
name
- The matrix parameter namevalue
- The matrix parameter value- Returns:
- The request being built
-
param
HttpClientRequest param(String name, String value)
Add a query parameter- Parameters:
name
- The name of the query parametervalue
- The value of the query parameter- Returns:
- The request being built
-
formParam
HttpClientRequest formParam(String name, String value)
Add a form parameter.- Parameters:
name
- The form parameter namevalue
- The form parameter value- Returns:
- The request being built
-
body
HttpClientRequest body(BodyContent bodyContent)
Set encoded body content.
-
body
HttpClientRequest body(Object bean, String contentType)
Set the body as a bean with the given content type using a BodyWriter.
-
body
HttpClientRequest body(Object bean)
Set the body as a bean using the default content type. The default content type will often beapplication/json; charset=utf8
.
-
body
HttpClientRequest body(String body)
Set the body content as a string.- Parameters:
body
- The body content- Returns:
- The request being built
-
body
HttpClientRequest body(byte[] body)
Set the body content as a bytes.- Parameters:
body
- The body content- Returns:
- The request being built
-
body
HttpClientRequest body(Supplier<? extends InputStream> supplier)
Set the body content with supplied InputStream.- Parameters:
supplier
- The supplier of InputStream content to send as body content- Returns:
- The request being built
-
body
HttpClientRequest body(Path file) throws FileNotFoundException
Set the body content with supplied InputStream.- Parameters:
file
- The file to send as body content- Returns:
- The request being built
- Throws:
FileNotFoundException
-
body
HttpClientRequest body(HttpRequest.BodyPublisher body)
Set the body content using http BodyPublisher.- Parameters:
body
- The body content- Returns:
- The request being built
-
get
HttpClientResponse get()
Execute the request as a GET.
-
post
HttpClientResponse post()
Execute the request as a POST.
-
put
HttpClientResponse put()
Execute the request as a PUT.
-
delete
HttpClientResponse delete()
Execute the request as a DELETE.
-
-