spice.http.DateHeaderKey.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.
package spice.http
class DateHeaderKey(val key: String, val commaSeparated: Boolean = false) extends TypedHeaderKey[Long] {
import DateHeaderKey._
override def value(headers: Headers): Option[Long] = get(headers).flatMap(parse)
override def apply(date: Long): Header = Header(this, format(date))
}
object DateHeaderKey {
def parse(date: String): Option[Long] = spice.Platform.parseHTTPDate(date)
def format(date: Long): String = spice.Platform.toHTTPDate(date)
}