80
80
return luaL_error(L, "expecting 0 arguments but seen %d", n);
83
lua_pushlightuserdata(L, &ngx_http_lua_request_key);
84
lua_rawget(L, LUA_GLOBALSINDEX);
85
r = lua_touserdata(L, -1);
83
r = ngx_http_lua_get_req(L);
89
85
return luaL_error(L, "request object not found");
217
213
return luaL_error(L, "expecting 0 arguments but seen %d", n);
220
lua_pushlightuserdata(L, &ngx_http_lua_request_key);
221
lua_rawget(L, LUA_GLOBALSINDEX);
222
r = lua_touserdata(L, -1);
216
r = ngx_http_lua_get_req(L);
226
218
return luaL_error(L, "request object not found");
254
246
return luaL_error(L, "expecting 0 arguments but seen %d", n);
257
lua_pushlightuserdata(L, &ngx_http_lua_request_key);
258
lua_rawget(L, LUA_GLOBALSINDEX);
259
r = lua_touserdata(L, -1);
249
r = ngx_http_lua_get_req(L);
263
251
return luaL_error(L, "request object not found");
325
313
return luaL_error(L, "expecting 0 arguments but seen %d", n);
328
lua_pushlightuserdata(L, &ngx_http_lua_request_key);
329
lua_rawget(L, LUA_GLOBALSINDEX);
330
r = lua_touserdata(L, -1);
316
r = ngx_http_lua_get_req(L);
334
318
return luaL_error(L, "request object not found");
380
364
body.data = (u_char *) luaL_checklstring(L, 1, &body.len);
382
lua_pushlightuserdata(L, &ngx_http_lua_request_key);
383
lua_rawget(L, LUA_GLOBALSINDEX);
384
r = lua_touserdata(L, -1);
366
r = ngx_http_lua_get_req(L);
388
368
return luaL_error(L, "request object not found");
546
526
return luaL_error(L, "expecting 0 or 1 argument but seen %d", n);
549
lua_pushlightuserdata(L, &ngx_http_lua_request_key);
550
lua_rawget(L, LUA_GLOBALSINDEX);
551
r = lua_touserdata(L, -1);
529
r = ngx_http_lua_get_req(L);
531
return luaL_error(L, "no request found");
554
534
ngx_http_lua_check_fake_request(L, r);
647
627
body.data = (u_char *) luaL_checklstring(L, 1, &body.len);
649
lua_pushlightuserdata(L, &ngx_http_lua_request_key);
650
lua_rawget(L, LUA_GLOBALSINDEX);
651
r = lua_touserdata(L, -1);
629
r = ngx_http_lua_get_req(L);
631
return luaL_error(L, "no request found");
654
634
ngx_http_lua_check_fake_request(L, r);
709
689
return luaL_error(L, "expecting 0 argument but seen %d", n);
712
lua_pushlightuserdata(L, &ngx_http_lua_request_key);
713
lua_rawget(L, LUA_GLOBALSINDEX);
714
r = lua_touserdata(L, -1);
692
r = ngx_http_lua_get_req(L);
718
return luaL_error(L, "no request");
694
return luaL_error(L, "no request found");
721
697
ngx_http_lua_check_fake_request(L, r);
762
738
return luaL_error(L, "out of memory");
765
size = r->headers_in.content_length_n;
741
size = (size_t) r->headers_in.content_length_n;
767
743
value.len = ngx_sprintf(value.data, "%uz", size) - value.data;
768
744
value.data[value.len] = '\0';
842
818
p = (u_char *) luaL_checklstring(L, 1, &name.len);
844
lua_pushlightuserdata(L, &ngx_http_lua_request_key);
845
lua_rawget(L, LUA_GLOBALSINDEX);
846
r = lua_touserdata(L, -1);
820
r = ngx_http_lua_get_req(L);
850
return luaL_error(L, "request object not found");
822
return luaL_error(L, "no request found");
853
825
ngx_http_lua_check_fake_request(L, r);
964
937
ngx_memzero(&of, sizeof(ngx_open_file_info_t));
939
of.directio = NGX_OPEN_FILE_DIRECTIO_OFF;
966
941
if (ngx_http_lua_open_and_stat_file(name.data, &of, r->connection->log)
1128
1101
static ngx_int_t
1129
1102
ngx_http_lua_read_body_resume(ngx_http_request_t *r)
1132
1106
ngx_connection_t *c;
1133
1107
ngx_http_lua_ctx_t *ctx;
1134
ngx_http_lua_main_conf_t *lmcf;
1136
1109
ctx = ngx_http_get_module_ctx(r, ngx_http_lua_module);
1138
1111
ctx->resume_handler = ngx_http_lua_wev_handler;
1140
lmcf = ngx_http_get_module_main_conf(r, ngx_http_lua_module);
1142
1113
c = r->connection;
1114
vm = ngx_http_lua_get_lua_vm(r, ctx);
1144
rc = ngx_http_lua_run_thread(lmcf->lua, r, ctx, 0);
1116
rc = ngx_http_lua_run_thread(vm, r, ctx, 0);
1146
1118
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1147
1119
"lua run thread returned %d", rc);
1149
1121
if (rc == NGX_AGAIN) {
1150
return ngx_http_lua_run_posted_threads(c, lmcf->lua, r, ctx);
1122
return ngx_http_lua_run_posted_threads(c, vm, r, ctx);
1153
1125
if (rc == NGX_DONE) {
1154
1126
ngx_http_lua_finalize_request(r, NGX_DONE);
1155
return ngx_http_lua_run_posted_threads(c, lmcf->lua, r, ctx);
1127
return ngx_http_lua_run_posted_threads(c, vm, r, ctx);
1158
1130
if (ctx->entered_content_phase) {