tcookies.nim 541 B

1234567891011121314151617181920212223
  1. discard """
  2. matrix: "--mm:refc; --mm:orc"
  3. targets: "c js"
  4. """
  5. import std/[cookies, times, strtabs]
  6. import std/assertions
  7. let expire = fromUnix(0) + 1.seconds
  8. let theCookies = [
  9. setCookie("test", "value", expire),
  10. setCookie("test", "value", expire.local),
  11. setCookie("test", "value", expire.utc)
  12. ]
  13. let expected = "Set-Cookie: test=value; Expires=Thu, 01 Jan 1970 00:00:01 GMT"
  14. doAssert theCookies == [expected, expected, expected]
  15. let table = parseCookies("uid=1; kp=2")
  16. doAssert table["uid"] == "1"
  17. doAssert table["kp"] == "2"