HttpClientConfig

class HttpClientConfig<T : HttpClientEngineConfig>

Mutable configuration used by HttpClient.

Constructors

Link copied to clipboard
fun HttpClientConfig()

Functions

Link copied to clipboard
fun clone(): HttpClientConfig<T>

Clones this HttpClientConfig duplicating all the plugins and customInterceptors.

Link copied to clipboard
fun engine(block: T.() -> Unit)

Configure engine parameters.

Link copied to clipboard
fun install(client: HttpClient)

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

fun <TBuilder : Any, TPlugin : Any> install(plugin: HttpClientPlugin<TBuilder, TPlugin>, configure: TBuilder.() -> Unit = {})

Installs a specific plugin and optionally configure it.

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

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

Link copied to clipboard
operator fun plusAssign(other: HttpClientConfig<out T>)

Install plugin from other client config.

Properties

Link copied to clipboard
var developmentMode: Boolean

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

Link copied to clipboard
var expectSuccess: Boolean = false

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

Link copied to clipboard
var followRedirects: Boolean = true

Use HttpRedirect plugin to automatically follow redirects.

Link copied to clipboard
var useDefaultTransformers: Boolean = true

Use defaultTransformers to automatically handle simple ContentType.

Extensions

Link copied to clipboard
fun HttpClientConfig<*>.addDefaultResponseValidation()

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

Link copied to clipboard
fun HttpClientConfig<*>.BrowserUserAgent()

Installs the UserAgent plugin with a browser-like user agent.

Link copied to clipboard
fun HttpClientConfig<*>.Charsets(block: HttpPlainText.Config.() -> Unit)

Configure client charsets.

Link copied to clipboard
fun HttpClientConfig<*>.CurlUserAgent()

Installs the UserAgent plugin with a CURL user agent.

Link copied to clipboard
fun HttpClientConfig<*>.defaultRequest(block: DefaultRequest.DefaultRequestBuilder.() -> Unit)

Set default request parameters. See DefaultRequest

Link copied to clipboard
fun HttpClientConfig<*>.HttpResponseValidator(block: HttpCallValidator.Config.() -> Unit)

Install HttpCallValidator with block configuration.

Link copied to clipboard
fun HttpClientConfig<*>.ResponseObserver(block: ResponseHandler)

Install ResponseObserver plugin in client.

Link copied to clipboard
fun HttpClientConfig<*>.WebSockets(config: WebSockets.Config.() -> Unit)

Installs the WebSockets plugin using the config as configuration.