All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.io.github.alexzhirkevich.compottie.DefaultHttpClient.kt Maven / Gradle / Ivy

The newest version!
package io.github.alexzhirkevich.compottie

import io.ktor.client.HttpClient
import io.ktor.client.plugins.HttpRequestRetry
import io.ktor.client.request.get
import io.ktor.client.statement.bodyAsBytes
import io.ktor.client.statement.bodyAsChannel
import io.ktor.utils.io.InternalAPI
import io.ktor.utils.io.toByteArray

internal val DefaultHttpClient by lazy {
    HttpClient {
        followRedirects = true
        expectSuccess = true
        install(HttpRequestRetry) {
            maxRetries = 2
            constantDelay(1000, 500)
        }
    }
}

@OptIn(InternalAPI::class)
internal val DefaultHttpRequest : suspend  (String) -> ByteArray = {
    DefaultHttpClient.get(it).bodyAsBytes()
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy