Package io.ktor.client.request.forms

Types

Link copied to clipboard
class FormBuilder

Form builder type used in formData builder function.

Link copied to clipboard
class FormDataContent(formData: Parameters) : OutgoingContent.ByteArrayContent

OutgoingContent with for application/x-www-form-urlencoded formatted request.

Link copied to clipboard
data class FormPart<T : Any>(key: String, value: T, headers: Headers)

Multipart form item. Use it to build form in client.

Link copied to clipboard
class InputProvider(size: Long?, block: () -> Input)

Reusable Input form entry.

Link copied to clipboard

OutgoingContent for multipart/form-data formatted request.

Functions

Link copied to clipboard
inline fun FormBuilder.append(key: String, headers: Headers = Headers.Empty, size: Long? = null, crossinline bodyBuilder: BytePacketBuilder.() -> Unit)

Append a form part with the specified key using bodyBuilder for it's body.

fun FormBuilder.append(key: String, filename: String, contentType: ContentType? = null, size: Long? = null, bodyBuilder: BytePacketBuilder.() -> Unit)

Append a form part with the specified key, filename and optional contentType using bodyBuilder for it's body.

Link copied to clipboard
fun formData(vararg values: FormPart<*>): List<PartData>

Build multipart form from values.

fun formData(block: FormBuilder.() -> Unit): List<PartData>

Build multipart form using block function.

Link copied to clipboard
inline suspend fun <T> HttpClient.submitForm(formParameters: Parameters = Parameters.Empty, encodeInQuery: Boolean = false, block: HttpRequestBuilder.() -> Unit = {}): T
inline suspend fun <T> HttpClient.submitForm(url: String, formParameters: Parameters = Parameters.Empty, encodeInQuery: Boolean = false, block: HttpRequestBuilder.() -> Unit = {}): T
inline suspend fun <T> HttpClient.submitForm(scheme: String = "http", host: String = "localhost", port: Int = 80, path: String = "/", formParameters: Parameters = Parameters.Empty, encodeInQuery: Boolean = false, block: HttpRequestBuilder.() -> Unit = {}): T

Submit formParameters request.

Link copied to clipboard
inline suspend fun <T> HttpClient.submitFormWithBinaryData(formData: List<PartData>, block: HttpRequestBuilder.() -> Unit = {}): T
inline suspend fun <T> HttpClient.submitFormWithBinaryData(scheme: String = "http", host: String = "localhost", port: Int = 80, path: String = "/", formData: List<PartData> = emptyList(), block: HttpRequestBuilder.() -> Unit = {}): T

Send HttpMethod.Post request with formData encoded in body. formData encoded using multipart/form-data format. https://tools.ietf.org/html/rfc2045

inline suspend fun <T> HttpClient.submitFormWithBinaryData(url: String, formData: List<PartData>, block: HttpRequestBuilder.() -> Unit = {}): T

Send HttpMethod.Post request with formData encoded in body. url destination formData encoded using multipart/form-data format.