mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-25 12:43: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 table = table
|
||||||
local string = string
|
local string = string
|
||||||
|
local type = type
|
||||||
|
|
||||||
local httpd = {}
|
local httpd = {}
|
||||||
|
|
||||||
@@ -113,7 +114,13 @@ local function writeall(writefunc, statuscode, bodyfunc, header)
|
|||||||
writefunc(statusline)
|
writefunc(statusline)
|
||||||
if header then
|
if header then
|
||||||
for k,v in pairs(header) do
|
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
|
||||||
end
|
end
|
||||||
local t = type(bodyfunc)
|
local t = type(bodyfunc)
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
local table = table
|
||||||
|
local type = type
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local LIMIT = 8192
|
local LIMIT = 8192
|
||||||
@@ -83,7 +86,12 @@ function M.parseheader(lines, from, header)
|
|||||||
end
|
end
|
||||||
name = name:lower()
|
name = name:lower()
|
||||||
if header[name] then
|
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
|
else
|
||||||
header[name] = value
|
header[name] = value
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user