HttpClientConfig

class HttpClientConfig<T : HttpClientEngineConfig>

Mutable configuration used by HttpClient.

Constructors

<init>

HttpClientConfig()

Mutable configuration used by HttpClient.

Properties

expectSuccess

var expectSuccess: Boolean

Terminate HttpClient.responsePipeline 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

Auth

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

Install Auth feature.

BrowserUserAgent

fun HttpClientConfig<*>.BrowserUserAgent(): Unit

Install UserAgent feature with browser-like user agent.

Charsets

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

Configure client charsets.

ContentEncoding

fun HttpClientConfig<*>.ContentEncoding(
    block: Config.() -> Unit = { gzip() deflate() identity() }
): Unit

Install or configure ContentEncoding feature.

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.

Json

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

Install JsonFeature.

Logging

fun HttpClientConfig<*>.Logging(
    block: Config.() -> Unit = {}
): Unit

Configure and install Logging in HttpClient.

ResponseObserver

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

Install ResponseObserver feature in client.

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.