diff --git a/configure.ac b/configure.ac index 3696e53..e4c8362 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/silkmvc/BaseObject.lua b/silkmvc/BaseObject.lua index 5009c59..48bae13 100644 --- a/silkmvc/BaseObject.lua +++ b/silkmvc/BaseObject.lua @@ -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) diff --git a/silkmvc/Router.lua b/silkmvc/Router.lua index cb27874..f4eca21 100644 --- a/silkmvc/Router.lua +++ b/silkmvc/Router.lua @@ -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 diff --git a/silkmvc/api.lua b/silkmvc/api.lua index 2bfa3f1..d6569e1 100644 --- a/silkmvc/api.lua +++ b/silkmvc/api.lua @@ -43,9 +43,3 @@ POLICY.mimes = { ["audio/mpeg"] = true } - -function html() - if not RESPONSE_HEADER.sent then - std.html() - end -end diff --git a/silkmvc/core/std.lua b/silkmvc/core/std.lua index 6fca691..9487315 100644 --- a/silkmvc/core/std.lua +++ b/silkmvc/core/std.lua @@ -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