Package-level declarations

Types

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

Response exception handler method.

Link copied to clipboard
typealias CallRequestExceptionHandler = suspend (cause: Throwable, request: HttpRequest) -> Unit

Response exception handler method. request is null if

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

Bad client request exception.

Link copied to clipboard

Sets default request parameters. Used to add common headers and URL for a request. Note that trailing slash in base URL and leading slash in request URL are important. The rules to calculate a final URL:

Link copied to clipboard
Link copied to clipboard
interface HttpClientPlugin<out TConfig : Any, TPlugin : Any>

Base interface representing a HttpClient plugin.

Link copied to clipboard

Charset configuration for HttpPlainText plugin.

Link copied to clipboard
Link copied to clipboard

Contains HttpRequestRetry configurations settings.

Link copied to clipboard
class HttpRequestTimeoutException(url: String, timeoutMillis: Long?, cause: Throwable? = null) : IOException, CopyableThrowable<HttpRequestTimeoutException>

This exception is thrown in case the request timeout is exceeded. The request timeout is the time period required to process an HTTP call: from sending a request to receiving a response.

Link copied to clipboard

A context for HttpRequestRetry.Configuration.delayMillis. Contains a non-null response or cause but not both.

Link copied to clipboard

Data for the HttpRequestRetryEvent event. Contains a non-null response or cause but not both.

Link copied to clipboard

A context for HttpRequestRetry.Configuration.modifyRequest. Contains a non-null response or cause but not both.

Link copied to clipboard
class HttpRetryShouldRetryContext(val retryCount: Int)

A context for HttpRequestRetry.Configuration.shouldRetry and HttpRequestRetry.Configuration.shouldRetryOnException

Link copied to clipboard
class HttpSend

This is an internal plugin that is always installed.

Link copied to clipboard

HttpSend pipeline interceptor function

Link copied to clipboard

An HttpTimeout extension configuration that is used during installation.

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.

Link copied to clipboard

Configuration for SaveBodyPlugin

Link copied to clipboard

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
object SetupRequestContext : ClientHook<suspend (HttpRequestBuilder, suspend () -> Unit) -> Unit>
Link copied to clipboard
class UserAgentConfig(var agent: String = "Ktor http-client")

Properties

Link copied to clipboard

Plugin that provides observable progress for uploads and downloads

Link copied to clipboard

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

Link copied to clipboard

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

Link copied to clipboard

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

Link copied to clipboard
Link copied to clipboard

A client's HTTP plugin that sets up HttpRequestBuilder.executionContext and completes it when the pipeline is fully processed.

Link copied to clipboard

A plugin that enables the client to retry failed requests. The default retry policy is 3 retries with exponential delay. Typical usages:

Link copied to clipboard
Link copied to clipboard

Occurs when receiving a response with a redirect message.

Link copied to clipboard

A plugin that allows you to configure the following timeouts:

Link copied to clipboard
Link copied to clipboard

SaveBodyPlugin saving the whole body in memory, so it can be received multiple times.

Link copied to clipboard

A plugin that adds a User-Agent header to all requests.

Functions

Link copied to clipboard

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

Link copied to clipboard

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

Link copied to clipboard

Configure client charsets.

Link copied to clipboard

This exception is thrown in case the connection timeout is exceeded. It indicates the client took too long to establish a connection with a server.

Converts a 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.

Converts 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

Installs the UserAgent plugin with a CURL user agent.

Link copied to clipboard

Set default request parameters. See DefaultRequest

Link copied to clipboard

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
Link copied to clipboard

Registers listener to observe download progress.

Link copied to clipboard

Registers listener to observe upload progress.

Link copied to clipboard
fun <B : Any, F : Any> HttpClient.plugin(plugin: HttpClientPlugin<B, F>): F

Returns a plugin installed in HttpClient.

Link copied to clipboard
fun <B : Any, F : Any> HttpClient.pluginOrNull(plugin: HttpClientPlugin<B, F>): F?

Returns a plugin installed in this client. Returns null if the plugin was not previously installed.

Link copied to clipboard

Configures the HttpRequestRetry plugin on a per-request level.

Link copied to clipboard

Prevent saving response body in memory for the specific request.

Link copied to clipboard

This exception is thrown in case the socket timeout (read or write) is exceeded. It indicates the time between two data packets when exchanging data with a server was too long.

Link copied to clipboard

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