summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorflywind <43030857+xflywind@users.noreply.github.com>2020-09-14 18:20:42 +0800
committerGitHub <noreply@github.com>2020-09-14 12:20:42 +0200
commite111b610caa26b6577f99423d360ff805e0b0ecf (patch)
tree4af6b52600ab512c6b073998cad789f85841782d /tests
parent366216da6455fc882da44bac84b1887e6e1a267e (diff)
downloadNim-e111b610caa26b6577f99423d360ff805e0b0ecf.tar.gz
test cookies with comma for #15319 (#15322)
* test cookies with comma for #15319

* space
Diffstat (limited to 'tests')
-rw-r--r--tests/stdlib/thttpcore.nim17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/stdlib/thttpcore.nim b/tests/stdlib/thttpcore.nim
index f96fcc3b8..33c24453e 100644
--- a/tests/stdlib/thttpcore.nim
+++ b/tests/stdlib/thttpcore.nim
@@ -34,3 +34,20 @@ suite "httpcore":
     let h1 = newHttpHeaders({"a": "1", "a": "2", "A": "3"})
 
     assert seq[string](h1["a"]).join(",") == "1,2,3"
+
+  test "test cookies with comma":
+    doAssert parseHeader("cookie: foo, bar") ==  ("cookie", @["foo, bar"])
+    doAssert parseHeader("cookie: foo, bar, prologue") == ("cookie", @["foo, bar, prologue"])
+    doAssert parseHeader("cookie: foo, bar, prologue, starlight") == ("cookie", @["foo, bar, prologue, starlight"])
+
+    doAssert parseHeader("cookie:   foo, bar") ==  ("cookie", @["foo, bar"])
+    doAssert parseHeader("cookie:  foo, bar, prologue") == ("cookie", @["foo, bar, prologue"])
+    doAssert parseHeader("cookie:   foo, bar, prologue, starlight") == ("cookie", @["foo, bar, prologue, starlight"])
+
+    doAssert parseHeader("Cookie: foo, bar") == (key: "Cookie", value: @["foo, bar"])
+    doAssert parseHeader("Cookie: foo, bar, prologue") == (key: "Cookie", value: @["foo, bar, prologue"])
+    doAssert parseHeader("Cookie: foo, bar, prologue, starlight") == (key: "Cookie", value: @["foo, bar, prologue, starlight"])
+
+    doAssert parseHeader("Accept: foo, bar") == (key: "Accept", value: @["foo", "bar"])
+    doAssert parseHeader("Accept: foo, bar, prologue") == (key: "Accept", value: @["foo", "bar", "prologue"])
+    doAssert parseHeader("Accept: foo, bar, prologue, starlight") == (key: "Accept", value: @["foo", "bar", "prologue", "starlight"])