HttpResponse
interface HttpResponse
Interface for accessing HTTP response data.
This interface provides access to all aspects of an HTTP response including status code, headers, cookies, and body content. It is designed to be implemented by different HTTP client libraries while maintaining a consistent API.
Example usage:
val response: HttpResponse = httpClient.request {
url = "https://api.example.com/users"
}
// Check status
if (response.status.isSuccess()) {
// Read body
val body = response.body()
println("Response: $body")
// Access headers
val contentType = response.header("Content-Type")
// Access cookies
val cookies = response.cookies()
} else {
println("Error: ${response.status}")
}Content copied to clipboard