thttpcore.nim 705 B

1234567891011121314151617181920212223242526272829303132
  1. discard """
  2. output: "[Suite] httpcore"
  3. """
  4. import unittest
  5. import httpcore
  6. suite "httpcore":
  7. test "HttpCode":
  8. assert $Http418 == "418 I'm a teapot"
  9. assert Http418.is4xx() == true
  10. assert Http418.is2xx() == false
  11. test "headers":
  12. var h = newHttpHeaders()
  13. assert h.len == 0
  14. h.add("Cookie", "foo")
  15. assert h.len == 1
  16. assert h.hasKey("cooKIE")
  17. assert h["Cookie"] == "foo"
  18. assert h["cookie"] == "foo"
  19. h["cookie"] = @["bar", "x"]
  20. assert h["Cookie"] == "bar"
  21. assert h["Cookie", 1] == "x"
  22. assert h["Cookie"].contains("BaR") == true
  23. assert h["Cookie"].contains("X") == true
  24. assert "baR" in h["cookiE"]
  25. h.del("coOKie")
  26. assert h.len == 0