mirror of
https://github.com/rxi/lovebird.git
synced 2024-11-27 12:04:21 +00:00
Added Content-Length to HTTP response, removed Content-Type
This commit is contained in:
parent
4f36c2ac45
commit
3c2583df70
@ -603,12 +603,15 @@ function lovebird.onrequest(req, client)
|
|||||||
page = page ~= "" and page or "index"
|
page = page ~= "" and page or "index"
|
||||||
-- Handle "page not found"
|
-- Handle "page not found"
|
||||||
if not lovebird.pages[page] then
|
if not lovebird.pages[page] then
|
||||||
return "HTTP/1.1 404\r\n\r\nBad page"
|
return "HTTP/1.1 404\r\nContent-Length: 8\r\n\r\nBad page"
|
||||||
end
|
end
|
||||||
-- Handle page
|
-- Handle page
|
||||||
local str
|
local str
|
||||||
xpcall(function()
|
xpcall(function()
|
||||||
str = "HTTP/1.1 200 OK\r\n\r\n" .. lovebird.pages[page](lovebird, req)
|
local data = lovebird.pages[page](lovebird, req)
|
||||||
|
str = "HTTP/1.1 200 OK\r\n" ..
|
||||||
|
"Content-Length: " .. #data .. "\r\n" ..
|
||||||
|
"\r\n" .. data
|
||||||
end, lovebird.onerror)
|
end, lovebird.onerror)
|
||||||
return str
|
return str
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user