Is `ktor-client-ios` works in iOS emulator? Works ...
# ktor
a
Is
ktor-client-ios
works in iOS emulator? Works with https? Is
HttpClient(Ios.create {})
a good way for create HttpClient? This code works fine from macOS application from kotlin-native (with curl in HttpClient) but doesn’t work on Swift code with kotlin library.
Copy code
val client = HttpClient(Ios.create {}) {
                HttpResponseValidator {
                    validateResponse { response ->
                        when (response.status.value) {
                            in 300..399 -> throw RedirectResponseException(response)
                            in 400..499 -> throw ClientRequestException(response)
                            in 500..599 -> throw ServerResponseException(response)
                        }
                    }
                }
                expectSuccess = false
           <http://client.post|client.post><String>(url) {
                contentType(ContentType.Application.Json)
                header("x-api-key", "KEY")
                body = request
            }
I have error in log:
Copy code
HttpClient: REQUEST: <https://SITE>
HttpClient: METHOD: HttpMethod(value=POST)
HttpClient: COMMON HEADERS
HttpClient: -> Accept: */*
HttpClient: -> Accept-Charset: UTF-8
HttpClient: -> x-api-key: KEY
HttpClient: CONTENT HEADERS
... Connection 1: received failure notification
... Connection 1: failed to connect 3:-9816, reason -1
... Connection 1: encountered error(3:-9816)
... Task <06ED9745-5284-4678-87C8-D791E461BA71>.<1> HTTP load failed, 0/0 bytes (error code: -1200 [3:-9816])
There are no
Content-Type: application/json
in the headers 🤔