ktor-client-core / io.ktor.client / HttpClientConfig

HttpClientConfig

class HttpClientConfig<T : HttpClientEngineConfig>

Mutable configuration used by HttpClient.

Constructors

<init>

HttpClientConfig()

Mutable configuration used by HttpClient.

Properties

developmentMode

var developmentMode: Boolean

Indicate if client should use development mode. In development mode client pipelines have advanced stack traces.

expectSuccess

var expectSuccess: Boolean

Terminate HttpClient.receivePipeline if status code is not success(>=300).

followRedirects

var followRedirects: Boolean

Use HttpRedirect feature to automatically follow redirects.

useDefaultTransformers

var useDefaultTransformers: Boolean

Use defaultTransformers to automatically handle simple ContentType.

Functions

clone

fun clone(): HttpClientConfig<T>

Clones this HttpClientConfig duplicating all the features and customInterceptors.

engine

fun engine(block: T.() -> Unit): Unit

Configure engine parameters.

install

fun <TBuilder : Any, TFeature : Any> install(feature: HttpClientFeature<TBuilder, TFeature>, configure: TBuilder.() -> Unit = {}): Unit

Installs a specific feature and optionally configure it.

fun install(key: String, block: HttpClient.() -> Unit): Unit

Installs an interceptor defined by block. The key parameter is used as a unique name, that also prevents installing duplicated interceptors.

fun install(client: HttpClient): Unit

Applies all the installed features and customInterceptors from this configuration into the specified client.

plusAssign

operator fun plusAssign(other: HttpClientConfig<out T>): Unit

Install features from other client config.

Extension Functions

BrowserUserAgent

fun HttpClientConfig<*>.BrowserUserAgent(): Unit

Install UserAgent feature with browser-like user agent.

Charsets

fun HttpClientConfig<*>.Charsets(block: Config.() -> Unit): Unit

Configure client charsets.

CurlUserAgent

fun HttpClientConfig<*>.CurlUserAgent(): Unit

Install UserAgent feature with browser-like user agent.

HttpResponseValidator

fun HttpClientConfig<*>.HttpResponseValidator(block: Config.() -> Unit): Unit

Install HttpCallValidator with block configuration.

ResponseObserver

fun HttpClientConfig<*>.ResponseObserver(block: ResponseHandler): Unit

Install ResponseObserver feature in client.

WebSockets

fun HttpClientConfig<*>.WebSockets(config: Config.() -> Unit): Unit

Install WebSockets feature using the config as configuration.

addDefaultResponseValidation

fun HttpClientConfig<*>.addDefaultResponseValidation(): Unit

Default response validation. Check the response status code in range (0..299).

defaultRequest

fun HttpClientConfig<*>.defaultRequest(block: HttpRequestBuilder.() -> Unit): Unit

Set request default parameters.