webmcp
diff framework/env/request/set_status.lua @ 0:9fdfb27f8e67
Version 1.0.0
author | jbe/bsw |
---|---|
date | Sun Oct 25 12:00:00 2009 +0100 (2009-10-25) |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/framework/env/request/set_status.lua Sun Oct 25 12:00:00 2009 +0100 1.3 @@ -0,0 +1,22 @@ 1.4 +--[[-- 1.5 +request.set_status( 1.6 + str -- string containing a HTTP status code, e.g. "404 Not Found" 1.7 +) 1.8 + 1.9 +Calling this function causes a HTTP status different from 200 OK (or in case of error different from 500 Internal Server Error) to be sent to the browser. 1.10 + 1.11 +--]]-- 1.12 + 1.13 +function request.set_status(str) 1.14 + if str then 1.15 + local t = type(str) 1.16 + if type(str) == "number" then 1.17 + str = tostring(str) 1.18 + elseif type(str) ~= "string" then 1.19 + error("request.set_status(...) must be called with a string as parameter.") 1.20 + end 1.21 + request._status = str 1.22 + else 1.23 + request._status = nil 1.24 + end 1.25 +end