com.hexagonkt.http.model.Cookie.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of http Show documentation
Show all versions of http Show documentation
HTTP classes. These classes are shared among the HTTP client and the HTTP server.
The newest version!
package com.hexagonkt.http.model
import java.time.Instant
/**
* TODO .
*
* @property name
* @property value
* @property maxAge '-1' is the same as empty
* @property secure
* @property path '/' is the same as empty
* @property httpOnly
* @property domain
* @property sameSite
* @property expires
*/
data class Cookie(
val name: String,
val value: String = "",
val maxAge: Long = -1,
val secure: Boolean = false,
val path: String = "/",
val httpOnly: Boolean = false,
val domain: String? = null,
val sameSite: CookieSameSite? = null,
val expires: Instant? = null,
) {
val deleted: Boolean by lazy { value == "" && maxAge <= 0L }
init {
require(name.isNotBlank()) { "Cookie name can not be blank: $name" }
}
fun delete(): Cookie =
copy(value = "", maxAge = 0)
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy