kotlin
val client = HttpClient {
install(HttpTimeout) {
requestTimeoutMillis = 5000L
}
install(HttpRetry) {
maxRetryAttempts = 3
}
}
kotlin
client.get<String>("https://api.example.com/data") {
header("Authorization", "Bearer token")
body = "Hello, server"
}
kotlin
val response: HttpResponse = client.get("https://api.example.com/data")
kotlin
client.close()