question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Empty body in response using macosx64 target

See original GitHub issue

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”)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:24 (19 by maintainers)

github_iconTop GitHub Comments

3reactions
e5lcommented, Sep 23, 2020

Fixed in master

3reactions
e5lcommented, Feb 7, 2020

Hi @joreilly, it looks like you’re trying to use native-mt branch of coroutines, but release ktor is not compatible with it right now: it leads to unexpected freezes. Could you recheck it with the regular version?

The process of migration to the native-mt version is in progress right now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Does anyone know why the Response Body would be empty ...
This works perfectly in Android but IOS returns an empty POST response body. I used IOS Charles and can see the Response body...
Read more >
CHANGELOG.md · Gitee 极速下载/Ktor - Gitee.com
OkHttp: Can't reuse same HttpRequestBuilder for different network clients (KTOR-949); Empty body in response using macosX64 target (KTOR-479) ...
Read more >
WhatsNew 1.4 | Ktor Framework
ClassCastException with HTTP client when using via an inline function with reified type ... Empty body in response using macosx64 target.
Read more >
io.ktor:ktor-client-serialization-macosx64: Versions | Openbase
Full version history for io.ktor:ktor-client-serialization-macosx64 including change logs. ... Empty body in response using macosX64 target (KTOR-479) ...
Read more >
Solved: Re: Empty JSON string when getting target response...
Internal proxy override the Content-Type to have value "application/json" and keep the same JSON response body. External proxy receives response from internal ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found