MemoryRequest

data class MemoryRequest(val method: Method, val uri: Uri, val headers: Headers = listOf(), val body: Body = EMPTY, val version: String = HTTP_1_1, val source: RequestSource? = null) : Request

Constructors

Link copied to clipboard
constructor(method: Method, uri: Uri, headers: Headers = listOf(), body: Body = EMPTY, version: String = HTTP_1_1, source: RequestSource? = null)

Properties

Link copied to clipboard
open override val body: Body
Link copied to clipboard
open override val headers: Headers
Link copied to clipboard
open override val method: Method
Link copied to clipboard
open override val source: RequestSource? = null
Link copied to clipboard
open override val uri: Uri
Link copied to clipboard
open override val version: String

Functions

Link copied to clipboard
Link copied to clipboard
fun Request.bearerAuth(token: String, scheme: String = "Bearer"): Request
Link copied to clipboard
Link copied to clipboard
open override fun body(body: String): MemoryRequest
open override fun body(body: Body): MemoryRequest
open override fun body(body: InputStream, length: Long?): MemoryRequest

(Copy &) sets the body content.

Link copied to clipboard
open fun bodyString(): String

This will realise any underlying stream.

Link copied to clipboard
open override fun close()

Closes the request. For server generated messages, this is called by all backend/client implementations, but when consuming external responses in streaming mode, this should be used.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
Link copied to clipboard
fun Request.form(vararg formData: Pair<String, String?>): Request
fun Request.form(name: String, value: String?): Request

fun Request.form(name: String): String?

Returns the first form parameter with name.

Link copied to clipboard
Link copied to clipboard
open fun header(name: String): String?

Retrieves the first header value with this name.

open override fun header(name: String, value: String?): MemoryRequest

(Copy &) Adds a header value with this name.

Link copied to clipboard
open override fun headers(headers: Headers): MemoryRequest

(Copy &) Add all passed headers.

Link copied to clipboard
open fun headerValues(name: String): List<String?>

Retrieves all header values with this name.

Link copied to clipboard
open override fun method(method: Method): Request

(Copy &) sets the method.

Link copied to clipboard
fun Request.path(name: String): String?
Link copied to clipboard
open override fun queries(name: String): List<String?>

Retrieves all query values with this name.

Link copied to clipboard
open override fun query(name: String): String?

Retrieves the first query value with this name.

open override fun query(name: String, value: String?): MemoryRequest

(Copy &) Adds a query value with this name.

Link copied to clipboard
Link copied to clipboard
open override fun removeHeader(name: String): MemoryRequest

(Copy &) remove headers with this name.

Link copied to clipboard
open override fun removeHeaders(prefix: String): MemoryRequest

(Copy &) remove headers with this prefix. Default removes all headers.

Link copied to clipboard
open override fun removeQueries(prefix: String): MemoryRequest

(Copy &) remove queries with this prefix. Default removes all queries.

Link copied to clipboard
open override fun removeQuery(name: String): MemoryRequest

(Copy &) remove queries with this name.

Link copied to clipboard
open override fun replaceHeader(name: String, value: String?): MemoryRequest

(Copy &) Adds a header value with this name, replacing any previously set values.

Link copied to clipboard
open override fun replaceHeaders(source: Headers): MemoryRequest

Replace all headers with ones passed.

Link copied to clipboard
open override fun source(source: RequestSource): MemoryRequest

(Copy &) sets request source.

Link copied to clipboard
fun Request.toCurl(truncateBodyLength: Int = 256): String
Link copied to clipboard
open override fun toMessage(): String

Returns a formatted wire representation of this message.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
open override fun uri(uri: Uri): MemoryRequest

(Copy &) sets the Uri.

Link copied to clipboard
fun Request.withBasicAuth(credentials: Credentials, header: String = "Authorization"): Request
Link copied to clipboard