net.httpserver: Join multiple headers with the same name as per RFC (thanks darkhippo)

Sat, 28 Aug 2010 23:41:09 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Sat, 28 Aug 2010 23:41:09 +0100
changeset 3473
84fe4d5ac2ed
parent 3472
61cf3e7d7f07
child 3474
730876bbe4e6

net.httpserver: Join multiple headers with the same name as per RFC (thanks darkhippo)

net/httpserver.lua file | annotate | diff | comparison | revisions
--- a/net/httpserver.lua	Sat Aug 28 22:25:12 2010 +0100
+++ b/net/httpserver.lua	Sat Aug 28 23:41:09 2010 +0100
@@ -152,7 +152,12 @@
 			startpos = (startpos or 1) + #line + 2;
 			local k, v = line:match("(%S+): (.+)");
 			if k and v then
-				headers[k:lower()] = v;
+				k = k:lower();
+				if headers[k] then
+					headers[k] = headers[k]..", "..v;
+				else
+					headers[k] = v;
+				end
 				--log("debug", "Header: '"..k:lower().."' = '"..v.."'");
 			elseif #line == 0 then
 				headers_complete = true;

mercurial