From 23c4421d7bb4e35a598699c3f1361173906088d8 Mon Sep 17 00:00:00 2001 From: findstr Date: Sat, 6 Aug 2016 23:32:27 +0800 Subject: [PATCH] bug fix incorrect http header pack --- lualib/http/server.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lualib/http/server.lua b/lualib/http/server.lua index 2db080ff..136ef7ff 100644 --- a/lualib/http/server.lua +++ b/lualib/http/server.lua @@ -145,10 +145,10 @@ function server.listen(port, handler) end function server.send(fd, status, header, body) - local tmp = string.format("HTTP/1.1 %d %s\r\n", status, http_err_msg[status]) - tmp = tmp .. table.concat(header, "\r\n") - tmp = tmp .. string.format("Content-Length: %d\r\n", #body) - tmp = tmp .. "\r\n" + table.insert(header, 1, string.format("HTTP/1.1 %d %s", status, http_err_msg[status])) + table.insert(header, string.format("Content-Length: %d", #body)) + local tmp = table.concat(header, "\r\n") + tmp = tmp .. "\r\n\r\n" tmp = tmp .. body write(fd, tmp) end