]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
mod_lua: Allow scripts handled by the lua-script handler to set a return
authorDaniel Gruno <humbedooh@apache.org>
Fri, 17 Aug 2012 09:41:46 +0000 (09:41 +0000)
committerDaniel Gruno <humbedooh@apache.org>
Fri, 17 Aug 2012 09:41:46 +0000 (09:41 +0000)
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

CHANGES
modules/lua/mod_lua.c

diff --git a/CHANGES b/CHANGES
index 4b97109fd4a77d5356e17a11a051cf3b018fb2ba..ab566c34f7505fb7f81f0b37bb66c18299e8c074 100644 (file)
--- 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]
 
index 23aaf1a774bba5d068beaca806666ca89ab1b750..4aa2aa87bfb6a59e049528ff22d8a23181c1716d 100644 (file)
@@ -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;
 }