Skip to content

Empty body in response using macosx64 target #1622

@joreilly

Description

Ktor Version and Engine Used (client or server and name)
1.3.0, client (macosx64) (using curl)

Describe the bug
When using macosx64 target in a Multiplatform project I'm getting empty BODY in response

HttpClient: REQUEST: http://api.open-notify.org/astros.json
HttpClient: METHOD: HttpMethod(value=GET)
HttpClient: COMMON HEADERS
HttpClient: -> Accept: application/json
HttpClient: -> Accept-Charset: UTF-8
HttpClient: CONTENT HEADERS
HttpClient: BODY Content-Type: null
HttpClient: BODY START
HttpClient: BODY END

The same code for iOS logs

HttpClient: REQUEST: http://api.open-notify.org/astros.json
HttpClient: METHOD: HttpMethod(value=GET)
HttpClient: COMMON HEADERS
HttpClient: -> Accept: application/json
HttpClient: -> Accept-Charset: UTF-8
HttpClient: CONTENT HEADERS
HttpClient: BODY Content-Type: null
HttpClient: BODY START
HttpClient: BODY END
HttpClient: BODY Content-Type: application/json
HttpClient: BODY START
HttpClient: {"people": [{"craft": "ISS", "name": "Andrew Morgan"}, {"craft": "ISS", "name": "Oleg Skripochka"}, {"craft": "ISS", "name": "Jessica Meir"}], "message": "success", "number": 3}
HttpClient: BODY END

The following is the common code that uses ktor

class PeopleInSpaceApi {
    private val url = "http://api.open-notify.org/astros.json"

    private val client by lazy {
        HttpClient() {
            install(JsonFeature) {
                serializer = KotlinxSerializer(Json(JsonConfiguration(strictMode = false)))
            }
            install(Logging) {
                logger = Logger.DEFAULT
                level = LogLevel.ALL
            }
        }
    }

    suspend fun fetchPeople(): AstroResult {
        return client.get(url) 
    }
}

I'm using following dependencies

        macOSMain.dependencies {
            // Coroutines
            implementation('org.jetbrains.kotlinx:kotlinx-coroutines-core-macosx64') {
                version {
                    strictly '1.3.3-native-mt'
                }
            }

            // Ktor
            implementation "io.ktor:ktor-client-curl:${Versions.ktor}"
            implementation "io.ktor:ktor-client-core-macosx64:${Versions.ktor}"
            implementation "io.ktor:ktor-client-json-macosx64:${Versions.ktor}"
            implementation "io.ktor:ktor-client-logging-macosx64:${Versions.ktor}"
            implementation "io.ktor:ktor-client-serialization-macosx64:${Versions.ktor}"

            // Serialize
            implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-macosx64:${Versions.kotlinxSerialization}"

        }

(kotlinxSerialization = "0.14.0")

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions