api

http4k / org.http4k.core / StreamBody

StreamBody

class StreamBody : 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

Name Summary
<init> Represents a body that is backed by a (lazy) InputStream. Operating with StreamBody has a number of potential gotchas:StreamBody(stream: InputStream, length: Long? = null)

Properties

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

Functions

Name Summary
close fun close(): Unit
equals fun equals(other: Any?): Boolean
hashCode fun hashCode(): Int
toString fun toString(): String

Extension Functions

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