api

http4k / org.http4k.core / Body

Body

interface Body : Closeable

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

Properties

Name Summary
length Will be null for bodies where it’s impossible to a priori determine - e.g. StreamBodyabstract val length: Long?
payload abstract val payload: ByteBuffer
stream abstract val stream: InputStream

Companion Object Properties

Name Summary
EMPTY val EMPTY: Body

Companion Object Functions

Name Summary
invoke operator fun invoke(body: String): Body
operator fun invoke(body: ByteBuffer): Body
operator fun invoke(body: InputStream, length: Long? = null): Body

Extension Functions

Name Summary
gunzipped fun Body.gunzipped(): Body
gunzippedStream fun Body.gunzippedStream(): Body
gzipped fun Body.gzipped(): CompressionResult
gzippedStream fun Body.gzippedStream(): CompressionResult

Companion Object Extension Functions

Name Summary
binary fun Body.Companion.binary(contentType: ContentType, description: String? = null, contentNegotiation: ContentNegotiation = None): <ERROR CLASS>
multipartForm fun Body.Companion.multipartForm(validator: Validator, vararg parts: Lens<MultipartForm, *>, defaultBoundary: String = MULTIPART_BOUNDARY, diskThreshold: Int = DEFAULT_DISK_THRESHOLD, contentTypeFn: (String) -> ContentType = ::MultipartFormWithBoundary): BiDiBodyLensSpec<MultipartForm>
nonEmptyString fun Body.Companion.nonEmptyString(contentType: ContentType, description: String? = null, contentNegotiation: ContentNegotiation = None): <ERROR CLASS>
regex fun Body.Companion.regex(pattern: String, group: Int = 1, contentType: ContentType = ContentType.TEXT_PLAIN, description: String? = null, contentNegotiation: ContentNegotiation = None): <ERROR CLASS>
string fun Body.Companion.string(contentType: ContentType, description: String? = null, contentNegotiation: ContentNegotiation = None): <ERROR CLASS>
viewModel fun Body.Companion.viewModel(renderer: TemplateRenderer, contentType: ContentType): <ERROR CLASS>
webForm fun Body.Companion.webForm(validator: Validator, vararg formFields: Lens<WebForm, *>): BiDiBodyLensSpec<WebForm>

Inheritors

Name Summary
MemoryBody Represents a body that is backed by an in-memory ByteBuffer. Closing this has no effect.data class MemoryBody : Body
MultipartFormBody Represents a Multi-part that is backed by a stream, which should be closed after handling the content. The gotchas which apply to StreamBody also apply here..data class MultipartFormBody : Body, Closeable
StreamBody Represents a body that is backed by a (lazy) InputStream. Operating with StreamBody has a number of potential gotchas:class StreamBody : Body