Skip to content

Commit

Permalink
Add a test for headers containing commas
Browse files Browse the repository at this point in the history
  • Loading branch information
timschumi committed Jul 21, 2023
1 parent 012199e commit 4175e76
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/chttp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,31 @@ return {
})
end
},
{
name = "Response has multiple cookies with Expires properties",
async = true,
timeout = 1,
func = function()
CHTTP({
url = "http://127.0.0.1:5000/response_multiple_cookies_with_expires",
success = function(code, body, headers)
expect(code).to.equal(200)
expect(body).to.equal("Hello World!")

local cookie_a = "CookieA=1; Expires=Sat, 02 Feb 2002 12:17:00 GMT"
local cookie_b = "CookieB=2; Expires=Fri, 21 Jul 2023 13:36:35 GMT"

-- Header order is nondeterministic
expect((headers["Set-Cookie"] == (cookie_a .. "," .. cookie_b)) or (headers["Set-Cookie"] == (cookie_b .. "," .. cookie_a))).to.beTrue()
done()
end,
failed = function(err)
error("HTTP request failed: " .. err)
done()
end
})
end
},
{
name = "Response has multiple warnings",
async = true,
Expand Down
14 changes: 14 additions & 0 deletions tests/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@ def response_multiple_cookies():
)


@app.route("/response_multiple_cookies_with_expires", methods=["GET"])
def response_multiple_cookies_with_expires():
return (
b"Hello World!",
200,
{
"Set-Cookie": [
"CookieA=1; Expires=Sat, 02 Feb 2002 12:17:00 GMT",
"CookieB=2; Expires=Fri, 21 Jul 2023 13:36:35 GMT",
],
},
)


@app.route("/response_multiple_warning", methods=["GET"])
def response_multiple_warning():
return (
Expand Down

0 comments on commit 4175e76

Please sign in to comment.