summaryrefslogtreecommitdiffhomepage
path: root/libs
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-07-16 09:18:27 +0000
committerSteven Barth <steven@midlink.org>2008-07-16 09:18:27 +0000
commit9b1ef9e2b1a9e318a2840ee4b846f7ca8d82d3bb (patch)
tree38205200e231fa5b1dccb33f6cf5f5dc16461907 /libs
parent9fd9401d9bddd5288085d97f6593b06876a2ef4b (diff)
libs/web: Made luci.http.write a sink
Diffstat (limited to 'libs')
-rw-r--r--libs/web/luasrc/http.lua35
1 files changed, 22 insertions, 13 deletions
diff --git a/libs/web/luasrc/http.lua b/libs/web/luasrc/http.lua
index 7a0a10232..dbfcad777 100644
--- a/libs/web/luasrc/http.lua
+++ b/libs/web/luasrc/http.lua
@@ -169,22 +169,31 @@ function status(code, message)
coroutine.yield(1, code, message)
end
-function write(content)
- if not content or #content == 0 then
- return
- end
- if not context.eoh then
- if not context.status then
- status()
+function write(content, src_err)
+ if not content then
+ if src_err then
+ error(src_err)
+ else
+ close()
end
- if not context.headers or not context.headers["content-type"] then
- header("Content-Type", "text/html; charset=utf-8")
+ return true
+ elseif #content == 0 then
+ return true
+ else
+ if not context.eoh then
+ if not context.status then
+ status()
+ end
+ if not context.headers or not context.headers["content-type"] then
+ header("Content-Type", "text/html; charset=utf-8")
+ end
+
+ context.eoh = true
+ coroutine.yield(3)
end
-
- context.eoh = true
- coroutine.yield(3)
+ coroutine.yield(4, content)
+ return true
end
- coroutine.yield(4, content)
end
function redirect(url)