Package io.ktor.client.request.forms

Types

FormBuilder

class FormBuilder

Form builder type used in formData builder function.

FormDataContent

class FormDataContent : ByteArrayContent

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

FormPart

data class FormPart<T : Any>

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

InputProvider

class InputProvider

Reusable Input form entry.

MultiPartFormDataContent

class MultiPartFormDataContent : WriteChannelContent

OutgoingContent for multipart/form-data formatted request.

Functions

append

fun FormBuilder.append(
    key: String,
    headers: Headers = Headers.Empty,
    size: Long? = null,
    bodyBuilder: BytePacketBuilder.() -> Unit
): 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
): Unit

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

formData

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.

submitForm

suspend fun <T> HttpClient.submitForm(
    formParameters: Parameters = Parameters.Empty,
    encodeInQuery: Boolean = false,
    block: HttpRequestBuilder.() -> Unit = {}
): T
suspend fun <T> HttpClient.submitForm(
    url: String,
    formParameters: Parameters = Parameters.Empty,
    encodeInQuery: Boolean = false,
    block: HttpRequestBuilder.() -> Unit = {}
): T
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.

submitFormWithBinaryData

suspend fun <T> HttpClient.submitFormWithBinaryData(
    formData: List<PartData>,
    block: HttpRequestBuilder.() -> Unit = {}
): T
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

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.