libs/web: don't send Status: 500 in error500() if header is already sent

modules/admin-core: include template header only once
This commit is contained in:
Jo-Philipp Wich 2009-02-09 13:17:26 +00:00
parent 8dbb8a0ad3
commit b5026e65c0
2 changed files with 16 additions and 8 deletions

View file

@ -74,12 +74,14 @@ end
-- @param message Custom error message (optional)#
-- @return false
function error500(message)
luci.http.status(500, "Internal Server Error")
require("luci.template")
if not luci.util.copcall(luci.template.render, "error500", {message=message}) then
luci.http.prepare_content("text/plain")
luci.http.write(message)
if not context.template_header_sent then
luci.http.status(500, "Internal Server Error")
else
require("luci.template")
if not luci.util.copcall(luci.template.render, "error500", {message=message}) then
luci.http.prepare_content("text/plain")
luci.http.write(message)
end
end
return false
end
@ -589,7 +591,7 @@ end
local function _call(self, ...)
if #self.argv > 0 then
if #self.argv > 0 then
return getfenv()[self.name](unpack(self.argv), ...)
else
return getfenv()[self.name](...)

View file

@ -12,4 +12,10 @@ You may obtain a copy of the License at
$Id$
-%>
<% include("themes/" .. theme .. "/header") %>
<%
if not luci.dispatcher.context.template_header_sent then
include("themes/" .. theme .. "/header")
luci.dispatcher.context.template_header_sent = true
end
%>