spice.http.content.StreamContent.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spice-core_3 Show documentation
Show all versions of spice-core_3 Show documentation
Core functionality leveraged and shared by most other sub-projects of YouI.
package spice.http.content
import cats.effect.IO
import cats.effect.unsafe.implicits.global
import spice.net.ContentType
case class StreamContent(stream: fs2.Stream[IO, Byte],
contentType: ContentType,
lastModified: Long = System.currentTimeMillis(),
length: Long = -1L) extends Content {
override def withContentType(contentType: ContentType): Content = copy(contentType = contentType)
override def withLastModified(lastModified: Long): Content = copy(lastModified = lastModified)
override def asString: IO[String] = stream
.compile
.toList
.map(_.toArray)
.map(array => new String(array, "UTF-8"))
override def asStream: fs2.Stream[IO, Byte] = stream
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy