android-components / mozilla.components.concept.fetch / Response / Body

Body

class Body : Closeable, AutoCloseable (source)

A Body returned along with the Request.

The response body can be consumed only once..

Constructors

<init>

Body(stream: InputStream)

A Body returned along with the Request.

Functions

close

open fun close(): Unit

Closes this Body and releases any system resources associated with it.

string

fun string(charset: Charset = Charsets.UTF_8): String

Reads this body completely as a String.

useBufferedReader

fun <R> useBufferedReader(charset: Charset = Charsets.UTF_8, block: (BufferedReader) -> R): R

Creates a buffered reader from this body.

useStream

fun <R> useStream(block: (InputStream) -> R): R

Creates a usable stream from this body.

Companion Object Functions

empty

fun empty(): Body

Creates an empty response body.