BodyMode

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

This choice comes with the following trade-offs:

Memory does not require any special treatment. However, you need to be confident that the sum of all "in-flight" body bytes does not exceed your JVM heap. Otherwise, you'll run into `OutOfMemoryException's.

Stream, on the other hand, allows you to handle payloads of any size, but you'll need to make sure that:

  1. You're consuming it only once and at the right place (harder to add "debugging" filters too).

  2. It's always consumed, or close() is called appropriately.

Inheritors

Types

Link copied to clipboard
data object Memory : BodyMode
Link copied to clipboard
data object Stream : BodyMode

Functions

Link copied to clipboard
fun Events.and(next: Events): Events
Link copied to clipboard
fun (Request) -> Boolean.asRouter(description: String = unavailable.description): Router

Convert any predicate on a request into a router

Link copied to clipboard
Link copied to clipboard
fun HttpHandler.debug(out: PrintStream = System.out, debugStream: Boolean = false): (request: Request) -> Response
Link copied to clipboard
abstract operator fun invoke(p1: InputStream): Body
Link copied to clipboard
fun Events.then(next: Events): (Event) -> Unit
Link copied to clipboard

Convert a synchronous HttpHandler API to mimic AsyncHttpClient