Computer scienceBackendKtorKtor Client

Ktor Client: First view

Theory

The right way to add headers

Report a typo

Select the option where the request header is set correctly.

1)

client.get("http://example.com") {
    headers {
        append(HttpHeaders.Accept, "text/html")
    }
}

2)

client.get("http://example.com") {
    headers {
        append("Accept", "text/html")
    }
}

3)

client.get("http://example.com") {
    headers {
        append("Accept: text/html")
    }
}

4)

client.get("http://example.com") {
    appendHeader(HttpHeaders.Accept, "text/html")
}

5)

client.get("http://example.com") {
    appendHeader("Accept", "text/html")
}

6)

client.get("http://example.com") {
    appendHeader("Accept: text/html")
}
Select one option from the list

Create a free account to access the full topic