Obtaining the redirection header

Report a typo

The code below makes a request to gooogle.com (having previously disabled redirect-following mode) and gets the response headers.

suspend fun main(args: Array<String>) {
    val client = HttpClient(CIO) {
        followRedirects = false
    }
    val response: HttpResponse = client.get("http://gooogle.com")
    println(response.headers)
    client.close()
}

Run this code in your IDE.

What is the value of the Location redirect header?

Specify the value in the answer field.

Enter a short text
___

Create a free account to access the full topic