io.youi.http.CookieHeader.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of youi-core_sjs0.6_2.13 Show documentation
Show all versions of youi-core_sjs0.6_2.13 Show documentation
Core functionality leveraged and shared by most other sub-projects of YouI.
The newest version!
package io.youi.http
import io.youi.http.cookie.RequestCookie
object CookieHeader extends ListTypedHeaderKey[RequestCookie] {
override def key: String = "Cookie"
override protected def commaSeparated: Boolean = false
override def value(headers: Headers): List[RequestCookie] = {
val cookies = headers.get(this)
try {
cookies.flatMap(_.split(';')).map(_.trim).collect {
case SetCookie.KeyValueRegex(key, value) => RequestCookie(key, value)
}
} catch {
case t: Throwable => {
scribe.error(new RuntimeException(s"Failed to parse cookie: [${cookies.mkString("|")}]", t))
throw t
}
}
}
override def apply(value: RequestCookie): Header = Header(this, value.http)
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy