HttpClient

class HttpClient(val engine: HttpClientEngine, userConfig: HttpClientConfig<out HttpClientEngineConfig> = HttpClientConfig()) : CoroutineScope, Closeable

A multiplatform asynchronous HTTP client that allows you to make requests, handle responses, and extend its functionality with plugins such as authentication, JSON serialization, and more.

Creating client

To create a new client, you can call:

val client = HttpClient()

You can create as many clients as you need.

If you no longer need the client, please consider closing it to release resources:

client.close()

To learn more on how to create and configure an HttpClient see the tutorial page: Creating and configuring a client.

Making API Requests

For every HTTP method (GET, POST, PUT, etc.), there is a corresponding function:

val response: HttpResponse = client.get("https://ktor.io/")
val body = response.bodyAsText()

See Making HTTP requests for more details.

Query Parameters

Add query parameters to your request using the parameter function:

val response = client.get("https://google.com/search") {
url {
parameter("q", "REST API with Ktor")
}
}

For more information, refer to Passing request parameters.

Adding Headers

Include headers in your request using the headers builder or the header function:

val response = client.get("https://httpbin.org/bearer") {
headers {
append("Authorization", "Bearer your_token_here")
append("Accept", "application/json")
}
}

Learn more at Adding headers to a request.

JSON Serialization

Add dependencies:

  • io.ktor:ktor-client-content-negotiation:3.+

  • io.ktor:ktor-serialization-kotlinx-json:3.+ Add Gradle plugin:

plugins {
kotlin("plugin.serialization")
}

Send and receive JSON data by installing the ContentNegotiation plugin with kotlinx.serialization:

val client = HttpClient {
install(ContentNegotiation) {
json()
}
}

@Serializable
data class MyRequestType(val someData: String)

@Serializable
data class MyResponseType(val someResponseData: String)

val response: MyResponseType = client.post("https://api.example.com/data") {
contentType(ContentType.Application.Json)
setBody(MyRequestType(someData = "value"))
}.body()

See Serializing JSON data for maven configuration and other details.

Submitting Forms

Submit form data using FormDataContent or the submitForm function:

// Using FormDataContent
val response = client.post("https://example.com/submit") {
setBody(FormDataContent(Parameters.build {
append("username", "user")
append("password", "pass")
}))
}

// Or using submitForm
val response = client.submitForm(
url = "https://example.com/submit",
formParameters = Parameters.build {
append("username", "user")
append("password", "pass")
}
)

More information is available at Submitting form parameters.

Handling Authentication

Add dependency: io.ktor:ktor-client-auth:3.+

Use the Auth plugin to handle various authentication schemes like Basic or Bearer token authentication:

val client = HttpClient {
install(Auth) {
bearer {
loadTokens {
BearerTokens(accessToken = "your_access_token", refreshToken = "your_refresh_token")
}
}
}
}

val response = client.get("https://api.example.com/protected")

Refer to Client authentication for more details.

Setting Timeouts and Retries

Configure timeouts and implement retry logic for your requests:

val client = HttpClient {
install(HttpTimeout) {
requestTimeoutMillis = 10000
connectTimeoutMillis = 5000
socketTimeoutMillis = 15000
}
}

For the request timeout:

client.get("") {
timeout {
requestTimeoutMillis = 1000
}
}

See Timeout for more information.

Handling Cookies

Manage cookies automatically by installing the HttpCookies plugin:

val client = HttpClient {
install(HttpCookies) {
storage = AcceptAllCookiesStorage()
}
}

// Accessing cookies
val cookies: List<Cookie> = client.cookies("https://example.com")

Learn more at Cookies.

Uploading Files

Upload files using multipart/form-data requests:

client.submitFormWithBinaryData(
url = "https://example.com/upload",
formData = formData {
append("description", "File upload example")
append("file", {
File("path/to/file.txt").readChannel()
})
}
)

See [Uploading data](https://ktor.io/docs/client-requests.html#upload_file) for details.

# Using WebSockets

Communicate over WebSockets using the `webSocket` function:
```kotlin
client.webSocket("wss://echo.websocket.org") {
send(Frame.Text("Hello, WebSocket!"))
val frame = incoming.receive()
if (frame is Frame.Text) {
println("Received: ${frame.readText()}")
}
}

Learn more at Client WebSockets.

Error Handling

Handle exceptions and HTTP error responses gracefully: val client = HttpClient { HttpResponseValidator { validateResponse { response -> val statusCode = response.status.value when (statusCode) { in 300..399 -> error("Redirects are not allowed") } } } }

See Error handling for more information.

Configuring SSL/TLS

Customize SSL/TLS settings for secure connections is engine-specific. Please refer to the following page for the details: Client SSL/TLS.

Using Proxies

Route requests through an HTTP or SOCKS proxy:

val client = HttpClient() {
engine {
proxy = ProxyBuilder.http("http://proxy.example.com:8080")
// For a SOCKS proxy:
// proxy = ProxyBuilder.socks(host = "proxy.example.com", port = 1080)
}
}

See Using a proxy for details.

Streaming Data

Stream large data efficiently without loading it entirely into memory.

Stream request:

val response = client.post("https://example.com/upload") {
setBody(object: OutgoingContent.WriteChannelContent() {
override suspend fun writeTo(channel: ByteWriteChannel) {
repeat(1000) {
channel.writeString("Hello!")
}
}
})
}

Stream response:

client.prepareGet("https://example.com/largefile.zip").execute { response ->
val channel: ByteReadChannel = response.bodyAsChannel()

while (!channel.exhausted()) {
val chunk = channel.readBuffer()
// ...
}
}

Learn more at Streaming data.

Using SSE

Server-Sent Events (SSE) is a technology that allows a server to continuously push events to a client over an HTTP connection. It's particularly useful in cases where the server needs to send event-based updates without requiring the client to repeatedly poll the server.

Install the plugin:

val client = HttpClient(CIO) {
install(SSE)
}
client.sse(host = "0.0.0.0", port = 8080, path = "/events") {
while (true) {
for (event in incoming) {
println("Event from server:")
println(event)
}
}
}

Visit Using SSE to learn more.

Customizing a client with plugins

To extend out-of-the-box functionality, you can install plugins for a Ktor client:

val client = HttpClient {
install(ContentNegotiation) {
json()
}
}

There are many plugins available out of the box, and you can write your own. See Create custom client plugins to learn more.

Service Loader and Default Engine

On JVM, calling HttpClient() without specifying an engine uses a service loader mechanism to determine the appropriate default engine. This can introduce a performance overhead, especially on slower devices, such as Android.

Performance Note: If you are targeting platforms where initialization speed is critical, consider explicitly specifying an engine to avoid the service loader lookup.

Example with manual engine specification:

val client = HttpClient(Apache) // Explicitly uses Apache engine, bypassing service loader

By directly setting the engine (e.g., Apache, OkHttp), you can optimize startup performance by preventing the default service loader mechanism.

Constructors

Link copied to clipboard
constructor(engine: HttpClientEngine, userConfig: HttpClientConfig<out HttpClientEngineConfig> = HttpClientConfig())

Properties

Link copied to clipboard

Typed attributes used as a lightweight container for this client.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Provides access to the client's engine configuration.

Link copied to clipboard

Provides access to the events of the client's lifecycle.

Link copied to clipboard

A pipeline used for receiving a request.

Link copied to clipboard

A pipeline used for processing all requests sent by this client.

Link copied to clipboard

A pipeline used for processing all responses sent by the server.

Link copied to clipboard

A pipeline used for sending a request.

Functions

Link copied to clipboard
open override fun close()

Initiates the shutdown process for the HttpClient. This is a non-blocking call, which means it returns immediately and begins the client closure in the background.

Link copied to clipboard
fun config(block: HttpClientConfig<*>.() -> Unit): HttpClient

Returns a new HttpClient by copying this client's configuration and additionally configured by the block parameter.

Link copied to clipboard
suspend fun HttpClient.cookies(url: Url): List<Cookie>

Gets all the cookies for the specified url for this HttpClient.

suspend fun HttpClient.cookies(urlString: String): List<Cookie>

Gets all the cookies for the specified urlString for this HttpClient.

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
inline suspend fun HttpClient.delete(builder: HttpRequestBuilder): HttpResponse

Executes a HttpClient DELETE request with the parameters configured in builder.

inline suspend fun HttpClient.delete(block: HttpRequestBuilder.() -> Unit): HttpResponse

Executes an HttpClient's DELETE request with the parameters configured in block.

inline suspend fun HttpClient.delete(url: Url, block: HttpRequestBuilder.() -> Unit = {}): HttpResponse

Executes a HttpClient HEAD request with the specified url and an optional block receiving an HttpRequestBuilder for configuring the request.

inline suspend fun HttpClient.delete(urlString: String, block: HttpRequestBuilder.() -> Unit = {}): HttpResponse

Executes an HttpClient's DELETE request with the specified url and an optional block receiving an HttpRequestBuilder for configuring the request.

Link copied to clipboard
inline suspend fun HttpClient.get(builder: HttpRequestBuilder): HttpResponse

Executes an HttpClient's GET request with the parameters configured in builder.

inline suspend fun HttpClient.get(block: HttpRequestBuilder.() -> Unit): HttpResponse

Executes an HttpClient's GET request with the parameters configured in block.

inline suspend fun HttpClient.get(url: Url, block: HttpRequestBuilder.() -> Unit = {}): HttpResponse

Executes a HttpClient GET request with the specified url and an optional block receiving an HttpRequestBuilder for configuring the request.

inline suspend fun HttpClient.get(urlString: String, block: HttpRequestBuilder.() -> Unit = {}): HttpResponse

Executes an HttpClient's GET request with the specified url and an optional block receiving an HttpRequestBuilder for configuring the request.

Link copied to clipboard
inline suspend fun HttpClient.head(builder: HttpRequestBuilder): HttpResponse

Executes a HttpClient HEAD request with the parameters configured in builder.

inline suspend fun HttpClient.head(block: HttpRequestBuilder.() -> Unit): HttpResponse

Executes an HttpClient's HEAD request with the parameters configured in block.

inline suspend fun HttpClient.head(url: Url, block: HttpRequestBuilder.() -> Unit = {}): HttpResponse

Executes a HttpClient HEAD request with the specified url and an optional block receiving an HttpRequestBuilder for configuring the request.

inline suspend fun HttpClient.head(urlString: String, block: HttpRequestBuilder.() -> Unit = {}): HttpResponse

Executes an HttpClient's HEAD request with the specified url and an optional block receiving an HttpRequestBuilder for configuring the request.

Link copied to clipboard

Checks if the specified capability is supported by this client.

Link copied to clipboard
inline suspend fun HttpClient.options(builder: HttpRequestBuilder): HttpResponse

Executes a HttpClient OPTIONS request with the parameters configured in builder.

inline suspend fun HttpClient.options(block: HttpRequestBuilder.() -> Unit): HttpResponse

Executes an HttpClient's OPTIONS request with the parameters configured in block.

inline suspend fun HttpClient.options(url: Url, block: HttpRequestBuilder.() -> Unit = {}): HttpResponse

Executes a HttpClient OPTIONS request with the specified url and an optional block receiving an HttpRequestBuilder for configuring the request.

inline suspend fun HttpClient.options(urlString: String, block: HttpRequestBuilder.() -> Unit = {}): HttpResponse

Executes an HttpClient's OPTIONS request with the specified url and an optional block receiving an HttpRequestBuilder for configuring the request.

Link copied to clipboard
inline suspend fun HttpClient.patch(builder: HttpRequestBuilder): HttpResponse

Executes a HttpClient PATCH request with the parameters configured in builder.

inline suspend fun HttpClient.patch(block: HttpRequestBuilder.() -> Unit): HttpResponse

Executes an HttpClient's PATCH request with the parameters configured in block.

inline suspend fun HttpClient.patch(url: Url, block: HttpRequestBuilder.() -> Unit = {}): HttpResponse

Executes a HttpClient PATCH request with the specified url and an optional block receiving an HttpRequestBuilder for configuring the request.

inline suspend fun HttpClient.patch(urlString: String, block: HttpRequestBuilder.() -> Unit = {}): HttpResponse

Executes an HttpClient's PATCH request with the specified url and an optional block receiving an HttpRequestBuilder for configuring the request.

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
inline suspend fun HttpClient.post(builder: HttpRequestBuilder): HttpResponse

Executes an HttpClient's POST request with the parameters configured in builder.

inline suspend fun HttpClient.post(block: HttpRequestBuilder.() -> Unit): HttpResponse

Executes an HttpClient's POST request with the parameters configured in block.

inline suspend fun HttpClient.post(url: Url, block: HttpRequestBuilder.() -> Unit = {}): HttpResponse

Executes a HttpClient POST request with the specified url and an optional block receiving an HttpRequestBuilder for configuring the request.

inline suspend fun HttpClient.post(urlString: String, block: HttpRequestBuilder.() -> Unit = {}): HttpResponse

Executes an HttpClient's POST request with the specified url and an optional block receiving an HttpRequestBuilder for configuring the request.

Link copied to clipboard

Prepares an HttpClient's DELETE request with the parameters configured in builder.

Prepares an HttpClient's DELETE request with the parameters configured in block.

inline suspend fun HttpClient.prepareDelete(url: Url, block: HttpRequestBuilder.() -> Unit = {}): HttpStatement

Prepares a HttpClient HEAD request with the specified url and an optional block receiving an HttpRequestBuilder for configuring the request.

inline suspend fun HttpClient.prepareDelete(urlString: String, block: HttpRequestBuilder.() -> Unit = {}): HttpStatement

Prepares an HttpClient's DELETE request with the specified url and an optional block receiving an HttpRequestBuilder for configuring the request.

Link copied to clipboard
inline suspend fun HttpClient.prepareForm(formParameters: Parameters = Parameters.Empty, encodeInQuery: Boolean = false, block: HttpRequestBuilder.() -> Unit = {}): HttpStatement
suspend fun HttpClient.prepareForm(url: String, formParameters: Parameters = Parameters.Empty, encodeInQuery: Boolean = false, block: HttpRequestBuilder.() -> Unit = {}): HttpStatement

Prepares a request containing form parameters encoded using the x-www-form-urlencoded format.

Link copied to clipboard
inline suspend fun HttpClient.prepareFormWithBinaryData(formData: List<PartData>, crossinline block: HttpRequestBuilder.() -> Unit = {}): HttpStatement
inline suspend fun HttpClient.prepareFormWithBinaryData(url: String, formData: List<PartData>, crossinline block: HttpRequestBuilder.() -> Unit = {}): HttpStatement

Prepares a POST request containing form parameters encoded using the multipart/form-data format.

Link copied to clipboard

Prepares an HttpClient's GET request with the parameters configured in builder.

inline suspend fun HttpClient.prepareGet(block: HttpRequestBuilder.() -> Unit): HttpStatement

Prepares an HttpClient's GET request with the parameters configured in block.

inline suspend fun HttpClient.prepareGet(url: Url, block: HttpRequestBuilder.() -> Unit = {}): HttpStatement

Prepares a HttpClient GET request with the specified url and an optional block receiving an HttpRequestBuilder for configuring the request.

inline suspend fun HttpClient.prepareGet(urlString: String, block: HttpRequestBuilder.() -> Unit = {}): HttpStatement

Prepares an HttpClient's GET request with the specified url and an optional block receiving an HttpRequestBuilder for configuring the request.

Link copied to clipboard

Prepares an HttpClient's HEAD request with the parameters configured in builder.

inline suspend fun HttpClient.prepareHead(block: HttpRequestBuilder.() -> Unit): HttpStatement

Prepares an HttpClient's HEAD request with the parameters configured in block.

inline suspend fun HttpClient.prepareHead(url: Url, block: HttpRequestBuilder.() -> Unit = {}): HttpStatement

Prepares a HttpClient HEAD request with the specified url and an optional block receiving an HttpRequestBuilder for configuring the request.

inline suspend fun HttpClient.prepareHead(urlString: String, block: HttpRequestBuilder.() -> Unit = {}): HttpStatement

Prepares an HttpClient's HEAD request with the specified url and an optional block receiving an HttpRequestBuilder for configuring the request.

Link copied to clipboard

Prepares an HttpClient's OPTIONS request with the parameters configured in builder.

Prepares an HttpClient's OPTIONS request with the parameters configured in block.

inline suspend fun HttpClient.prepareOptions(url: Url, block: HttpRequestBuilder.() -> Unit = {}): HttpStatement

Prepares a HttpClient OPTIONS request with the specified url and an optional block receiving an HttpRequestBuilder for configuring the request.

inline suspend fun HttpClient.prepareOptions(urlString: String, block: HttpRequestBuilder.() -> Unit = {}): HttpStatement

Prepares an HttpClient's OPTIONS request with the specified url and an optional block receiving an HttpRequestBuilder for configuring the request.

Link copied to clipboard

Prepares an HttpClient's PATCH request with the parameters configured in builder.

inline suspend fun HttpClient.preparePatch(block: HttpRequestBuilder.() -> Unit): HttpStatement

Prepares an HttpClient's PATCH request with the parameters configured in block.

inline suspend fun HttpClient.preparePatch(url: Url, block: HttpRequestBuilder.() -> Unit = {}): HttpStatement

Prepares a HttpClient PATCH request with the specified url and an optional block receiving an HttpRequestBuilder for configuring the request.

inline suspend fun HttpClient.preparePatch(urlString: String, block: HttpRequestBuilder.() -> Unit = {}): HttpStatement

Prepares an HttpClient's PATCH request with the specified url and an optional block receiving an HttpRequestBuilder for configuring the request.

Link copied to clipboard

Prepares an HttpClient's POST request with the parameters configured in builder.

inline suspend fun HttpClient.preparePost(block: HttpRequestBuilder.() -> Unit): HttpStatement

Prepares an HttpClient's POST request with the parameters configured in block.

inline suspend fun HttpClient.preparePost(url: Url, block: HttpRequestBuilder.() -> Unit = {}): HttpStatement

Prepares a HttpClient POST request with the specified url and an optional block receiving an HttpRequestBuilder for configuring the request.

inline suspend fun HttpClient.preparePost(urlString: String, block: HttpRequestBuilder.() -> Unit = {}): HttpStatement

Prepares an HttpClient's POST request with the specified url and an optional block receiving an HttpRequestBuilder for configuring the request.

Link copied to clipboard

Prepares an HttpClient's PUT request with the parameters configured in builder.

inline suspend fun HttpClient.preparePut(block: HttpRequestBuilder.() -> Unit): HttpStatement

Prepares an HttpClient's PUT request with the parameters configured in block.

inline suspend fun HttpClient.preparePut(url: Url, block: HttpRequestBuilder.() -> Unit = {}): HttpStatement

Prepares a HttpClient PUT request with the specified url and an optional block receiving an HttpRequestBuilder for configuring the request.

inline suspend fun HttpClient.preparePut(urlString: String, block: HttpRequestBuilder.() -> Unit = {}): HttpStatement

Prepares an HttpClient's PUT request with the specified url and an optional block receiving an HttpRequestBuilder for configuring the request.

Link copied to clipboard
inline suspend fun HttpClient.prepareRequest(builder: HttpRequestBuilder = HttpRequestBuilder()): HttpStatement

Prepares an HttpClient's request with the parameters specified using builder.

Prepares an HttpClient's request with the parameters specified using block.

inline suspend fun HttpClient.prepareRequest(url: Url, block: HttpRequestBuilder.() -> Unit = {}): HttpStatement

Prepares an HttpClient's request with the url and the parameters configured in block.

inline suspend fun HttpClient.prepareRequest(urlString: String, block: HttpRequestBuilder.() -> Unit = {}): HttpStatement

Prepares an HttpClient's request with the urlString and the parameters configured in block.

Link copied to clipboard
inline suspend fun HttpClient.put(builder: HttpRequestBuilder): HttpResponse

Executes a HttpClient PUT request with the parameters configured in builder.

inline suspend fun HttpClient.put(block: HttpRequestBuilder.() -> Unit): HttpResponse

Executes an HttpClient's PUT request with the parameters configured in block.

inline suspend fun HttpClient.put(url: Url, block: HttpRequestBuilder.() -> Unit = {}): HttpResponse

Executes a HttpClient PUT request with the specified url and an optional block receiving an HttpRequestBuilder for configuring the request.

inline suspend fun HttpClient.put(urlString: String, block: HttpRequestBuilder.() -> Unit = {}): HttpResponse

Executes an HttpClient's PUT request with the specified url and an optional block receiving an HttpRequestBuilder for configuring the request.

Link copied to clipboard
inline suspend fun HttpClient.request(builder: HttpRequestBuilder = HttpRequestBuilder()): HttpResponse
inline suspend fun HttpClient.request(block: HttpRequestBuilder.() -> Unit): HttpResponse
inline suspend fun HttpClient.request(url: Url, block: HttpRequestBuilder.() -> Unit = {}): HttpResponse
inline suspend fun HttpClient.request(urlString: String, block: HttpRequestBuilder.() -> Unit = {}): HttpResponse

Executes an HTTP request using the provided HttpRequestBuilder configuration.

Link copied to clipboard
suspend fun HttpClient.serverSentEvents(request: HttpRequestBuilder.() -> Unit, reconnectionTime: Duration? = null, showCommentEvents: Boolean? = null, showRetryEvents: Boolean? = null, block: suspend ClientSSESession.() -> Unit)
suspend fun HttpClient.serverSentEvents(urlString: String, reconnectionTime: Duration? = null, showCommentEvents: Boolean? = null, showRetryEvents: Boolean? = null, request: HttpRequestBuilder.() -> Unit = {}, block: suspend ClientSSESession.() -> Unit)
suspend fun HttpClient.serverSentEvents(scheme: String? = null, host: String? = null, port: Int? = null, path: String? = null, reconnectionTime: Duration? = null, showCommentEvents: Boolean? = null, showRetryEvents: Boolean? = null, request: HttpRequestBuilder.() -> Unit = {}, block: suspend ClientSSESession.() -> Unit)

Opens a block with ClientSSESession.

Link copied to clipboard
suspend fun HttpClient.serverSentEventsSession(reconnectionTime: Duration? = null, showCommentEvents: Boolean? = null, showRetryEvents: Boolean? = null, block: HttpRequestBuilder.() -> Unit): ClientSSESession
suspend fun HttpClient.serverSentEventsSession(urlString: String, reconnectionTime: Duration? = null, showCommentEvents: Boolean? = null, showRetryEvents: Boolean? = null, block: HttpRequestBuilder.() -> Unit = {}): ClientSSESession
suspend fun HttpClient.serverSentEventsSession(scheme: String? = null, host: String? = null, port: Int? = null, path: String? = null, reconnectionTime: Duration? = null, showCommentEvents: Boolean? = null, showRetryEvents: Boolean? = null, block: HttpRequestBuilder.() -> Unit = {}): ClientSSESession
Link copied to clipboard
suspend fun HttpClient.sse(request: HttpRequestBuilder.() -> Unit, reconnectionTime: Duration? = null, showCommentEvents: Boolean? = null, showRetryEvents: Boolean? = null, block: suspend ClientSSESession.() -> Unit)
suspend fun HttpClient.sse(urlString: String, request: HttpRequestBuilder.() -> Unit = {}, reconnectionTime: Duration? = null, showCommentEvents: Boolean? = null, showRetryEvents: Boolean? = null, block: suspend ClientSSESession.() -> Unit)
suspend fun HttpClient.sse(scheme: String? = null, host: String? = null, port: Int? = null, path: String? = null, request: HttpRequestBuilder.() -> Unit = {}, reconnectionTime: Duration? = null, showCommentEvents: Boolean? = null, showRetryEvents: Boolean? = null, block: suspend ClientSSESession.() -> Unit)

Opens a block with ClientSSESession.

Link copied to clipboard
suspend fun HttpClient.sseSession(reconnectionTime: Duration? = null, showCommentEvents: Boolean? = null, showRetryEvents: Boolean? = null, block: HttpRequestBuilder.() -> Unit): ClientSSESession
suspend fun HttpClient.sseSession(urlString: String, reconnectionTime: Duration? = null, showCommentEvents: Boolean? = null, showRetryEvents: Boolean? = null, block: HttpRequestBuilder.() -> Unit = {}): ClientSSESession
suspend fun HttpClient.sseSession(scheme: String? = null, host: String? = null, port: Int? = null, path: String? = null, reconnectionTime: Duration? = null, showCommentEvents: Boolean? = null, showRetryEvents: Boolean? = null, block: HttpRequestBuilder.() -> Unit = {}): ClientSSESession
Link copied to clipboard
inline suspend fun HttpClient.submitForm(formParameters: Parameters = Parameters.Empty, encodeInQuery: Boolean = false, block: HttpRequestBuilder.() -> Unit = {}): HttpResponse
suspend fun HttpClient.submitForm(url: String, formParameters: Parameters = Parameters.Empty, encodeInQuery: Boolean = false, block: HttpRequestBuilder.() -> Unit = {}): HttpResponse

Makes a request containing form parameters encoded using the x-www-form-urlencoded format.

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

Makes a POST request containing form parameters encoded using the multipart/form-data format.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
suspend fun HttpClient.webSocket(request: HttpRequestBuilder.() -> Unit, block: suspend DefaultClientWebSocketSession.() -> Unit)
suspend fun HttpClient.webSocket(urlString: String, request: HttpRequestBuilder.() -> Unit = {}, block: suspend DefaultClientWebSocketSession.() -> Unit)
suspend fun HttpClient.webSocket(method: HttpMethod = HttpMethod.Get, host: String? = null, port: Int? = null, path: String? = null, request: HttpRequestBuilder.() -> Unit = {}, block: suspend DefaultClientWebSocketSession.() -> Unit)
Link copied to clipboard
suspend fun HttpClient.webSocketSession(method: HttpMethod = HttpMethod.Get, host: String? = null, port: Int? = null, path: String? = null, block: HttpRequestBuilder.() -> Unit = {}): DefaultClientWebSocketSession
Link copied to clipboard
suspend fun HttpClient.ws(request: HttpRequestBuilder.() -> Unit, block: suspend DefaultClientWebSocketSession.() -> Unit)
suspend fun HttpClient.ws(urlString: String, request: HttpRequestBuilder.() -> Unit = {}, block: suspend DefaultClientWebSocketSession.() -> Unit)
suspend fun HttpClient.ws(method: HttpMethod = HttpMethod.Get, host: String? = null, port: Int? = null, path: String? = null, request: HttpRequestBuilder.() -> Unit = {}, block: suspend DefaultClientWebSocketSession.() -> Unit)
Link copied to clipboard
suspend fun HttpClient.wss(request: HttpRequestBuilder.() -> Unit, block: suspend DefaultClientWebSocketSession.() -> Unit)
suspend fun HttpClient.wss(urlString: String, request: HttpRequestBuilder.() -> Unit = {}, block: suspend DefaultClientWebSocketSession.() -> Unit)
suspend fun HttpClient.wss(method: HttpMethod = HttpMethod.Get, host: String? = null, port: Int? = null, path: String? = null, request: HttpRequestBuilder.() -> Unit = {}, block: suspend DefaultClientWebSocketSession.() -> Unit)