From: Daniel Gruno Date: Fri, 17 Aug 2012 09:41:46 +0000 (+0000) Subject: mod_lua: Allow scripts handled by the lua-script handler to set a return X-Git-Tag: 2.5.0-alpha~6423 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=71ca51c1a6d7a36e1944780c51ad3bcd36c29ad0;p=thirdparty%2Fapache%2Fhttpd.git mod_lua: Allow scripts handled by the lua-script handler to set a return code that will be sent to the client, such as 302, 500 etc. This will allow scripts to be able to f.x. redirect a user to another page by returning 302. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1374185 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 4b97109fd4a..ab566c34f75 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ -*- coding: utf-8 -*- Changes with Apache 2.5.0 + *) mod_lua: Allow scripts handled by the lua-script handler to return + a status code to the client (such as a 302 or a 500) [Daniel Gruno] + *) mod_proxy_ajp: Fix crash in packet dump code when logging with LogLevel trace7 or trace8. PR 53730. [Rainer Jung] diff --git a/modules/lua/mod_lua.c b/modules/lua/mod_lua.c index 23aaf1a774b..4aa2aa87bfb 100644 --- a/modules/lua/mod_lua.c +++ b/modules/lua/mod_lua.c @@ -233,6 +233,7 @@ static const char* ap_lua_interpolate_string(apr_pool_t* pool, const char* strin */ static int lua_handler(request_rec *r) { + int rc = OK; if (strcmp(r->handler, "lua-script")) { return DECLINED; } @@ -275,12 +276,15 @@ static int lua_handler(request_rec *r) return HTTP_INTERNAL_SERVER_ERROR; } ap_lua_run_lua_request(L, r); - if (lua_pcall(L, 1, 0, 0)) { + if (lua_pcall(L, 1, 1, 0)) { report_lua_error(L, r); } + if (lua_isnumber(L, -1)) { + rc = lua_tointeger(L, -1); + } ap_lua_release_state(L, spec, r); } - return OK; + return rc; }