refactor: header flushing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
# initialise autoconf and set up some basic information about the program we’re packaging
|
||||
AC_INIT([silk], [1.0.1], [xsang.le@gmail.com])
|
||||
AC_INIT([silk], [1.0.2], [xsang.le@gmail.com])
|
||||
|
||||
# We’re going to use automake for this project
|
||||
# [subdir-objects] if needed
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -43,9 +43,3 @@ POLICY.mimes = {
|
||||
["audio/mpeg"] = true
|
||||
|
||||
}
|
||||
|
||||
function html()
|
||||
if not RESPONSE_HEADER.sent then
|
||||
std.html()
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user