Repository: ktorio/ktor
File: ktor-client/ktor-client-core/common/src/io/ktor/client/engine/HttpClientEngine.kt (Kotlin)

Code before:
     *     TimeoutCapability
     * )
     * ```
     *
     * **Usage in Plugins**:
     * Plugins can check if the engine supports a specific capability before
     * applying behavior:
     * ```kotlin
     * if (engine.supportedCapabilities.contains(WebSocketCapability)) {
     *     // Configure WebSocket-specific settings
     * }
     * ```
     *
     * When implementing a custom engine, ensure this property accurately reflects
     * the engine's abilities to avoid unexpected plugin behavior or runtime errors.
     */
    public val supportedCapabilities: Set<HttpClientEngineCapability<*>>
        get() = emptySet()

    private val closed: Boolean
        get() = !(coroutineContext[Job]?.isActive ?: false)

    /**
     * Executes an HTTP request and produces an HTTP response.
     *
     * This function is responsible for converting [HttpRequestData], which
     * contains all the request details, into [HttpResponseData], which encapsulates
     * the response information such as headers, status code, and body.
     *
     * @param data The [HttpRequestData] representing the request to be executed.
     * @return A [HttpResponseData] object containing the server's response.
     */
    @InternalAPI
    public suspend fun execute(data: HttpRequestData): HttpResponseData

    /**
     * Installs the engine into an [HttpClient].
     *
     * This method is called when the engine is being set up within an `HttpClient`.
     * Use it to register interceptors, validate configuration, or prepare the engine
     * for use with the client.
     *
     * @param client The [HttpClient] instance to which the engine is being installed.
     */
    @InternalAPI
    public fun install(client: HttpClient) {
        client.sendPipeline.intercept(HttpSendPipeline.Engine) { content ->
            val builder = HttpRequestBuilder().apply {
                takeFromWithExecutionContext(context)
                setBody(content)
            }

Review comment (suggestion):
This is a bit hard to read. I suggest a small refinement:

This function takes [HttpRequestData], which contains all details of the HTTP request, and returns [HttpResponseData] with the server's response, including headers, status code, and body.

Code after:
     *     TimeoutCapability
     * )
     * ```
     *
     * **Usage in Plugins**:
     * Plugins can check if the engine supports a specific capability before
     * applying behavior:
     * ```kotlin
     * if (engine.supportedCapabilities.contains(WebSocketCapability)) {
     *     // Configure WebSocket-specific settings
     * }
     * ```
     *
     * When implementing a custom engine, ensure this property accurately reflects
     * the engine's abilities to avoid unexpected plugin behavior or runtime errors.
     */
    public val supportedCapabilities: Set<HttpClientEngineCapability<*>>
        get() = emptySet()

    private val closed: Boolean
        get() = !(coroutineContext[Job]?.isActive ?: false)

    /**
     * Executes an HTTP request and produces an HTTP response.
     *
     * This function takes [HttpRequestData], which contains all details of the HTTP request,
     * and returns [HttpResponseData] with the server's response, including headers, status code, and body.
     *
     * @param data The [HttpRequestData] representing the request to be executed.
     * @return An [HttpResponseData] object containing the server's response.
     */
    @InternalAPI
    public suspend fun execute(data: HttpRequestData): HttpResponseData

    /**
     * Installs the engine into an [HttpClient].
     *
     * This method is called when the engine is being set up within an `HttpClient`.
     * Use it to register interceptors, validate configuration, or prepare the engine
     * for use with the client.
     *
     * @param client The [HttpClient] instance to which the engine is being installed.
     */
    @InternalAPI
    public fun install(client: HttpClient) {
        client.sendPipeline.intercept(HttpSendPipeline.Engine) { content ->
            val builder = HttpRequestBuilder().apply {
                takeFromWithExecutionContext(context)
                setBody(content)
            }