spec/util_http_spec.lua
changeset 13128 f15e23840780
parent 10715 d2e4584ba7b3
child 13405 626ab0af83af
equal deleted inserted replaced
13127:dee26e4cfb2b 13128:f15e23840780
   106 
   106 
   107 		it("is weird", function ()
   107 		it("is weird", function ()
   108 			assert.is_(http.contains_token("fo o", "foo"));
   108 			assert.is_(http.contains_token("fo o", "foo"));
   109 		end);
   109 		end);
   110 	end);
   110 	end);
       
   111 
       
   112 do
       
   113 	describe("parse_forwarded", function()
       
   114 		it("works", function()
       
   115 			assert.same({ { ["for"] = "[2001:db8:cafe::17]:4711" } }, http.parse_forwarded('For="[2001:db8:cafe::17]:4711"'), "case insensitive");
       
   116 
       
   117 			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'),
       
   118 				"separated by semicolon");
       
   119 
       
   120 			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'),
       
   121 				"Values from multiple proxy servers can be appended using a comma");
       
   122 
       
   123 		end)
       
   124 		it("rejects quoted quotes", function ()
       
   125 			assert.falsy(http.parse_forwarded('foo="bar\"bar'), "quoted quotes");
       
   126 		end)
       
   127 		pending("deals with quoted quotes", function ()
       
   128 			assert.same({ { foo = 'bar"baz' } }, http.parse_forwarded('foo="bar\"bar'), "quoted quotes");
       
   129 		end)
       
   130 	end)
       
   131 end
   111 end);
   132 end);