Interface HttpClient
-
- All Known Implementing Classes:
JdkHttpClient
public interface HttpClientA simple interface for sending HTTP requests.This interface is designed to abstract the implementation of HTTP clients, allowing for sending requests and receiving responses. It provides methods for sending a request either with or without a body.
- Since:
- 4.0.0
- Author:
- Dmytro Nosan
- See Also:
JdkHttpClient
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classHttpClient.BodySuppliersA utility class for creating different kinds of body suppliers.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default HttpResponsesend(HttpRequest httpRequest)Sends an HTTP request.HttpResponsesend(HttpRequest httpRequest, IOSupplier<? extends InputStream> bodySupplier)Sends an HTTP request with an optional body.
-
-
-
Method Detail
-
send
default HttpResponse send(HttpRequest httpRequest) throws IOException
Sends an HTTP request.- Parameters:
httpRequest- The request to be sent- Returns:
- The HTTP response
- Throws:
IOException- If an I/O error occurs
-
send
HttpResponse send(HttpRequest httpRequest, IOSupplier<? extends InputStream> bodySupplier) throws IOException
Sends an HTTP request with an optional body.- Parameters:
httpRequest- The request to be sentbodySupplier- A supplier for the request body, ornullif no body is needed- Returns:
- The HTTP response
- Throws:
IOException- If an I/O error occurs- See Also:
HttpClient.BodySuppliers
-
-