webmcp
annotate framework/env/request/set_status.lua @ 264:8aa38ddcc1b2
New configuration options "min_requests_per_connect" and "max_requests_per_connect"; Bugfix: Send headers added with request.add_header(...) also in case of 303 Redirect
author | jbe |
---|---|
date | Fri Mar 20 05:30:57 2015 +0100 (2015-03-20) |
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 |