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

Body

class Body : Closeable (source)

A Body to be send with the Request.

Parameters

stream - A stream that will be read and send to the resource.

Constructors

Name Summary
<init> Body(stream: InputStream)
A Body to be send with the Request.

Functions

Name Summary
close fun close(): Unit
Closes this body and releases any system resources associated with it.
useStream fun <R> useStream(block: (InputStream) -> R): R
Executes the given block function on the body’s stream and then closes it down correctly whether an exception is thrown or not.

Companion Object Functions

Name Summary
fromFile fun fromFile(file: File): Body
Create a Body from the provided File.
fromParamsForFormUrlEncoded fun fromParamsForFormUrlEncoded(vararg unencodedParams: Pair<String, String>): Body
Create a Body from the provided unencodedParams in the format of Content-Type “application/x-www-form-urlencoded”. Parameters are formatted as “key1=value1&key2=value2…” and values are percent-encoded. If the given map is empty, the response body will contain the empty string.
fromString fun fromString(value: String): Body
Create a Body from the provided String.