Body

zio.http.Body
See theBody companion object
final class Body

HTTP message body backed by a Stream[Nothing, Byte].

Body is a thin wrapper around a pull-based byte stream and a content type. All optimization intelligence (known chunk, known length) lives in the underlying Stream via its knownChunk and knownLength metadata APIs.

Value parameters

contentType

the MIME content type of this body

stream

the underlying byte stream

Attributes

Companion
object
Source
Body.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def asString(charset: Charset = ...): String

Decodes the body using the given charset.

Decodes the body using the given charset.

Attributes

Source
Body.scala
def asStringAsync(charset: Charset = ...): encoding.Async[String]

Decodes the body asynchronously using the given charset.

Decodes the body asynchronously using the given charset.

Attributes

Source
Body.scala

Decodes the body using the content-type charset when present.

Decodes the body using the content-type charset when present.

Attributes

Source
Body.scala
def asStringFromContentTypeAsync: encoding.Async[String]

Decodes asynchronously using the content-type charset when present.

Decodes asynchronously using the content-type charset when present.

Attributes

Source
Body.scala
override def equals(that: Any): Boolean

Compares the receiver object (this) with the argument object (that) for equivalence.

Compares the receiver object (this) with the argument object (that) for equivalence.

Any implementation of this method should be an equivalence relation:

  • It is reflexive: for any instance x of type Any, x.equals(x) should return true.
  • It is symmetric: for any instances x and y of type Any, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any instances x, y, and z of type Any if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.

If you override this method, you should verify that your implementation remains an equivalence relation. Additionally, when overriding this method it is usually necessary to override hashCode to ensure that objects which are "equal" (o1.equals(o2) returns true) hash to the same scala.Int. (o1.hashCode.equals(o2.hashCode)).

Value parameters

that

the object to compare against this object for equality.

Attributes

Returns

true if the receiver object is equivalent to the argument; false otherwise.

Definition Classes
Any
Source
Body.scala
override def hashCode: Int

Calculates a hash code value for the object.

Calculates a hash code value for the object.

The default hashing algorithm is platform dependent.

Note that it is allowed for two objects to have identical hash codes (o1.hashCode.equals(o2.hashCode)) yet not be equal (o1.equals(o2) returns false). A degenerate implementation could always return 0. However, it is required that if two objects are equal (o1.equals(o2) returns true) that they have identical hash codes (o1.hashCode.equals(o2.hashCode)). Therefore, when overriding this method, be sure to verify that the behavior is consistent with the equals method.

Attributes

Returns

the hash code value for this object.

Definition Classes
Any
Source
Body.scala
def isEmpty: Boolean

Returns true if this body is known to be empty (zero bytes).

Returns true if this body is known to be empty (zero bytes).

Attributes

Source
Body.scala
def length: Option[Long]

Returns the known length of this body in bytes, or None if the length is not known without consuming the stream.

Returns the known length of this body in bytes, or None if the length is not known without consuming the stream.

Attributes

Source
Body.scala
def nonEmpty: Boolean

Returns true if this body is known to be non-empty.

Returns true if this body is known to be non-empty.

Attributes

Source
Body.scala
def text: String

Attributes

Source
Body.scala
def textAsync: encoding.Async[String]

Attributes

Source
Body.scala
def toArray: Array[Byte]

Materializes the entire stream into a fresh Array[Byte].

Materializes the entire stream into a fresh Array[Byte].

Attributes

Source
Body.scala
def toArrayAsync: encoding.Async[Array[Byte]]

Materializes the entire stream asynchronously into a fresh array.

Materializes the entire stream asynchronously into a fresh array.

Attributes

Source
Body.scala
def toChunk: Chunk[Byte]

Materializes the entire stream into a Chunk[Byte].

Materializes the entire stream into a Chunk[Byte].

Attributes

Source
Body.scala
def toChunkAsync: encoding.Async[Chunk[Byte]]

Materializes the entire stream asynchronously into a Chunk[Byte].

Materializes the entire stream asynchronously into a Chunk[Byte].

Attributes

Source
Body.scala
def toStream: Stream[Nothing, Byte]

Returns the body content as a Stream[Nothing, Byte].

Returns the body content as a Stream[Nothing, Byte].

Attributes

Source
Body.scala
override def toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Any
Source
Body.scala

Concrete fields

Attributes

Source
Body.scala
val stream: Stream[Nothing, Byte]

Attributes

Source
Body.scala