StreamBody

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:

  1. Attempts to consume the stream will pull all of the contents into memory, and should thus be avoided. This includes calling equals() and payload

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

  3. Depending on the source of the stream, this body may or may not contain a known length.

Constructors

Link copied to clipboard
constructor(stream: InputStream, length: Long? = null)

Properties

Link copied to clipboard
open override val length: Long? = null

Will be null for bodies where it's impossible to a priori determine - e.g. StreamBody

Link copied to clipboard
open override val payload: ByteBuffer
Link copied to clipboard
open override val stream: InputStream

Functions

Link copied to clipboard
open override fun close()
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun Body.gzipped(compressionLevel: Int = DEFAULT_COMPRESSION): CompressionResult
Link copied to clipboard
fun Body.gzippedStream(compressionLevel: Int = DEFAULT_COMPRESSION): CompressionResult
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun toString(): String