Package-level declarations

Types

Link copied to clipboard
fun interface Authorization
Link copied to clipboard
class CustomHttpRequestBuilder(method: HttpMethod, other: HttpRequest.Builder = newBuilder().method(method.name, noBody())) : HttpRequest.Builder

A class that builds HTTP requests with custom features like query parameters and authorization.

Link copied to clipboard
Link copied to clipboard
data class ServerSentEvent(val id: String? = null, val event: String? = null, val data: List<String>, val comments: List<String> = listOf())

Properties

Link copied to clipboard
val discarding: HttpResponse.BodyHandler<Void>

This is a BodyHandler that discards the HTTP response body.

Link copied to clipboard
val ofByteArray: HttpResponse.BodyHandler<ByteArray>

This is a BodyHandler that handles HTTP response bodies as a ByteArray.

Link copied to clipboard
val ofByteArrayFlow: HttpResponse.BodyHandler<Flow<ByteArray>>

This is a BodyHandler that handles HTTP response bodies as a Flow of ByteArray.

Link copied to clipboard
val ofFlow: HttpResponse.BodyHandler<Flow<ByteBuffer>>

This is a BodyHandler that handles HTTP response bodies as a Flow of ByteBuffer.

Link copied to clipboard
val ofLines: HttpResponse.BodyHandler<Flow<String>>

This is a BodyHandler that handles HTTP response bodies as a Flow of Strings, where each string is a line from the response.

Link copied to clipboard
val ofServerSentEventFlow: HttpResponse.BodyHandler<Flow<ServerSentEvent>>

This is a BodyHandler that parses the HTTP response into ServerSentEvent objects.

Link copied to clipboard
val ofString: HttpResponse.BodyHandler<String>

This is a BodyHandler that handles HTTP response bodies as a String.

Link copied to clipboard
val ofStringFlow: HttpResponse.BodyHandler<Flow<String>>

This is a BodyHandler that handles HTTP response bodies as a Flow of String.

Functions

Link copied to clipboard
fun <T> HttpResponse<Flow.Publisher<T>>.bodyAsFlow(): Flow<T>

Converts the body of this HTTP response into a Flow.

Link copied to clipboard
suspend fun <T> HttpClient.coSend(request: HttpRequest, bodyHandler: HttpResponse.BodyHandler<T>): HttpResponse<T>
suspend fun <T> HttpClient.coSend(bodyHandler: HttpResponse.BodyHandler<T>, request: suspend () -> HttpRequest): HttpResponse<T>

Sends an HTTP request and returns the HTTP response.

suspend fun <T> HttpRequest.coSend(bodyHandler: HttpResponse.BodyHandler<T>, client: HttpClient = DefaultHttpClient): HttpResponse<T>

Sends this HTTP request and returns the HTTP response.

Link copied to clipboard
inline fun delete(url: String, f: CustomHttpRequestBuilder.() -> Unit = {}): HttpRequest

Creates an HTTP DELETE request to the specified URL.

Link copied to clipboard
inline fun get(url: String, f: CustomHttpRequestBuilder.() -> Unit = {}): HttpRequest

Creates an HTTP GET request to the specified URL.

Link copied to clipboard
inline fun head(url: String, f: CustomHttpRequestBuilder.() -> Unit = {}): HttpRequest

Creates an HTTP HEAD request to the specified URL.

Link copied to clipboard
fun <T, R> HttpResponse.BodyHandler<T>.map(f: (T) -> R): HttpResponse.BodyHandler<R>

This function allows to create a new BodyHandler by transforming the output of the current BodyHandler.

Link copied to clipboard
inline fun options(url: String, f: CustomHttpRequestBuilder.() -> Unit = {}): HttpRequest

Creates an HTTP OPTIONS request to the specified URL.

Link copied to clipboard

parseAsServerSentEvents parses pieces of string in a stream fashion manner into ServerSentEvent objects. It splits & chunks the flow using the "\n\n" delimiter, which separates different server-sent events in a stream. Once the event is properly parsed, a ServerSentEvent is created and emitted downstream

Link copied to clipboard
inline fun patch(url: String, f: CustomHttpRequestBuilder.() -> Unit = {}): HttpRequest

Creates an HTTP PATCH request to the specified URL.

Link copied to clipboard
inline fun post(url: String, f: CustomHttpRequestBuilder.() -> Unit = {}): HttpRequest

Creates an HTTP POST request to the specified URL.

Link copied to clipboard
inline fun put(url: String, f: CustomHttpRequestBuilder.() -> Unit = {}): HttpRequest

Creates an HTTP PUT request to the specified URL.

Link copied to clipboard
inline fun request(uri: URI, method: HttpMethod, f: CustomHttpRequestBuilder.() -> Unit = {}): HttpRequest
inline fun request(uri: String, method: HttpMethod, f: CustomHttpRequestBuilder.() -> Unit = {}): HttpRequest

Creates an HTTP request of the given method type to the specified URL.

Link copied to clipboard
fun <T> Flow<HttpRequest>.sendAndHandle(bodyHandler: HttpResponse.BodyHandler<T>, concurrency: Int = 1, httpClient: HttpClient = DefaultHttpClient): Flow<HttpResponse<T>>
fun <T> Flow<HttpRequest>.sendAndHandle(concurrency: Int = 1, httpClient: HttpClient = DefaultHttpClient, handle: CoroutineScope.() -> HttpResponse.BodyHandler<T>): Flow<HttpResponse<T>>

Sends each HTTP request in the flow and returns a flow of the HTTP responses.