resty: made ngx.print, ngx.say, and print return meaninful values; also mocked ngx.flush() and ngx.eof().

This commit is contained in:
Yichun Zhang (agentzh) 2014-08-20 21:10:18 -07:00
parent fae163cc70
commit 59e6665224
1 changed files with 5 additions and 2 deletions

View File

@ -127,9 +127,12 @@ http {
init_by_lua '
local stdout = io.stdout
print = function (...) stdout:write(...) end
print = function (...) return stdout:write(...) end
ngx.print = print
ngx.say = function (...) print(...) print("\\\\n") end
ngx.say = function (...) local ok, err = print(...) if ok then return print("\\\\n") end return ok, err end
ngx.flush = function (...) return stdout:flush() end
-- we cannot close stdout here due to a bug in Lua:
ngx.eof = function (...) return true end
';
init_worker_by_lua '