Permalink
Browse files

test, donnot use

  • Loading branch information...
1 parent 07a1414 commit 7143cb1c2c1ab0c3244b22afb723ce003ce2787a @alacner committed Apr 29, 2011
Showing with 17 additions and 2 deletions.
  1. +17 −2 src/ngx_http_lua_module.c
View
@@ -54,7 +54,7 @@ static int luaM_set_cookie (lua_State *L);
#endif
static int
-luaM_print (lua_State *L) {
+luaM_print2 (lua_State *L) {
const char *str = luaL_optstring(L, 1, NULL);
lua_getglobal(L, LUA_NGX_RESPONSE_BUFFER);
@@ -70,6 +70,16 @@ luaM_print (lua_State *L) {
return 0;
}
+static int
+luaM_print (lua_State *L) {
+ const char *str = luaL_optstring(L, 1, NULL);
+
+ lua_getfield(L, LUA_GLOBALSINDEX, LUA_NGX_RESPONSE_BUFFER);
+ lua_pushstring(L, str);
+ lua_rawset(L, -2)
+ return 0;
+}
+
/* Commands */
static ngx_command_t ngx_http_lua_commands[] = {
{ ngx_string("ngx_lua_module"),
@@ -246,7 +256,8 @@ static ngx_int_t make_http_body_by_lua(ngx_http_request_t *r, char *out_buf){
/* push out_buf to lua */
- lua_pushlightuserdata(L, out_buf);
+ //lua_pushlightuserdata(L, out_buf);
+ lua_newtable(L); /* out buffer */
lua_setglobal(L, LUA_NGX_RESPONSE_BUFFER);
lua_newtable(L); /* ngx */
@@ -277,13 +288,17 @@ static ngx_int_t make_http_body_by_lua(ngx_http_request_t *r, char *out_buf){
lua_setglobal(L, "ngx");
+
if (luaL_dofile(L, "/usr/local/nginx/conf/test.lua") != 0) {
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
"runtime error: %s", lua_tostring(L, -1));
lua_pop(L, 1);
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
+
+ lua_getfield(L, LUA_GLOBALSINDEX, LUA_NGX_RESPONSE_BUFFER);
+ lua_concat()
return NGX_OK;
}

0 comments on commit 7143cb1

Please sign in to comment.