2023-07-14 23:53:45 (UTC-03:00)
Marcel Rodrigues <marcelgmr@gmail.com>
some fixes to response header
diff --git a/lib/ludweb/http.lua b/lib/ludweb/http.lua index 8fcd1aa..e7a7f3c 100644 --- a/lib/ludweb/http.lua +++ b/lib/ludweb/http.lua @@ -72,7 +72,7 @@ local function build_cookie_data(cookies) if c.age ~= nil then line = line .. "; Max-Age=" .. c.age end - data = data .. line .. "\n" + data = data .. line .. "\r\n" end return data end @@ -84,14 +84,14 @@ local function build_response(data, status, reason, cookies) reason = "OK" elseif status == 303 then reason = reason or "See Other" - header = "Location: " .. data .. "\n" + header = "Location: " .. data .. "\r\n" end - header = header .. "Content-Length: " .. #data .. "\n" - header = header .. build_cookie_data(cookies) -- it's nice to provide a minimal error message by default if status ~= 200 and data == "" then data = status.." "..reason.."\n" end + header = header .. "Content-Length: " .. #data .. "\r\n" + header = header .. build_cookie_data(cookies) local fmt = "HTTP/1.1 %03d %s\r\n%s\r\n%s" return fmt:format(status, reason, header, data) end