HttpClientEngineFactory

A factory for creating instances of HttpClientEngine with a specific configuration type T.

This interface defines how to produce custom HTTP client engines that implement HttpClientEngine. Each engine is initialized with a configuration object of type T, which extends HttpClientEngineConfig.

Factories implementing this interface are commonly passed to the io.ktor.client.HttpClient constructor to specify the underlying engine that will handle HTTP requests. This allows users to seamlessly plug in different engines based on their requirements, such as for performance, platform compatibility, or protocol support.

Parameters

T

The type of HttpClientEngineConfig used to configure the engine.

Example:

object MyCustomEngine: HttpClientEngineFactory<MyEngineConfig> {
// ...
}

val client = HttpClient(MyCustomEngine) {
engine {
timeout = 10_000
customSetting = "example"
}
}

Inheritors

Functions

Link copied to clipboard

Creates a new HttpClientEngineFactory based on this one with further configurations from the nested block.

Link copied to clipboard
abstract fun create(block: T.() -> Unit = {}): HttpClientEngine

Creates or retrieves an instance of HttpClientEngine, applying optional configurations.