diff --git a/lualib/http/httpd.lua b/lualib/http/httpd.lua index c19d4bae..0131db0a 100644 --- a/lualib/http/httpd.lua +++ b/lualib/http/httpd.lua @@ -2,6 +2,7 @@ local internal = require "http.internal" local table = table local string = string +local type = type local httpd = {} @@ -113,7 +114,13 @@ local function writeall(writefunc, statuscode, bodyfunc, header) writefunc(statusline) if header then for k,v in pairs(header) do - writefunc(string.format("%s: %s\r\n", k,v)) + if type(v) == "table" then + for _,v in ipairs(v) do + writefunc(string.format("%s: %s\r\n", k,v)) + end + else + writefunc(string.format("%s: %s\r\n", k,v)) + end end end local t = type(bodyfunc) diff --git a/lualib/http/internal.lua b/lualib/http/internal.lua index 0e83bc72..5bb35752 100644 --- a/lualib/http/internal.lua +++ b/lualib/http/internal.lua @@ -1,3 +1,6 @@ +local table = table +local type = type + local M = {} local LIMIT = 8192 @@ -83,7 +86,12 @@ function M.parseheader(lines, from, header) end name = name:lower() if header[name] then - header[name] = header[name] .. ", " .. value + local v = header[name] + if type(v) == "table" then + table.insert(v, value) + else + header[name] = { v , value } + end else header[name] = value end