HttpClient

interface HttpClient

Interface for HTTP client implementations.

This interface defines the contract for making HTTP requests and receiving responses. It provides an abstraction that can be implemented using different underlying HTTP client libraries (Ktor, OkHttp, Apache HttpClient, etc.) while maintaining a consistent API across the SDK.

Implementations

The SDK provides a default implementation using Ktor with CIO engine: You can also create custom implementations for specific requirements:

class CustomHttpClient : HttpClient {
override fun request(): HttpRequest = CustomHttpRequest()
override suspend fun request(request: HttpRequest): HttpResponse { ... }
override suspend fun request(requestBuilder: HttpRequest.() -> Unit): HttpResponse { ... }
override fun close() { ... }
}

See also

Inheritors

Functions

Link copied to clipboard
abstract fun close()

Closes the HTTP client and releases all resources.

Link copied to clipboard
abstract fun request(): HttpRequest

Creates a new HTTP request instance.

abstract suspend fun request(request: HttpRequest): HttpResponse

Sends an HTTP request and returns the response.

abstract suspend fun request(requestBuilder: HttpRequest.() -> Unit): HttpResponse

Sends an HTTP request built with a builder lambda and returns the response.