diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/ktor/KtorRequestsExecutor.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/ktor/KtorRequestsExecutor.kt index 503601bc4b..b0b1996613 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/ktor/KtorRequestsExecutor.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/ktor/KtorRequestsExecutor.kt @@ -11,8 +11,8 @@ import kotlinx.serialization.json.Json /** * Represents default [BaseRequestsExecutor] working on [Ktor](https://ktor.io) [HttpClient] * - * * On JS and JVM platforms it is [dev.inmo.tgbotapi.bot.ktor.base.DefaultKtorRequestsExecutor] - * * On LinuxX64 and MingwX64 it is [dev.inmo.tgbotapi.bot.ktor.base.MultipleClientKtorRequestsExecutor] + * * On JS, JVM and MingwX64 platforms it is [dev.inmo.tgbotapi.bot.ktor.base.DefaultKtorRequestsExecutor] + * * On LinuxX64 it is [dev.inmo.tgbotapi.bot.ktor.base.MultipleClientKtorRequestsExecutor] */ expect class KtorRequestsExecutor ( telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/ktor/base/MultipleClientKtorRequestsExecutor.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/ktor/base/MultipleClientKtorRequestsExecutor.kt index 8a468606fc..c8c6a73337 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/ktor/base/MultipleClientKtorRequestsExecutor.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/ktor/base/MultipleClientKtorRequestsExecutor.kt @@ -17,13 +17,11 @@ import kotlinx.serialization.json.Json /** * This function is used in default constructor of [MultipleClientKtorRequestsExecutor] and on all non-native - * platforms should return [HttpClient.config] call + * platforms and MingwX64 should return [client] * * On LinuxX64 it will create copy with Curl engine or throw an exception if engine is different with Curl - * On MingwX64 it will create copy with WinHttp engine or throw an exception if engine is different with WinHttp * - * @throws IllegalArgumentException When pass non Curl-based [HttpClient] on LinuxX64 or non WinHttp-based [HttpClient] - * on MingwX64 + * @throws IllegalArgumentException When pass non Curl-based [HttpClient] on LinuxX64 */ internal expect inline fun platformClientCopy(client: HttpClient): HttpClient @@ -31,7 +29,7 @@ internal expect inline fun platformClientCopy(client: HttpClient): HttpClient * Will use its parameters of constructor to create several [DefaultKtorRequestsExecutor] and use them in [execute] * and [close] operations * - * This [BaseRequestsExecutor] has been created for native targets due to their inability of requests paralleling + * This [BaseRequestsExecutor] has been created for LinuxX64 target due to its inability of requests paralleling * * Under the hood on each [execute] it will take [DefaultKtorRequestsExecutor] and mark it as busy, execute * [Request], free up taken [DefaultKtorRequestsExecutor] and return (or throw) the result of execution diff --git a/tgbotapi.core/src/jsMain/kotlin/dev/inmo/tgbotapi/bot/ktor/base/ActualPlatformClientCopy.kt b/tgbotapi.core/src/jsMain/kotlin/dev/inmo/tgbotapi/bot/ktor/base/ActualPlatformClientCopy.kt index 998333d34f..3b3451a931 100644 --- a/tgbotapi.core/src/jsMain/kotlin/dev/inmo/tgbotapi/bot/ktor/base/ActualPlatformClientCopy.kt +++ b/tgbotapi.core/src/jsMain/kotlin/dev/inmo/tgbotapi/bot/ktor/base/ActualPlatformClientCopy.kt @@ -4,12 +4,10 @@ import io.ktor.client.* /** * This function is used in default constructor of [MultipleClientKtorRequestsExecutor] and on all non-native - * platforms should return [HttpClient.config] call + * platforms and MingwX64 should return [client] * * On LinuxX64 it will create copy with Curl engine or throw an exception if engine is different with Curl - * On MingwX64 it will create copy with WinHttp engine or throw an exception if engine is different with WinHttp * - * @throws IllegalArgumentException When pass non Curl-based [HttpClient] on LinuxX64 or non WinHttp-based [HttpClient] - * on MingwX64 + * @throws IllegalArgumentException When pass non Curl-based [HttpClient] on LinuxX64 */ internal actual inline fun platformClientCopy(client: HttpClient): HttpClient = client.config { } diff --git a/tgbotapi.core/src/jvmMain/kotlin/dev/inmo/tgbotapi/bot/ktor/base/ActualPlatformClientCopy.kt b/tgbotapi.core/src/jvmMain/kotlin/dev/inmo/tgbotapi/bot/ktor/base/ActualPlatformClientCopy.kt index 998333d34f..3b3451a931 100644 --- a/tgbotapi.core/src/jvmMain/kotlin/dev/inmo/tgbotapi/bot/ktor/base/ActualPlatformClientCopy.kt +++ b/tgbotapi.core/src/jvmMain/kotlin/dev/inmo/tgbotapi/bot/ktor/base/ActualPlatformClientCopy.kt @@ -4,12 +4,10 @@ import io.ktor.client.* /** * This function is used in default constructor of [MultipleClientKtorRequestsExecutor] and on all non-native - * platforms should return [HttpClient.config] call + * platforms and MingwX64 should return [client] * * On LinuxX64 it will create copy with Curl engine or throw an exception if engine is different with Curl - * On MingwX64 it will create copy with WinHttp engine or throw an exception if engine is different with WinHttp * - * @throws IllegalArgumentException When pass non Curl-based [HttpClient] on LinuxX64 or non WinHttp-based [HttpClient] - * on MingwX64 + * @throws IllegalArgumentException When pass non Curl-based [HttpClient] on LinuxX64 */ internal actual inline fun platformClientCopy(client: HttpClient): HttpClient = client.config { } diff --git a/tgbotapi.core/src/linuxX64Main/kotlin/bot/ktor/base/ActualPlatformClientCopy.kt b/tgbotapi.core/src/linuxX64Main/kotlin/bot/ktor/base/ActualPlatformClientCopy.kt index 3e883a1ba7..8f7104ddc0 100644 --- a/tgbotapi.core/src/linuxX64Main/kotlin/bot/ktor/base/ActualPlatformClientCopy.kt +++ b/tgbotapi.core/src/linuxX64Main/kotlin/bot/ktor/base/ActualPlatformClientCopy.kt @@ -5,13 +5,11 @@ import io.ktor.client.engine.curl.* /** * This function is used in default constructor of [MultipleClientKtorRequestsExecutor] and on all non-native - * platforms should return [client] + * platforms and MingwX64 should return [client] * * On LinuxX64 it will create copy with Curl engine or throw an exception if engine is different with Curl - * On MingwX64 it will create copy with WinHttp engine or throw an exception if engine is different with WinHttp * - * @throws IllegalArgumentException When pass non Curl-based [HttpClient] on LinuxX64 or non WinHttp-based [HttpClient] - * on MingwX64 + * @throws IllegalArgumentException When pass non Curl-based [HttpClient] on LinuxX64 */ internal actual inline fun platformClientCopy(client: HttpClient): HttpClient = (client.engineConfig as? CurlClientEngineConfig) ?.let { lateinit var config: HttpClientConfig diff --git a/tgbotapi.core/src/mingwX64Main/kotlin/bot/ktor/KtorRequestsExecutor.kt b/tgbotapi.core/src/mingwX64Main/kotlin/bot/ktor/KtorRequestsExecutor.kt index 2f49bfc213..fd842f95bb 100644 --- a/tgbotapi.core/src/mingwX64Main/kotlin/bot/ktor/KtorRequestsExecutor.kt +++ b/tgbotapi.core/src/mingwX64Main/kotlin/bot/ktor/KtorRequestsExecutor.kt @@ -1,5 +1,5 @@ package dev.inmo.tgbotapi.bot.ktor -import dev.inmo.tgbotapi.bot.ktor.base.MultipleClientKtorRequestsExecutor +import dev.inmo.tgbotapi.bot.ktor.base.DefaultKtorRequestsExecutor -actual typealias KtorRequestsExecutor = MultipleClientKtorRequestsExecutor +actual typealias KtorRequestsExecutor = DefaultKtorRequestsExecutor diff --git a/tgbotapi.core/src/mingwX64Main/kotlin/dev/inmo/tgbotapi/bot/ktor/base/ActualPlatformClientCopy.kt b/tgbotapi.core/src/mingwX64Main/kotlin/dev/inmo/tgbotapi/bot/ktor/base/ActualPlatformClientCopy.kt index 27b486a3a1..05eb9ece47 100644 --- a/tgbotapi.core/src/mingwX64Main/kotlin/dev/inmo/tgbotapi/bot/ktor/base/ActualPlatformClientCopy.kt +++ b/tgbotapi.core/src/mingwX64Main/kotlin/dev/inmo/tgbotapi/bot/ktor/base/ActualPlatformClientCopy.kt @@ -5,20 +5,10 @@ import io.ktor.client.engine.winhttp.* /** * This function is used in default constructor of [MultipleClientKtorRequestsExecutor] and on all non-native - * platforms should return [client] + * platforms and MingwX64 should return [client] * * On LinuxX64 it will create copy with Curl engine or throw an exception if engine is different with Curl - * On MingwX64 it will create copy with WinHttp engine or throw an exception if engine is different with WinHttp * - * @throws IllegalArgumentException When pass non Curl-based [HttpClient] on LinuxX64 or non WinHttp-based [HttpClient] - * on MingwX64 + * @throws IllegalArgumentException When pass non Curl-based [HttpClient] on LinuxX64 */ -internal actual inline fun platformClientCopy(client: HttpClient): HttpClient = (client.engineConfig as? WinHttpClientEngineConfig) ?.let { engineConfig -> - lateinit var config: HttpClientConfig - client.config { - config = this as HttpClientConfig - }.close() - HttpClient(WinHttp) { - this.plusAssign(config) - } -} ?: throw IllegalArgumentException("On LinuxX64 TelegramBotAPI currently support only Curl Ktor HttpClient engine") +internal actual inline fun platformClientCopy(client: HttpClient): HttpClient = client.config { }