object Body
- Alphabetic
- By Inheritance
- Body
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- final case class ByteRange(start: Long, end: Long, totalSize: Long, contentType: MediaType, data: ZStream[Any, Throwable, Byte]) extends Product with Serializable
Represents a single byte range for multipart/byteranges responses.
Represents a single byte range for multipart/byteranges responses.
- start
The starting byte position (inclusive)
- end
The ending byte position (inclusive)
- totalSize
The total size of the complete resource
- contentType
The content type of this part
- data
The stream of bytes for this range
- final case class ContentType(mediaType: MediaType, boundary: Option[Boundary] = None, charset: Option[Charset] = None) extends Product with Serializable
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @IntrinsicCandidate() @native()
- val empty: Body
A body that contains no data.
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def from[A](a: A)(implicit codec: BinaryCodec[A], trace: Trace): Body
Constructs a zio.http.Body from a value based on a zio-schema zio.schema.codec.BinaryCodec.
Example for json:Constructs a zio.http.Body from a value based on a zio-schema zio.schema.codec.BinaryCodec.
Example for json:import zio.schema.codec.JsonCodec._ case class Person(name: String, age: Int) implicit val schema: Schema[Person] = DeriveSchema.gen[Person] val person = Person("John", 42) val body = Body.from(person)
- def fromArray(data: Array[Byte]): Body
Constructs a zio.http.Body from an array of bytes.
Constructs a zio.http.Body from an array of bytes.
WARNING: The array must not be mutated after creating the body.
- def fromCharSequence(charSequence: CharSequence, charset: Charset = Charsets.Http): Body
Constructs a zio.http.Body from the contents of a file.
- def fromCharSequenceStream(stream: ZStream[Any, Throwable, CharSequence], contentLength: Long, charset: Charset = Charsets.Http)(implicit trace: Trace): Body
Constructs a zio.http.Body from a stream of text with known length, using the specified character set, which defaults to the HTTP character set.
- def fromCharSequenceStreamChunked(stream: ZStream[Any, Throwable, CharSequence], charset: Charset = Charsets.Http)(implicit trace: Trace): Body
Constructs a zio.http.Body from a stream of text with unknown length using chunked transfer encoding, using the specified character set, which defaults to the HTTP character set.
- def fromCharSequenceStreamChunkedEnv[R](stream: ZStream[R, Throwable, CharSequence], charset: Charset = Charsets.Http)(implicit trace: Trace): RIO[R, Body]
Constructs a zio.http.Body from a stream of text with unknown length using chunked transfer encoding that depends on
R, using the specified character set, which defaults to the HTTP character set. - def fromCharSequenceStreamEnv[R](stream: ZStream[R, Throwable, CharSequence], contentLength: Long, charset: Charset = Charsets.Http)(implicit trace: Trace): RIO[R, Body]
Constructs a zio.http.Body from a stream of text with known length that depends on
R, using the specified character set, which defaults to the HTTP character set. - def fromChunk(data: Chunk[Byte], contentType: ContentType): Body
- def fromChunk(data: Chunk[Byte], mediaType: MediaType): Body
Constructs a zio.http.Body from a chunk of bytes and sets the media type.
- def fromChunk(data: Chunk[Byte]): Body
Constructs a zio.http.Body from a chunk of bytes.
- def fromFile(file: File, chunkSize: Int = 1024 * 4)(implicit trace: Trace): ZIO[Any, Nothing, Body]
Constructs a zio.http.Body from the contents of a file.
- def fromFileRange(file: File, offset: Long, length: Long, chunkSize: Int = 1024 * 4)(implicit trace: Trace): ZIO[Any, Nothing, Body]
Constructs a zio.http.Body from a range of bytes within a file.
Constructs a zio.http.Body from a range of bytes within a file. This is useful for serving partial content in response to HTTP Range requests.
- file
The file to read from
- offset
The starting byte position (0-based)
- length
The number of bytes to read
- chunkSize
The size of chunks to use when streaming
- def fromMultipartByteRanges(ranges: Chunk[ByteRange], boundary: Boundary)(implicit trace: Trace): Body
Constructs a zio.http.Body from multiple byte ranges, using multipart/byteranges encoding as specified in RFC 9110 Section 14.6.
Constructs a zio.http.Body from multiple byte ranges, using multipart/byteranges encoding as specified in RFC 9110 Section 14.6.
This is used to respond to HTTP Range requests that specify multiple ranges.
- ranges
The list of byte ranges to include in the response
- boundary
The boundary to use for separating parts
- def fromMultipartByteRangesUUID(ranges: Chunk[ByteRange])(implicit trace: Trace): UIO[Body]
Constructs a zio.http.Body from multiple byte ranges with a randomly generated boundary.
- def fromMultipartForm(form: Form, specificBoundary: Boundary)(implicit trace: Trace): Body
Constructs a zio.http.Body from from form data, using multipart encoding and the specified character set, which defaults to UTF-8.
- def fromMultipartFormUUID(form: Form)(implicit trace: Trace): UIO[Body]
Constructs a zio.http.Body from from form data, using multipart encoding and the specified character set, which defaults to UTF-8.
Constructs a zio.http.Body from from form data, using multipart encoding and the specified character set, which defaults to UTF-8. Utilizes a random boundary based on a UUID.
- def fromSocketApp(app: WebSocketApp[Any]): WebsocketBody
- def fromStream[A](stream: ZStream[Any, Throwable, A])(implicit codec: BinaryCodec[A], trace: Trace): Body
Constructs a zio.http.Body from stream of values based on a zio-schema zio.schema.codec.BinaryCodec.
Constructs a zio.http.Body from stream of values based on a zio-schema zio.schema.codec.BinaryCodec.
Example for json:
import zio.schema.codec.JsonCodec._ case class Person(name: String, age: Int) implicit val schema: Schema[Person] = DeriveSchema.gen[Person] val persons = ZStream(Person("John", 42)) val body = Body.fromStream(persons)
- def fromStream(stream: ZStream[Any, Throwable, Byte], contentLength: Long): Body
Constructs a zio.http.Body from a stream of bytes with a known length.
- def fromStreamChunked(stream: ZStream[Any, Throwable, Byte]): Body
Constructs a zio.http.Body from a stream of bytes of unknown length, using chunked transfer encoding.
- def fromStreamChunkedEnv[R](stream: ZStream[R, Throwable, Byte])(implicit trace: Trace): RIO[R, Body]
Constructs a zio.http.Body from a stream of bytes of unknown length that depends on
R, using chunked transfer encoding. - def fromStreamEnv[A, R](stream: ZStream[R, Throwable, A])(implicit codec: BinaryCodec[A], trace: Trace): RIO[R, Body]
Constructs a zio.http.Body from stream of values based on a zio-schema zio.schema.codec.BinaryCodec and depends on
R
- def fromStreamEnv[R](stream: ZStream[R, Throwable, Byte], contentLength: Long)(implicit trace: Trace): RIO[R, Body]
Constructs a zio.http.Body from a stream of bytes with a known length that depends on
R. - def fromString(text: String, charset: Charset = Charsets.Http): Body
Helper to create Body from String
- def fromURLEncodedForm(form: Form, charset: Charset = StandardCharsets.UTF_8): Body
Constructs a zio.http.Body from form data using URL encoding and the default character set.
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @IntrinsicCandidate() @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @IntrinsicCandidate() @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def json[A](a: A)(implicit schema: Schema[A]): Body
Constructs a zio.http.Body from a value as JSON using zio-schema.
Constructs a zio.http.Body from a value as JSON using zio-schema.
Example:
import zio.schema.{DeriveSchema, Schema} case class Person(name: String, age: Int) implicit val schema: Schema[Person] = DeriveSchema.gen[Person] val person = Person("John", 42) val body = Body.json(person)
- def jsonCodec[A](a: A)(implicit encoder: JsonEncoder[A]): Body
Constructs a zio.http.Body from a value as JSON using zio-json.
Constructs a zio.http.Body from a value as JSON using zio-json.
Example:
import zio.json._ case class Person(name: String, age: Int) implicit val encoder: JsonEncoder[Person] = DeriveJsonEncoder.gen[Person] val person = Person("John", 42) val body = Body.jsonZio(person)
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @IntrinsicCandidate() @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @IntrinsicCandidate() @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- object ContentType extends Serializable