net.httpserver: Join multiple headers with the same name as per RFC (thanks darkhippo)
authorMatthew Wild <mwild1@gmail.com>
Sat, 28 Aug 2010 22:41:09 +0000 (23:41 +0100)
committerMatthew Wild <mwild1@gmail.com>
Sat, 28 Aug 2010 22:41:09 +0000 (23:41 +0100)
net/httpserver.lua

index 59ddbb12494d915ec1d39e52c9ed89799028cb1d..55758147e7c1f2a18f82e3421051f50f8e240474 100644 (file)
@@ -152,7 +152,12 @@ local function request_reader(request, data, startpos)
                        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;