api

http4k / org.http4k.core / StreamBody / <init>

<init>

StreamBody(stream: InputStream, length: Long? = null)

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.