Package-level declarations

Types

Link copied to clipboard
data class Accept(val contentTypes: List<QualifiedContent>)

See https://www.rfc-editor.org/rfc/rfc9110.html#name-accept

Link copied to clipboard
interface Body : Closeable

If this Body is NOT being returned to the caller (via a Server implementation or otherwise), close() should be called.

Link copied to clipboard

BodyMode represents a choice between working lazily with streams or eagerly storing the body contents in memory.

Link copied to clipboard
value class ContentEncodingName(val value: String)

See https://www.iana.org/assignments/http-parameters/http-parameters.xhtml#content-coding

Link copied to clipboard
data class ContentType(val value: String, val directives: Parameters = emptyList())
Link copied to clipboard
data class Credentials(val user: String, val password: String)
Link copied to clipboard
data class Exactly<T>(val value: T) : SimpleRange<T>
Link copied to clipboard
Link copied to clipboard
typealias Headers = Parameters
Link copied to clipboard
typealias HttpHandler = (request: Request) -> Response
Link copied to clipboard

HttpMessages are designed to be immutable, so any mutation methods return a modified copy of the message.

Link copied to clipboard
data class HttpTransaction(val request: Request, val response: Response, val duration: Duration, val labels: Map<String, String> = defaultLabels(request, response), val start: Instant) : ProtocolTransaction<Response>
Link copied to clipboard
data class MemoryBody(val payload: ByteBuffer) : Body

Represents a body that is backed by an in-memory ByteBuffer. Closing this has no effect.

Link copied to clipboard
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
Link copied to clipboard
data class MemoryResponse(val status: Status, val headers: Headers = listOf(), val body: Body = EMPTY, val version: String = HTTP_1_1) : Response
Link copied to clipboard
enum Method : Enum<Method>
Link copied to clipboard
class MimeTypes
Link copied to clipboard
typealias Parameter = Pair<String, String?>
Link copied to clipboard
Link copied to clipboard
data class PriorityList<T>(val ranges: List<Weighted<T>>)

A weighted list of content ranges of type T.

Link copied to clipboard
Link copied to clipboard
data class QualifiedContent(val content: ContentType, val priority: Double = 1.0)
Link copied to clipboard
interface Request : HttpMessage
Link copied to clipboard
class RequestContext(val id: UUID = UUID.randomUUID())
Link copied to clipboard
class RequestContexts(storeId: String? = null) : Store<RequestContext>

In-memory RequestContext store. Override the storeId to use multiple stores in one app.

Link copied to clipboard
data class RequestSource(val address: String, val port: Int? = 0, val scheme: String? = null)
Link copied to clipboard
interface Response : HttpMessage
Link copied to clipboard
sealed interface SimpleRange<in T>

A SimpleRange is either a value of some type, T, or a wildcard, represented in headers as "*", and matching any value of T. The value is constrained to being represented in HTTP headers by a single token, with no parameters.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
class StreamBody(val stream: InputStream, val length: Long? = null) : Body

Represents a body that is backed by a (lazy) InputStream. Operating with StreamBody has a number of potential gotchas:

Link copied to clipboard
data class Uri(val scheme: String, val userInfo: String, val host: String, val port: Int?, val path: String, val query: String, val fragment: String) : Comparable<Uri>
Link copied to clipboard
data class UriTemplate
Link copied to clipboard
typealias UriValue = AbstractValue<Uri>

Custom values4k extensions.

Link copied to clipboard
open class UriValueFactory<DOMAIN : Value<Uri>>(fn: (Uri) -> DOMAIN, validation: Validation<Uri>? = null) : ValueFactory<DOMAIN, Uri>
Link copied to clipboard
data class Weighted<T>(val range: T, val priority: Double)

A content range (e.g. media type range, language range, etc.) weighted by priority

Link copied to clipboard
data object Wildcard : SimpleRange<Any?>
Link copied to clipboard
data class WwwAuthenticate(val token: String, val contents: Map<String, String>) : Map<String, String>

Properties

Link copied to clipboard

Functions

Link copied to clipboard
Link copied to clipboard
fun Uri.appendToPath(pathToAppend: String?): Uri
Link copied to clipboard
Link copied to clipboard
fun Uri.extend(uri: Uri): Uri
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun <T> SimpleRange<T>.forHeader(valueForHeader: (T) -> String): Pair<String, Map<String, String>>
Link copied to clipboard
fun <T> PriorityList.Companion.fromHeader(s: String, parseValue: (String, HeaderParams) -> T): PriorityList<T>

Parses a PriorityList from a header value.

fun <T> SimpleRange.Companion.fromHeader(s: String, valueFromHeader: (String) -> T): SimpleRange<T>
Link copied to clipboard
fun <K, V> Map<K, List<V>>.getFirst(key: K): V?
Link copied to clipboard

This function works around input streams which report that there is nothing to read when they have never been accessed.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun Request.Companion.parse(request: String, lineBreak: String = ""): Request
fun Response.Companion.parse(response: String, lineBreak: String = ""): Response
Link copied to clipboard

Selects the client's preferred option from a set of options offered by the server, when the range is a SimpleRange

inline fun <Range, Option : Any, OptionId> PriorityList<Range>.preferred(offered: List<Option>, match: (Range, OptionId) -> Boolean, by: (Option) -> OptionId): Option?

Selects the client's preferred option from a set of options offered by the server, matching a priority list against the id of the options.

Link copied to clipboard
fun <T> PriorityList(vararg values: Weighted<T>): PriorityList<T>

Constructs a PriorityList from a fixed set of weighted ranges and ensures it is sorted by descending weight.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
infix fun <T> T.q(q: Double): Weighted<T>

A convenience operator for creating a Weighted programmatically.

Link copied to clipboard
Link copied to clipboard
fun Uri.query(name: String, value: String?): Uri
Link copied to clipboard
Link copied to clipboard
fun Uri.relative(relative: String): Uri
fun Uri.relative(relative: Uri): Uri
Link copied to clipboard
fun Uri.removeQueries(prefix: String = ""): Uri
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun Request.toCurl(truncateBodyLength: Int = 256): String
Link copied to clipboard
fun <T> PriorityList<T>.toHeader(rangeToHeader: (T) -> Pair<String, HeaderParams>): String
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun <T : HttpMessage> T.with(vararg modifiers: (T) -> T): T
fun WebForm.with(vararg modifiers: (WebForm) -> WebForm): WebForm