webmcp
annotate framework/env/request/set_status.lua @ 471:a9fea293b2d6
New function format.file_path_element(...)
author | jbe |
---|---|
date | Thu May 25 02:46:23 2017 +0200 (2017-05-25) |
parents | 9fdfb27f8e67 |
children |
rev | line source |
---|---|
jbe/bsw@0 | 1 --[[-- |
jbe/bsw@0 | 2 request.set_status( |
jbe/bsw@0 | 3 str -- string containing a HTTP status code, e.g. "404 Not Found" |
jbe/bsw@0 | 4 ) |
jbe/bsw@0 | 5 |
jbe/bsw@0 | 6 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. |
jbe/bsw@0 | 7 |
jbe/bsw@0 | 8 --]]-- |
jbe/bsw@0 | 9 |
jbe/bsw@0 | 10 function request.set_status(str) |
jbe/bsw@0 | 11 if str then |
jbe/bsw@0 | 12 local t = type(str) |
jbe/bsw@0 | 13 if type(str) == "number" then |
jbe/bsw@0 | 14 str = tostring(str) |
jbe/bsw@0 | 15 elseif type(str) ~= "string" then |
jbe/bsw@0 | 16 error("request.set_status(...) must be called with a string as parameter.") |
jbe/bsw@0 | 17 end |
jbe/bsw@0 | 18 request._status = str |
jbe/bsw@0 | 19 else |
jbe/bsw@0 | 20 request._status = nil |
jbe/bsw@0 | 21 end |
jbe/bsw@0 | 22 end |