spice.http.content.BytesContent.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spice-core_sjs1_3 Show documentation
Show all versions of spice-core_sjs1_3 Show documentation
Core functionality leveraged and shared by most other sub-projects of Spice.
The newest version!
package spice.http.content
import rapid.Task
import spice.net.ContentType
case class BytesContent(value: Array[Byte], contentType: ContentType, lastModified: Long = System.currentTimeMillis()) extends Content {
override def length: Long = value.length
override def withContentType(contentType: ContentType): Content = copy(contentType = contentType)
override def withLastModified(lastModified: Long): Content = copy(lastModified = lastModified)
override def toString: String = s"BytesContent(${value.take(100).mkString("Array(", ", ", ")")}, contentType: $contentType)"
override def asString: Task[String] = Task.pure(new String(value, "UTF-8"))
override def asStream: rapid.Stream[Byte] = new rapid.Stream(Task(value.iterator))
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy