HttpClientEngineBase

abstract class HttpClientEngineBase(engineName: String) : HttpClientEngine

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

engineName

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
}
}

Constructors

Link copied to clipboard
constructor(engineName: String)

Properties

Link copied to clipboard

Provides access to the engine's configuration via HttpClientEngineConfig.

Link copied to clipboard
Link copied to clipboard
open override val dispatcher: CoroutineDispatcher

Specifies the CoroutineDispatcher for I/O operations in the engine.

Link copied to clipboard

Specifies the set of capabilities supported by this HTTP client engine.

Functions

Link copied to clipboard
open override fun close()
Link copied to clipboard
abstract suspend fun execute(data: HttpRequestData): HttpResponseData

Executes an HTTP request and produces an HTTP response.

Link copied to clipboard
open fun install(client: HttpClient)

Installs the engine into an HttpClient.