Package-level declarations

Types

Link copied to clipboard

Plugin 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
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

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

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

Base interface representing a HttpClient plugin.

Link copied to clipboard

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

Link copied to clipboard

An HttpClient plugin that handles HTTP redirects

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
class HttpRequestTimeoutException(url: String, timeoutMillis: Long?) : IOException

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
class HttpSend

This is an internal plugin that is always installed.

Link copied to clipboard

HttpSend pipeline interceptor function

Link copied to clipboard

A plugin that allows you to configure the following timeouts:

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

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

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

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.

Properties

Link copied to clipboard

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