RequestCookies
Provides access to request cookies in Cookie header.
In HttpRequest, cookies are stringed together in the Cookie header. You can access them using extension methods provided by RequestCookies, with each cookie represented as PlainCookie.
import scala.language.implicitConversions
import scamper.http.RequestMethod.Registry.Get
import scamper.http.cookies.{ PlainCookie, RequestCookies }
import scamper.http.stringToUri
// Build request with cookies
val req = Get("https://localhost:8080/motd").setCookies(
PlainCookie("ID", "bG9zCg"), PlainCookie("Region", "SE-US")
)
// Print all cookies
req.cookies.foreach(println)
// Get cookies by name
val id: Option[PlainCookie] = req.getCookie("ID")
val region: Option[PlainCookie] = req.getCookie("Region")
// Get cookie values by name
assert(req.getCookieValue("ID").contains("bG9zCg"))
assert(req.getCookieValue("Region").contains("SE-US"))
Value members
Concrete methods
Creates copy of request with supplied cookie.
Creates copy of request with supplied cookie.
- Value Params
- cookies
new cookies
- Note
Previous cookies with same name are removed.
Creates copy of request with supplied cookies.
Creates copy of request with supplied cookies.
- Value Params
- more
additional cookies
- one
cookie
- Note
Previous cookies with same name are removed.
Creates copy of request excluding cookies with given names.
Creates copy of request excluding cookies with given names.
- Value Params
- names
cookie names
Creates copy of request excluding cookies with given names.
Creates copy of request excluding cookies with given names.
- Value Params
- more
additional cookie names
- one
cookie name
Creates copy of request with new set of cookies.
Creates copy of request with new set of cookies.
- Value Params
- cookies
new set of cookies