Package io.ktor.client.features

Types

DefaultRequest

class DefaultRequest

Feature is used to set request default parameters.

ExpectSuccess

class ExpectSuccess

HttpCallValidator

class HttpCallValidator

Response validator feature is used for validate response and handle response exceptions.

HttpClientFeature

interface HttpClientFeature<out TConfig : Any, TFeature : Any>

Base interface representing a HttpClient feature.

HttpPlainText

class HttpPlainText

HttpClient feature that encodes String request bodies to TextContent and processes the response body as String.

HttpRedirect

class HttpRedirect

HttpClient feature that handles http redirect

HttpSend

class HttpSend

This is internal feature that is always installed.

Sender

interface Sender

This interface represents a request send pipeline interceptor chain

UserAgent

class UserAgent

Default user-agent feature for HttpClient.

Exceptions

ClientRequestException

class ClientRequestException : ResponseException

Bad client request exception.

RedirectResponseException

class RedirectResponseException : ResponseException

Unhandled redirect exception.

ResponseException

open class ResponseException : IllegalStateException

Base for default response exceptions.

SendCountExceedException

class SendCountExceedException : IllegalStateException

Thrown when too many actual requests were sent during a client call. It could be caused by infinite or too long redirect sequence. Maximum number of requests is limited by HttpSend.maxSendCount

ServerResponseException

class ServerResponseException : ResponseException

Server error exception.

Type Aliases

BadResponseStatusException

typealias BadResponseStatusException = ResponseException

CallExceptionHandler

typealias CallExceptionHandler = suspend (cause: Throwable) -> Unit

Response exception handler method.

HttpSendInterceptor

typealias HttpSendInterceptor = suspend Sender.(HttpClientCall) -> HttpClientCall

HttpSend pipeline interceptor function

ResponseValidator

typealias ResponseValidator = suspend (response: HttpResponse) -> Unit

Response validator method.

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.

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.

defaultTransformers

fun HttpClient.defaultTransformers(): Unit

Install default transformers. Usually installed by default so there is no need to use it unless you have disabled it via HttpClientConfig.useDefaultTransformers.

feature

fun <B : Any, F : Any> HttpClient.feature(
    feature: HttpClientFeature<B, F>
): F?

Try to get a feature installed in this client. Returns null if the feature was not previously installed.