refactor: header flushing
All checks were successful
Autotools pipeline / build-amd64 (push) Successful in 18s
Autotools pipeline / build-arm64 (push) Successful in 20s
Autotools pipeline / build-arm (push) Successful in 19s

This commit is contained in:
2026-04-09 22:03:08 +02:00
parent 2a554e2b4b
commit b92f89f14f
5 changed files with 9 additions and 9 deletions

View File

@@ -1,5 +1,5 @@
# initialise autoconf and set up some basic information about the program were packaging
AC_INIT([silk], [1.0.1], [xsang.le@gmail.com])
AC_INIT([silk], [1.0.2], [xsang.le@gmail.com])
# Were going to use automake for this project
# [subdir-objects] if needed

View File

@@ -27,7 +27,7 @@ function BaseObject:print()
end
function BaseObject:error(msg,...)
html()
std.html()
--local line = debug.getinfo(1).currentline
local emsg = string.format(msg or "ERROR",...)
echo(emsg)

View File

@@ -100,6 +100,10 @@ function Router:delegate()
data = self:infer(v)
views[k] = self:call(data)
end
std.html()
if REQUEST.method == "HEAD" then
return
end
-- now require the main page to put the view
local view_args = {}
local view_argv = {}
@@ -109,7 +113,6 @@ function Router:delegate()
end
local script_path = VIEW_ROOT .. DIR_SEP .. self.registry.layout .. DIR_SEP .. "layout.ls"
local fn, e = loadscript(script_path, view_args)
html()
if fn then
local r, o = pcall(fn, table.unpack(view_argv))
if not r then

View File

@@ -43,9 +43,3 @@ POLICY.mimes = {
["audio/mpeg"] = true
}
function html()
if not RESPONSE_HEADER.sent then
std.html()
end
end

View File

@@ -95,6 +95,9 @@ function std.header(k, v)
end
function std.header_flush()
if RESPONSE_HEADER.sent == true then
return
end
-- send out status
echo("Status: ", RESPONSE_HEADER.status, " ", http_status[RESPONSE_HEADER.status], "\r\n")
-- send out header