api

http4k / org.http4k.core / Request

Request

interface Request : HttpMessage

Properties

Name Summary
method abstract val method: Method
source abstract val source: RequestSource?
uri abstract val uri: Uri

Functions

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

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
alphabetiseHeaders fun <T : HttpMessage> T.alphabetiseHeaders(): T
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 Returns the first form parameter with name.fun Request.form(name: String): String?fun Request.form(): Form
fun Request.form(name: String, value: String): Request
formAsMap fun Request.formAsMap(): Map<String, List<String?>>
fragmentParameter Retrieves the first fragment parameter value with this name.fun Request.fragmentParameter(name: String): String?
(Copy &) Adds a query value with this name.fun Request.fragmentParameter(name: String, value: String?): Request
fragmentParameters Retrieves all fragment parameters with this name.fun Request.fragmentParameters(name: String): List<String?>
multipartIterator fun HttpMessage.multipartIterator(): Iterator<MultipartEntity>
path fun Request.path(name: String): String?
removeCookie fun Request.removeCookie(name: String): Request
shouldHaveBody infix fun HttpMessage.shouldHaveBody(expected: Matcher<Body>): Unit
infix fun HttpMessage.shouldHaveBody(expected: Matcher<String?>): Unit
infix fun HttpMessage.shouldHaveBody(expected: String): Unit
infix fun HttpMessage.shouldHaveBody(expected: Regex): Unit
fun <T> HttpMessage.shouldHaveBody(lens: BodyLens<T>, matcher: Matcher<T>): Unit
shouldHaveContentType infix fun HttpMessage.shouldHaveContentType(expected: ContentType): Unit
shouldHaveCookie infix fun Request.shouldHaveCookie(expected: Cookie): Unit
fun Request.shouldHaveCookie(name: String, expected: Regex): Unit
fun Request.shouldHaveCookie(name: String, expected: String): Unit
fun Request.shouldHaveCookie(name: String, match: Matcher<Cookie>): Unit
shouldHaveForm fun Request.shouldHaveForm(name: String, matcher: Matcher<String?>): Unit
fun Request.shouldHaveForm(name: String, matcher: Regex): Unit
fun Request.shouldHaveForm(name: String, expected: CharSequence): Unit
shouldHaveHeader fun <T> HttpMessage.shouldHaveHeader(lens: HeaderLens<T>, matcher: Matcher<T>): Unit
fun HttpMessage.shouldHaveHeader(name: String, matcher: Matcher<String>): Unit
fun HttpMessage.shouldHaveHeader(name: String, expected: String): Unit
fun HttpMessage.shouldHaveHeader(name: String, expected: Regex): Unit
infix fun HttpMessage.shouldHaveHeader(name: String): Unit
fun HttpMessage.shouldHaveHeader(name: String, expected: List<String?>): Unit
shouldHaveMethod infix fun Request.shouldHaveMethod(expected: Method): Unit
shouldHaveQuery fun <T> Request.shouldHaveQuery(lens: QueryLens<T>, matcher: Matcher<T>): Unit
fun Request.shouldHaveQuery(name: String, matcher: Matcher<String?>): Unit
fun Request.shouldHaveQuery(name: String, expected: CharSequence): Unit
fun Request.shouldHaveQuery(name: String, expected: Regex): Unit
fun Request.shouldHaveQuery(name: String, expected: List<String?>): Unit
shouldHaveUri infix fun Request.shouldHaveUri(expected: Regex): Unit
infix fun Request.shouldHaveUri(expected: Uri): Unit
infix fun Request.shouldHaveUri(expected: String): Unit
infix fun Request.shouldHaveUri(match: Matcher<Uri>): Unit
shouldNotHaveBody infix fun HttpMessage.shouldNotHaveBody(expected: Matcher<Body>): Unit
infix fun HttpMessage.shouldNotHaveBody(expected: Matcher<String?>): Unit
infix fun HttpMessage.shouldNotHaveBody(expected: String): Unit
infix fun HttpMessage.shouldNotHaveBody(expected: Regex): Unit
fun <T> HttpMessage.shouldNotHaveBody(lens: BodyLens<T>, matcher: Matcher<T>): Unit
shouldNotHaveContentType infix fun HttpMessage.shouldNotHaveContentType(expected: ContentType): Unit
shouldNotHaveCookie infix fun Request.shouldNotHaveCookie(expected: Cookie): Unit
fun Request.shouldNotHaveCookie(name: String, expected: Regex): Unit
fun Request.shouldNotHaveCookie(name: String, expected: String): Unit
fun Request.shouldNotHaveCookie(name: String, match: Matcher<Cookie>): Unit
shouldNotHaveForm fun Request.shouldNotHaveForm(name: String, matcher: Matcher<String?>): Unit
fun Request.shouldNotHaveForm(name: String, matcher: Regex): Unit
fun Request.shouldNotHaveForm(name: String, expected: CharSequence): Unit
shouldNotHaveHeader fun <T> HttpMessage.shouldNotHaveHeader(lens: HeaderLens<T>, matcher: Matcher<T>): Unit
fun HttpMessage.shouldNotHaveHeader(name: String, matcher: Matcher<String>): Unit
fun HttpMessage.shouldNotHaveHeader(name: String, expected: String): Unit
fun HttpMessage.shouldNotHaveHeader(name: String, expected: Regex): Unit
infix fun HttpMessage.shouldNotHaveHeader(name: String): Unit
fun HttpMessage.shouldNotHaveHeader(name: String, expected: List<String?>): Unit
shouldNotHaveMethod infix fun Request.shouldNotHaveMethod(expected: Method): Unit
shouldNotHaveQuery fun <T> Request.shouldNotHaveQuery(lens: QueryLens<T>, matcher: Matcher<T>): Unit
fun Request.shouldNotHaveQuery(name: String, matcher: Matcher<String?>): Unit
fun Request.shouldNotHaveQuery(name: String, expected: CharSequence): Unit
fun Request.shouldNotHaveQuery(name: String, expected: Regex): Unit
fun Request.shouldNotHaveQuery(name: String, expected: List<String?>): Unit
shouldNotHaveUri infix fun Request.shouldNotHaveUri(expected: Regex): Unit
infix fun Request.shouldNotHaveUri(expected: Uri): Unit
infix fun Request.shouldNotHaveUri(expected: String): Unit
infix fun Request.shouldNotHaveUri(match: Matcher<Uri>): Unit
toCurl fun Request.toCurl(truncateBodyLength: Int = 256): String
with fun <T : HttpMessage> T.with(vararg modifiers: (T) -> T): T

Companion Object Extension Functions

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

Inheritors

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