Package io.ktor.client.features

Types

Link copied to clipboard
typealias BadResponseStatusException = ResponseException
Link copied to clipboard
class BodyProgress

Feature that provides observable progress for uploads and downloads

Link copied to clipboard
typealias CallExceptionHandler = suspend (cause: Throwable) -> Unit

Response exception handler method.

Link copied to clipboard
class ClientRequestException(response: HttpResponse, cachedResponseText: String) : ResponseException

Bad client request exception.

Link copied to clipboard

Object for installing io.ktor.util.converters.DataConversion as feature

Link copied to clipboard
class DefaultRequest(builder: HttpRequestBuilder.() -> Unit)

Feature is used to set request default parameters.

Link copied to clipboard
class ExpectSuccess
Link copied to clipboard
class HttpCallValidator

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

Link copied to clipboard
interface HttpClientFeature<out TConfig : Any, TFeature : Any>

Base interface representing a HttpClient feature.

Link copied to clipboard
class HttpPlainText

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

Link copied to clipboard
class HttpRedirect

HttpClient feature that handles http redirect

Link copied to clipboard
class HttpRequestTimeoutException(request: HttpRequestBuilder) : CancellationException

This exception is thrown in case request timeout exceeded.

Link copied to clipboard
class HttpSend(maxSendCount: Int)

This is internal feature that is always installed.

Link copied to clipboard
typealias HttpSendInterceptor = suspend Sender.(HttpClientCall, HttpRequestBuilder) -> HttpClientCall

HttpSend pipeline interceptor function

Link copied to clipboard
typealias HttpSendInterceptorBackwardCompatible = suspend Sender.(HttpClientCall) -> HttpClientCall

HttpSend pipeline interceptor function backward compatible with previous implementation.

Link copied to clipboard
class HttpTimeout(requestTimeoutMillis: Long?, connectTimeoutMillis: Long?, socketTimeoutMillis: Long?)

Client HTTP timeout feature. There are no default values, so default timeouts will be taken from engine configuration or considered as infinite time if engine doesn't provide them.

Link copied to clipboard
class RedirectResponseException(response: HttpResponse, cachedResponseText: String) : ResponseException

Unhandled redirect exception.

Link copied to clipboard
open class ResponseException(response: HttpResponse, cachedResponseText: String) : IllegalStateException

Base for default response exceptions.

Link copied to clipboard
typealias ResponseValidator = suspend (response: HttpResponse) -> Unit

Response validator method.

You could throw an exception to fail the response.

Link copied to clipboard
class SendCountExceedException(message: String) : 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

Link copied to clipboard
interface Sender

This interface represents a request send pipeline interceptor chain

Link copied to clipboard
class ServerResponseException(response: HttpResponse, cachedResponseText: String) : ResponseException

Server error exception.

Link copied to clipboard
class UserAgent(agent: String)

Default user-agent feature for HttpClient.

Functions

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()

Install UserAgent feature with browser-like user agent.

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

Configure client charsets.

Link copied to clipboard
fun ConnectTimeoutException(request: HttpRequestData, cause: Throwable? = null): ConnectTimeoutException
fun ConnectTimeoutException(url: String, timeout: Long?, cause: Throwable? = null): ConnectTimeoutException

This exception is thrown in case connect timeout exceeded.

fun convertLongTimeoutToIntWithInfiniteAsZero(timeout: Long): Int

Convert long timeout in milliseconds to int value. To do that we need to consider HttpTimeout.INFINITE_TIMEOUT_MS as zero and convert timeout value to Int.

fun convertLongTimeoutToLongWithInfiniteAsZero(timeout: Long): Long

Convert long timeout in milliseconds to long value. To do that we need to consider HttpTimeout.INFINITE_TIMEOUT_MS as zero and convert timeout value to Int.

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

Install UserAgent feature with browser-like user agent.

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

Set request default parameters.

Link copied to clipboard
fun HttpClient.defaultTransformers()

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

Link copied to clipboard
fun <B : Any, F : Any> HttpClient.feature(feature: HttpClientFeature<B, F>): F?

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

Link copied to clipboard
operator fun <B : Any, F : Any> HttpClient.get(feature: HttpClientFeature<B, F>): F

Find the feature installed in HttpClient.

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

Install HttpCallValidator with block configuration.

Link copied to clipboard
fun HttpRequestBuilder.onDownload(listener: ProgressListener?)

Registers listener to observe download progress.

Link copied to clipboard
fun HttpRequestBuilder.onUpload(listener: ProgressListener?)

Registers listener to observe upload progress.

Link copied to clipboard
fun SocketTimeoutException(request: HttpRequestData, cause: Throwable? = null): SocketTimeoutException

This exception is thrown in case socket timeout (read or write) exceeded.

Link copied to clipboard

Adds timeout boundaries to the request. Requires HttpTimeout feature to be installed.

Properties

Link copied to clipboard
var HttpRequestBuilder.expectSuccess: Boolean

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