create

fun create(connectionTimeout: Duration = 2.seconds, requestTimeout: Duration = 10.seconds, socketTimeout: Duration = 10.seconds, maxConnections: Int = 128, enableLogging: Boolean = false, logLevel: LogLevel = LogLevel.INFO, negotiation: ContentNegotiationConfig.() -> Unit = { json() }, configure: HttpClientConfig<CIOEngineConfig>.() -> Unit = {}): HttpClient(source)

Creates a configured instance of an HttpClient with specified connection settings, timeouts, and content negotiation.

Return

a configured instance of HttpClient.

Parameters

connectionTimeout

the timeout duration for establishing connections, default is 2 seconds.

requestTimeout

the timeout duration for the entire request, default is 10 seconds.

socketTimeout

the timeout duration for reading data from sockets, default is 10 seconds.

maxConnections

the maximum number of connections allowed in the connection pool, default is 128.

enableLogging

whether to enable HTTP request/response logging, default is false.

logLevel

the logging level for HTTP requests, the default is LogLevel.INFO.

negotiation

registers the client's content converters and is the only codec installed; the default is kotlinx.serialization JSON with Ktor's default Json. Pass { json(myJson) } for another Json, or another converter (e.g. { jackson() }).

configure

runs last on the client's configuration, to install further plugins or extend the ones above.