瀏覽代碼

Fix and test the existing implementation for plain Lua pages

bel 11 年之前
父節點
當前提交
07beed7bf1
共有 2 個文件被更改,包括 4 次插入1 次删除
  1. 2 0
      src/civetweb.c
  2. 2 1
      src/mod_lua.inl

+ 2 - 0
src/civetweb.c

@@ -5135,6 +5135,8 @@ static void handle_request(struct mg_connection *conn)
                             "Directory listing denied");
                             "Directory listing denied");
         }
         }
 #ifdef USE_LUA
 #ifdef USE_LUA
+    } else if (match_prefix("**.lsp$", 6, path) > 0) {
+        mg_exec_lua_script(conn, path, NULL);
     } else if (match_prefix("**.lp$", 6, path) > 0) {
     } else if (match_prefix("**.lp$", 6, path) > 0) {
         handle_lsp_request(conn, path, &file, NULL);
         handle_lsp_request(conn, path, &file, NULL);
 #endif
 #endif

+ 2 - 1
src/mod_lua.inl

@@ -384,8 +384,8 @@ void mg_exec_lua_script(struct mg_connection *conn, const char *path,
         prepare_lua_environment(conn, L, path);
         prepare_lua_environment(conn, L, path);
         lua_pushcclosure(L, &lua_error_handler, 0);
         lua_pushcclosure(L, &lua_error_handler, 0);
 
 
-        lua_pushglobaltable(L);
         if (exports != NULL) {
         if (exports != NULL) {
+            lua_pushglobaltable(L);
             for (i = 0; exports[i] != NULL && exports[i + 1] != NULL; i += 2) {
             for (i = 0; exports[i] != NULL && exports[i + 1] != NULL; i += 2) {
                 lua_pushstring(L, exports[i]);
                 lua_pushstring(L, exports[i]);
                 lua_pushcclosure(L, (lua_CFunction) exports[i + 1], 0);
                 lua_pushcclosure(L, (lua_CFunction) exports[i + 1], 0);
@@ -399,6 +399,7 @@ void mg_exec_lua_script(struct mg_connection *conn, const char *path,
         lua_pcall(L, 0, 0, -2);
         lua_pcall(L, 0, 0, -2);
         lua_close(L);
         lua_close(L);
     }
     }
+    conn->must_close=1;
 }
 }
 
 
 static void lsp_send_err(struct mg_connection *conn, struct lua_State *L,
 static void lsp_send_err(struct mg_connection *conn, struct lua_State *L,