http4k / org.http4k.core / Request


interface Request : HttpMessage (source)


Name Summary
method abstract val method: Method
uri abstract val uri: Uri

Inherited Properties

Name Summary
body abstract val body: Body
headers abstract val headers: Headers
version abstract val version: String


Name Summary
body abstract fun body(body: Body): Request
abstract fun body(body: String): Request
abstract fun body(body: InputStream, length: Long?): Request
(Copy &) sets the body content.
header abstract fun header(name: String, value: String?): Request
(Copy &) Adds a header value with this name.
headers abstract fun headers(headers: Headers): Request
(Copy &) Add all passed headers.
method abstract fun method(method: Method): Request
(Copy &) sets the method.
queries abstract fun queries(name: String): List<String?>
Retrieves all query values with this name.
query abstract fun query(name: String, value: String): Request
(Copy &) Adds a query value with this name.abstract fun query(name: String): String?
Retrieves the first query value with this name.
removeHeader abstract fun removeHeader(name: String): Request
(Copy &) remove headers with this name.
removeQuery abstract fun removeQuery(name: String): Request
(Copy &) remove queries with this name.
replaceHeader abstract fun replaceHeader(name: String, value: String?): Request
(Copy &) Adds a header value with this name, replacing any previously set values.
toMessage open fun toMessage(): String
Returns a formatted wire representation of this message.
uri abstract fun uri(uri: Uri): Request
(Copy &) sets the Uri.

Inherited Functions

Name Summary
bodyString open fun bodyString(): String
This will realise any underlying stream.
close open fun close(): Unit
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.
header open fun header(name: String): String?
Retrieves the first header value with this name.
headerValues open fun headerValues(name: String): List<String?>
Retrieves all header values with this name.

Companion Object Functions

Name Summary
invoke operator fun invoke(method: Method, uri: Uri, version: String = HTTP_1_1): Request
operator fun invoke(method: Method, uri: String, version: String = HTTP_1_1): Request
operator fun invoke(method: Method, template: UriTemplate, version: String = HTTP_1_1): Request

Extension Functions

Name Summary
cookie fun Request.cookie(name: String, value: String): Request
fun Request.cookie(new: Cookie): Request
fun Request.cookie(name: String): Cookie?
cookies fun Request.cookies(): List<Cookie>
form fun Request.form(name: String): String?
Returns the first form parameter with name.fun Request.form(): Form
fun Request.form(name: String, value: String): Request
formAsMap fun Request.formAsMap(): Map<String, List<String?>>
multipartIterator fun HttpMessage.multipartIterator(): Iterator<MultipartEntity>
path fun Request.path(name: String): String?
removeCookie fun Request.removeCookie(name: String): Request
toCurl fun Request.toCurl(truncateBodyLength: Int = 256): String
with fun <T> T.with(vararg modifiers: (T) -> T): T

Companion Object Extension Functions

Name Summary
parse fun Request.Companion.parse(request: String): Request


Name Summary
MemoryRequest data class MemoryRequest : Request
RoutedRequest data class RoutedRequest : Request