HttpClientEngineBase
Abstract base implementation of HttpClientEngine, providing lifecycle management for the dispatcher and coroutineContext, as well as proper handling of call contexts.
This class is designed to simplify the creation of custom HttpClientEngine implementations by handling common functionality such as:
Managing the dispatcher for I/O operations.
Setting up a structured coroutineContext with a custom name for easier debugging.
Ensuring proper resource cleanup when the engine is closed.
Developers creating custom HTTP client engines are encouraged to use this class as their parent, as it handles much of the boilerplate related to engine lifecycle and coroutine management.
Parameters
The name of the engine, used for debugging and context naming.
Example:
class MyCustomHttpClientEngine : HttpClientEngineBase("MyCustomEngine") {
override suspend fun execute(data: HttpRequestData): HttpResponseData {
// Implementation of request execution
}
}
Properties
Provides access to the engine's configuration via HttpClientEngineConfig.
Specifies the CoroutineDispatcher for I/O operations in the engine.
Specifies the set of capabilities supported by this HTTP client engine.
Functions
Executes an HTTP request and produces an HTTP response.
Installs the engine into an HttpClient.