QueueInputStream

class QueueInputStream(requestMore: () -> Unit) : InputStream(source)

A blocking InputStream fed by chunks pushed from a reactive (push-based) source, letting a blocking http4k handler consume a body that the underlying framework delivers asynchronously.

The source calls push/end/fail; the http4k handler (on a worker thread) pulls via read. requestMore is invoked whenever the consumer needs the next chunk, so the source only delivers when asked - that is the backpressure. The blocking read must never run on the same thread that calls push, or it deadlocks.

Constructors

Link copied to clipboard
constructor(requestMore: () -> Unit)

Functions

Link copied to clipboard
open fun available(): Int
Link copied to clipboard
open fun close()
Link copied to clipboard
fun end()
Link copied to clipboard
fun fail(cause: Throwable)
Link copied to clipboard
open fun mark(readlimit: Int)
Link copied to clipboard
Link copied to clipboard
fun push(bytes: ByteArray)
Link copied to clipboard
open fun read(b: ByteArray?): Int
open override fun read(): Int
open override fun read(b: ByteArray, off: Int, len: Int): Int
Link copied to clipboard
open fun readAllBytes(): ByteArray?
Link copied to clipboard
open fun readNBytes(len: Int): ByteArray?
open fun readNBytes(b: ByteArray?, off: Int, len: Int): Int
Link copied to clipboard
open fun reset()
Link copied to clipboard
open fun skip(n: Long): Long
Link copied to clipboard
open fun skipNBytes(n: Long)
Link copied to clipboard
open fun transferTo(out: OutputStream?): Long