Package io.ktor.client.request

Types

Link copied to clipboard
abstract class ClientUpgradeContent : OutgoingContent.NoContent
Link copied to clipboard
open class DefaultHttpRequest(call: HttpClientCall, data: HttpRequestData) : HttpRequest

Default HttpRequest implementation.

Link copied to clipboard
interface HttpRequest : HttpMessage, CoroutineScope

A request for HttpClient, first part of HttpClientCall.

Link copied to clipboard
class HttpRequestBuilder : HttpMessageBuilder

Class for building HttpRequestData.

Link copied to clipboard
class HttpRequestData constructor(url: Url, method: HttpMethod, headers: Headers, body: OutgoingContent, executionContext: Job, attributes: Attributes)

Actual data of the HttpRequest, including url, method, headers, body and executionContext. Built by HttpRequestBuilder.

Link copied to clipboard
class HttpRequestPipeline(developmentMode: Boolean) : Pipeline<Any, HttpRequestBuilder>

HttpClient Pipeline used for executing HttpRequest.

Link copied to clipboard
class HttpResponseData(statusCode: HttpStatusCode, requestTime: GMTDate, headers: Headers, version: HttpProtocolVersion, body: Any, callContext: CoroutineContext)

Data prepared for HttpResponse.

Link copied to clipboard
class HttpSendPipeline(developmentMode: Boolean) : Pipeline<Any, HttpRequestBuilder>

HttpClient Pipeline used for sending HttpRequest to remote server.

Functions

Link copied to clipboard
fun HttpRequestBuilder.accept(contentType: ContentType)

Sets the Accept header with a specific contentType.

Link copied to clipboard
fun HttpRequestBuilder.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())

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

Link copied to clipboard
inline suspend fun <T> HttpClient.delete(builder: HttpRequestBuilder): T

Executes a HttpClient DELETE request, with the information from the builder and tries to receive a specific type T, if fails, an exception is thrown.

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

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

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

Executes a HttpClient DELETE request, with the specified url as URL and an optional block receiving an HttpRequestBuilder for further configuring the request.

inline suspend fun <T> HttpClient.delete(scheme: String = "http", host: String = "localhost", port: Int = DEFAULT_PORT, path: String = "/", body: Any = EmptyContent, block: HttpRequestBuilder.() -> Unit = {}): T

Executes a HttpClient DELETE request, with the specified scheme, host, port, path and body. And allows to further configure the request, using a block receiving an HttpRequestBuilder.

inline suspend fun <T> HttpClient.delete(url: URL, block: HttpRequestBuilder.() -> Unit = {}): T

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

Link copied to clipboard
inline suspend fun <T> HttpClient.get(builder: HttpRequestBuilder): T

Executes a HttpClient GET request, with the information from the builder and tries to receive a specific type T, if fails, an exception is thrown.

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

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

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

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

inline suspend fun <T> HttpClient.get(scheme: String = "http", host: String = "localhost", port: Int = DEFAULT_PORT, path: String = "/", body: Any = EmptyContent, block: HttpRequestBuilder.() -> Unit = {}): T

Executes a HttpClient GET request, with the specified scheme, host, port, path and body. And allows to further configure the request, using a block receiving an HttpRequestBuilder.

inline suspend fun <T> HttpClient.get(url: URL, block: HttpRequestBuilder.() -> Unit = {}): T

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

Link copied to clipboard
inline suspend fun <T> HttpClient.head(builder: HttpRequestBuilder): T

Executes a HttpClient HEAD request, with the information from the builder and tries to receive a specific type T, if fails, an exception is thrown.

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

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

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

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

inline suspend fun <T> HttpClient.head(scheme: String = "http", host: String = "localhost", port: Int = DEFAULT_PORT, path: String = "/", body: Any = EmptyContent, block: HttpRequestBuilder.() -> Unit = {}): T

Executes a HttpClient HEAD request, with the specified scheme, host, port, path and body. And allows to further configure the request, using a block receiving an HttpRequestBuilder.

inline suspend fun <T> HttpClient.head(url: URL, block: HttpRequestBuilder.() -> Unit = {}): T

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

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

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

Link copied to clipboard
fun HttpRequestBuilder.headers(block: HeadersBuilder.() -> Unit): HeadersBuilder

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

Link copied to clipboard
operator fun HttpRequestBuilder.Companion.invoke(block: URLBuilder.() -> Unit): HttpRequestBuilder

Executes a block that configures the URLBuilder associated to thisrequest.

operator fun HttpRequestBuilder.Companion.invoke(scheme: String = "http", host: String = "localhost", port: Int = DEFAULT_PORT, path: String = "/", block: URLBuilder.() -> Unit = {}): HttpRequestBuilder

Constructs a HttpRequestBuilder from URL information: scheme, host, port and path and optionally further configures it using block.

operator fun HttpRequestBuilder.Companion.invoke(url: URL): HttpRequestBuilder

Constructs a HttpRequestBuilder from url.

Link copied to clipboard
fun HttpRequestData.isUpgradeRequest(): Boolean
Link copied to clipboard
inline suspend fun <T> HttpClient.options(builder: HttpRequestBuilder): T

Executes a HttpClient OPTIONS request, with the information from the builder and tries to receive a specific type T, if fails, an exception is thrown.

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

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

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

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

inline suspend fun <T> HttpClient.options(scheme: String = "http", host: String = "localhost", port: Int = DEFAULT_PORT, path: String = "/", body: Any = EmptyContent, block: HttpRequestBuilder.() -> Unit = {}): T

Executes a HttpClient OPTIONS request, with the specified scheme, host, port, path and body. And allows to further configure the request, using a block receiving an HttpRequestBuilder.

inline suspend fun <T> HttpClient.options(url: URL, block: HttpRequestBuilder.() -> Unit = {}): T

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

Link copied to clipboard
fun HttpRequestBuilder.parameter(key: String, value: Any?)

Sets 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
inline suspend fun <T> HttpClient.patch(builder: HttpRequestBuilder): T

Executes a HttpClient PATCH request, with the information from the builder and tries to receive a specific type T, if fails, an exception is thrown.

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

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

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

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

inline suspend fun <T> HttpClient.patch(scheme: String = "http", host: String = "localhost", port: Int = DEFAULT_PORT, path: String = "/", body: Any = EmptyContent, block: HttpRequestBuilder.() -> Unit = {}): T

Executes a HttpClient PATCH request, with the specified scheme, host, port, path and body. And allows to further configure the request, using a block receiving an HttpRequestBuilder.

inline suspend fun <T> HttpClient.patch(url: URL, block: HttpRequestBuilder.() -> Unit = {}): T

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

Link copied to clipboard
inline suspend fun <T> HttpClient.post(builder: HttpRequestBuilder): T

Executes a HttpClient POST request, with the information from the builder and tries to receive a specific type T, if fails, an exception is thrown.

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

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

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

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

inline suspend fun <T> HttpClient.post(scheme: String = "http", host: String = "localhost", port: Int = DEFAULT_PORT, path: String = "/", body: Any = EmptyContent, block: HttpRequestBuilder.() -> Unit = {}): T

Executes a HttpClient POST request, with the specified scheme, host, port, path and body. And allows to further configure the request, using a block receiving an HttpRequestBuilder.

inline suspend fun <T> HttpClient.post(url: URL, block: HttpRequestBuilder.() -> Unit = {}): T

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

Link copied to clipboard
inline suspend fun <T> HttpClient.put(builder: HttpRequestBuilder): T

Executes a HttpClient PUT request, with the information from the builder and tries to receive a specific type T, if fails, an exception is thrown.

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

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

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

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

inline suspend fun <T> HttpClient.put(scheme: String = "http", host: String = "localhost", port: Int = DEFAULT_PORT, path: String = "/", body: Any = EmptyContent, block: HttpRequestBuilder.() -> Unit = {}): T

Executes a HttpClient PUT request, with the specified scheme, host, port, path and body. And allows to further configure the request, using a block receiving an HttpRequestBuilder.

inline suspend fun <T> HttpClient.put(url: URL, block: HttpRequestBuilder.() -> Unit = {}): T

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

Link copied to clipboard
fun request(block: HttpRequestBuilder.() -> Unit): HttpRequestBuilder

Creates a HttpRequestBuilder and configures it with a block of code.

inline suspend fun <T> HttpClient.request(builder: HttpRequestBuilder = HttpRequestBuilder()): T

Executes a HttpClient request, with the information from the builder and tries to receive a specific type T, if fails, an exception is thrown.

inline suspend fun <T> HttpClient.request(block: HttpRequestBuilder.() -> Unit): T

Executes a HttpClient request, with the information configured in builder block and tries to receive a specific type T, if fails, an exception is thrown.

inline suspend fun <T> HttpClient.request(url: Url, block: HttpRequestBuilder.() -> Unit = {}): T

Executes a HttpClient request, with the url and the information configured in builder block and tries to receive a specific type T, if fails, an exception is thrown.

inline suspend fun <T> HttpClient.request(urlString: String, block: HttpRequestBuilder.() -> Unit = {}): T

Executes a HttpClient request, with the urlString and the information configured in builder block and tries to receive a specific type T, if fails, an exception is thrown.

inline suspend fun <T> HttpClient.request(url: URL, block: HttpRequestBuilder.() -> Unit = {}): T

Executes a HttpClient request, with the specified url as URL and an optional block receiving an HttpRequestBuilder for further configuring the request.

Link copied to clipboard
fun HttpRequestBuilder.takeFrom(request: HttpRequest): HttpRequestBuilder

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

fun HttpRequestBuilder.takeFrom(request: HttpRequestData): HttpRequestBuilder
Link copied to clipboard
fun HttpRequestBuilder.url(url: Url)
fun HttpRequestBuilder.url(block: URLBuilder.() -> Unit)

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

fun HttpRequestBuilder.url(urlString: String)
fun HttpRequestBuilder.url(scheme: String = "http", host: String = "localhost", port: Int = DEFAULT_PORT, path: String = "/", block: URLBuilder.() -> Unit = {})

Sets the url using the specified scheme, host, port and path.

fun HttpRequestBuilder.url(url: URL): URLBuilder

Properties

Link copied to clipboard
var HttpRequestBuilder.host: String

Gets the associated URL's host.

Link copied to clipboard
var HttpRequestBuilder.port: Int

Gets the associated URL's port.