create

fun <T : HttpClientEngineConfig> create(engineFactory: HttpClientEngineFactory<T>, json: Json = DefaultJson, followRedirects: Boolean = false): HttpClient

Builds a client whose engine is created (and closed with the client) from engineFactory, e.g. OkHttp on Android/JVM or Darwin on iOS.

Parameters

json

the JSON codec used for request and response bodies.

followRedirects

whether Ktor follows 3xx redirects; off by default.


fun create(engine: HttpClientEngine, json: Json = DefaultJson, followRedirects: Boolean = false): HttpClient

Builds a client over an existing engine. The engine stays caller-owned: close it yourself once every client using it has finished.

Parameters

json

the JSON codec used for request and response bodies.

followRedirects

whether Ktor follows 3xx redirects; off by default.