HttpRequestBuilder

Contains parameters used to make an HTTP request.

Learn more from Making requests.

Constructors

Link copied to clipboard

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard

Creates immutable HttpRequestData.

Link copied to clipboard

Retrieves capability by the key.

Link copied to clipboard
fun setAttributes(block: Attributes.() -> Unit)

Sets request-specific attributes specified by block.

Link copied to clipboard
fun <T : Any> setCapability(key: HttpClientEngineCapability<T>, capability: T)

Sets capability configuration.

Link copied to clipboard

Mutates this by copying all the data but execution context from another builder using it as the base.

Link copied to clipboard

Mutates this copying all the data from another builder using it as the base.

Link copied to clipboard
fun url(block: URLBuilder.(URLBuilder) -> Unit)

Executes a block that configures the URLBuilder associated to this request.

Properties

Link copied to clipboard

Provides access to attributes specific for this request.

Link copied to clipboard
var body: Any

The body for this request. Initially EmptyContent.

Link copied to clipboard

The KType of body for this request. Null for default types that don't need serialization.

Link copied to clipboard

A deferred used to control the execution of this request.

Link copied to clipboard
open override val headers: HeadersBuilder

HeadersBuilder to configure the headers for this request.

Link copied to clipboard

HttpMethod used by this request. HttpMethod.Get by default.

Link copied to clipboard

URLBuilder to configure the URL for this request.

Extensions

Link copied to clipboard

Appends the Accept header with a specific contentType.

Link copied to clipboard
fun HttpMessageBuilder.basicAuth(username: String, password: String)

Appends the HttpHeaders.Authorization to Basic Authorization with the provided username and password. For advanced configuration use the io.ktor:ktor-client-auth plugin.

Link copied to clipboard

Appends the HttpHeaders.Authorization to Bearer Authorization with the provided token. For advanced configuration use the io.ktor:ktor-client-auth plugin.

Link copied to clipboard
fun HttpMessageBuilder.cookie(name: String, value: String, maxAge: Int = 0, expires: GMTDate? = null, domain: String? = null, path: String? = null, secure: Boolean = false, httpOnly: Boolean = false, extensions: Map<String, String?> = emptyMap())

Appends a single header of key with a specific value if the value is not null.

Link copied to clipboard

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

Link copied to clipboard
fun HttpMessageBuilder.header(key: String, value: Any?)

Appends a single header of key with a specific value if the value is not null.

Link copied to clipboard

Executes a block that configures the HeadersBuilder associated to this request.

Link copied to clipboard

Gets the associated URL's host.

Link copied to clipboard

Registers listener to observe download progress.

Link copied to clipboard

Registers listener to observe upload progress.

Link copied to clipboard

Appends a single URL query parameter of key with a specific value if the value is not null. Can not be used to set form parameters in the body.

Link copied to clipboard

Gets the associated URL's port.

Link copied to clipboard

Configures the HttpRequestRetry plugin on a per-request level.

Link copied to clipboard
inline fun <T> HttpRequestBuilder.setBody(body: T)
fun HttpRequestBuilder.setBody(body: Any?, bodyType: TypeInfo)
Link copied to clipboard

Mutates this copying all the data from another request using it as base.

Link copied to clipboard

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

Link copied to clipboard

Executes a block that configures the URLBuilder associated to this request.

fun HttpRequestBuilder.url(scheme: String? = null, host: String? = null, port: Int? = null, path: String? = null, block: URLBuilder.() -> Unit = {})

Sets the url using the specified scheme, host, port and path. Pass null to keep the existing value in the URLBuilder.

fun HttpRequestBuilder.url(urlString: String)