mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-23 11:33:09 +00:00
use table for multi header key
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user