@Experimental public interface HttpClientProvider
HttpClient implementations. Implementations of this interface
can be registered via Java's ServiceLoader mechanism to provide alternative HTTP client implementations.
To register a custom provider, create a file named META-INF/services/io.lettuce.core.http.HttpClientProvider
containing the fully qualified class name of your implementation.
The HTTP client uses a shared infrastructure (event loops) and supports per-connection configuration. Connections are established with specific SSL options and timeouts that apply to all requests made through that connection.
Example implementation:
public class MyHttpClientProvider implements HttpClientProvider {
@Override
public HttpClient createHttpClient() {
return new MyHttpClient();
}
@Override
public boolean isAvailable() {
try {
Class.forName("com.example.MyHttpClient");
return true;
} catch (ClassNotFoundException e) {
return false;
}
}
}
HttpClient,
HttpClientResources| Modifier and Type | Method and Description |
|---|---|
HttpClient |
createHttpClient()
Creates a new
HttpClient instance. |
default int |
getPriority()
Returns the priority of this provider.
|
boolean |
isAvailable()
Returns
true if this provider is available and can create HTTP clients. |
HttpClient createHttpClient()
HttpClient instance. The client uses shared infrastructure and supports per-connection
configuration.HttpClient instance.boolean isAvailable()
true if this provider is available and can create HTTP clients. This method should check if all required
dependencies are present on the classpath.true if this provider is available.default int getPriority()
Copyright © 2026 lettuce.io. All rights reserved.