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}")
}

Inheritors

Properties

Link copied to clipboard
abstract val request: HttpRequest

The original HTTP request that generated this response.

Link copied to clipboard
abstract val status: Int

The HTTP status code of the response.

Functions

Link copied to clipboard
abstract suspend fun body(): String

Gets the response body as a string.

Link copied to clipboard
abstract fun cookies(): List<String>

Gets all cookies from the response.

Link copied to clipboard
abstract fun header(name: String): String?

Gets a specific header value by name.

Link copied to clipboard
abstract fun headers(): Set<Map.Entry<String, List<String>>>

Gets all headers from the response.