aboutsummaryrefslogtreecommitdiffstats
path: root/spec/util_http_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'spec/util_http_spec.lua')
-rw-r--r--spec/util_http_spec.lua22
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/util_http_spec.lua b/spec/util_http_spec.lua
index c6087450..3e2f5a6a 100644
--- a/spec/util_http_spec.lua
+++ b/spec/util_http_spec.lua
@@ -41,6 +41,7 @@ describe("util.http", function()
end);
it("should encode special characters with escaping", function()
+ -- luacheck: ignore 631
assert.are.equal(http.formencode({ { name = "one two", value = "1"}, { name = "two one&", value = "2" } }), "one+two=1&two+one%26=2", "Form encoded");
end);
end);
@@ -108,4 +109,25 @@ describe("util.http", function()
assert.is_(http.contains_token("fo o", "foo"));
end);
end);
+
+do
+ describe("parse_forwarded", function()
+ it("works", function()
+ assert.same({ { ["for"] = "[2001:db8:cafe::17]:4711" } }, http.parse_forwarded('For="[2001:db8:cafe::17]:4711"'), "case insensitive");
+
+ assert.same({ { ["for"] = "192.0.2.60"; proto = "http"; by = "203.0.113.43" } }, http.parse_forwarded('for=192.0.2.60;proto=http;by=203.0.113.43'),
+ "separated by semicolon");
+
+ assert.same({ { ["for"] = "192.0.2.43" }; { ["for"] = "198.51.100.17" } }, http.parse_forwarded('for=192.0.2.43, for=198.51.100.17'),
+ "Values from multiple proxy servers can be appended using a comma");
+
+ end)
+ it("rejects quoted quotes", function ()
+ assert.falsy(http.parse_forwarded('foo="bar\"bar'), "quoted quotes");
+ end)
+ pending("deals with quoted quotes", function ()
+ assert.same({ { foo = 'bar"baz' } }, http.parse_forwarded('foo="bar\"bar'), "quoted quotes");
+ end)
+ end)
+end
end);