Yokan / rebuild
Course 1 8624561

PlatformHttp.ios.kt

composeApp/src/iosMain/kotlin/eu/friedcutlet/yokan/services/http/PlatformHttp.ios.kt

implementation28 lines
1package eu.friedcutlet.yokan.services.http23import io.ktor.client.engine.darwin.Darwin4import platform.Foundation.*56// NSURLSession resolves hosts itself; [platformSupportsCustomDns] hides the DNS settings.7internal actual val platformSupportsCustomDns: Boolean = false89internal actual fun createDefaultPlatformHttpClientEngine(resolveHost: HostResolver?): io.ktor.client.engine.HttpClientEngine = Darwin.create()1011@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)12internal actual fun createIsolatedPlatformHttpClientEngine(resolveHost: HostResolver?): io.ktor.client.engine.HttpClientEngine = Darwin.create {13    configureSession {14        HTTPCookieStorage = null15        HTTPShouldSetCookies = false16        URLCredentialStorage = null17        URLCache = null18    }19    configureRequest { setHTTPShouldHandleCookies(false) }20    handleChallenge { _, _, challenge, complete ->21        // Keep normal TLS verification; never ask the OS for another profile's saved HTTP/client22        // certificate credentials. Explicit profile Authorization headers still work normally.23        val disposition = if (challenge.protectionSpace.authenticationMethod == platform.Foundation.NSURLAuthenticationMethodServerTrust)24            platform.Foundation.NSURLSessionAuthChallengePerformDefaultHandling25        else platform.Foundation.NSURLSessionAuthChallengeCancelAuthenticationChallenge26        complete(disposition, null)27    }28}29

Search chapters, reference and source filenames.