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

Code before:
/*
* Copyright 2014-2021 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

package io.ktor.client.statement

import io.ktor.client.*
import io.ktor.client.call.*
import io.ktor.client.plugins.*
import io.ktor.client.request.*
import io.ktor.utils.io.*
import kotlinx.coroutines.*

/**
 * Represents a prepared HTTP request statement for `HttpClient`.
 *
 * The `HttpStatement` class encapsulates a request configuration without executing it immediately.
 * This statement can be executed on-demand via various methods such as [execute], allowing for
 * deferred or multiple executions without creating a new request each time.
 *
 * ## Deferred Execution
 * `HttpStatement` does not initiate any network activity until an execution method is called.
 * It is safe to execute multiple times, which can be useful in scenarios requiring reusability of
 * the same request configuration.
 *
 * Example: [Streaming data](https://ktor.io/docs/response.html#streaming)
 */
public class HttpStatement(
    private val builder: HttpRequestBuilder,
    @PublishedApi
    internal val client: HttpClient
) {

    /**
     * Executes the HTTP statement and invokes the provided [block] with the streaming [HttpResponse].
     *
     * The [response] holds an open network connection until [block] completes.
     * You can access the response body incrementally (streaming) or load it entirely with [body<T>()].
     *
     * After [block] finishes, the [response] is finalized based on the engine's configuration—either discarded
     * or released.
     * The [response] object should not be accessed outside of [block] as it will be canceled upon

Review comment (suggestion):
```suggestion
 * The [HttpStatement] class encapsulates a request configuration without executing it immediately.
```

Code after:
/*
* Copyright 2014-2021 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

package io.ktor.client.statement

import io.ktor.client.*
import io.ktor.client.call.*
import io.ktor.client.plugins.*
import io.ktor.client.request.*
import io.ktor.utils.io.*
import kotlinx.coroutines.*

/**
 * Represents a prepared HTTP request statement for [HttpClient].
 *
 * The [HttpStatement] class encapsulates a request configuration without executing it immediately.
 * This statement can be executed on-demand via various methods such as [execute], allowing for
 * deferred or multiple executions without creating a new request each time.
 *
 * ## Deferred Execution
 * `HttpStatement` does not initiate any network activity until an execution method is called.
 * It is safe to execute multiple times, which can be useful in scenarios requiring reusability of
 * the same request configuration.
 *
 * Example: [Streaming data](https://ktor.io/docs/response.html#streaming)
 */
public class HttpStatement(
    private val builder: HttpRequestBuilder,
    @PublishedApi
    internal val client: HttpClient
) {

    /**
     * Executes the HTTP statement and invokes the provided [block] with the streaming [HttpResponse].
     *
     * The [response] holds an open network connection until [block] completes.
     * You can access the response body incrementally (streaming) or load it entirely with [body<T>()].
     *
     * After [block] finishes, the [response] is finalized based on the engine's configuration—either discarded
     * or released.
     * The [response] object should not be accessed outside of [block] as it will be canceled upon