72
lua_pushlightuserdata(L, &ngx_http_lua_request_key);
73
lua_rawget(L, LUA_GLOBALSINDEX);
74
r = lua_touserdata(L, -1);
72
r = ngx_http_lua_get_req(L);
78
74
return luaL_error(L, "no request object found");
225
220
rc = NGX_HTTP_MOVED_TEMPORARILY;
228
lua_pushlightuserdata(L, &ngx_http_lua_request_key);
229
lua_rawget(L, LUA_GLOBALSINDEX);
230
r = lua_touserdata(L, -1);
223
r = ngx_http_lua_get_req(L);
234
225
return luaL_error(L, "no request object found");
262
253
return luaL_error(L, "out of memory");
265
r->headers_out.location->hash =
266
ngx_hash(ngx_hash(ngx_hash(ngx_hash(ngx_hash(ngx_hash(
267
ngx_hash('l', 'o'), 'c'), 'a'), 't'), 'i'), 'o'), 'n');
256
r->headers_out.location->hash = ngx_http_lua_location_hash;
270
259
dd("location hash: %lu == %lu",
301
290
return luaL_error(L, "expecting one argument");
304
lua_pushlightuserdata(L, &ngx_http_lua_request_key);
305
lua_rawget(L, LUA_GLOBALSINDEX);
306
r = lua_touserdata(L, -1);
293
r = ngx_http_lua_get_req(L);
310
295
return luaL_error(L, "no request object found");
318
303
ngx_http_lua_check_context(L, ctx, NGX_HTTP_LUA_CONTEXT_REWRITE
319
304
| NGX_HTTP_LUA_CONTEXT_ACCESS
320
305
| NGX_HTTP_LUA_CONTEXT_CONTENT
321
| NGX_HTTP_LUA_CONTEXT_TIMER);
306
| NGX_HTTP_LUA_CONTEXT_TIMER
307
| NGX_HTTP_LUA_CONTEXT_HEADER_FILTER);
323
309
rc = (ngx_int_t) luaL_checkinteger(L, 1);
331
317
return luaL_error(L, "attempt to abort with pending subrequests");
334
if (ctx->headers_sent
335
321
&& rc >= NGX_HTTP_SPECIAL_RESPONSE
336
322
&& rc != NGX_HTTP_REQUEST_TIME_OUT
337
323
&& rc != NGX_HTTP_CLIENT_CLOSED_REQUEST
346
332
rc = NGX_HTTP_OK;
335
dd("setting exit code: %d", (int) rc);
349
337
ctx->exit_code = rc;
352
340
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
353
341
"lua exit with code %i", ctx->exit_code);
343
if (ctx->context & NGX_HTTP_LUA_CONTEXT_HEADER_FILTER) {
355
347
dd("calling yield");
356
348
return lua_yield(L, 0);
365
357
ngx_http_lua_co_ctx_t *coctx = NULL;
366
358
ngx_http_lua_loc_conf_t *llcf;
368
lua_pushlightuserdata(L, &ngx_http_lua_request_key);
369
lua_rawget(L, LUA_GLOBALSINDEX);
370
r = lua_touserdata(L, -1);
360
r = ngx_http_lua_get_req(L);
374
362
return luaL_error(L, "no request found");
409
#ifndef NGX_HTTP_LUA_NO_FFI_API
411
ngx_http_lua_ffi_exit(ngx_http_request_t *r, int status, u_char *err,
414
ngx_http_lua_ctx_t *ctx;
416
ctx = ngx_http_get_module_ctx(r, ngx_http_lua_module);
418
*errlen = ngx_snprintf(err, *errlen, "no request ctx found") - err;
422
if (ngx_http_lua_ffi_check_context(ctx, NGX_HTTP_LUA_CONTEXT_REWRITE
423
| NGX_HTTP_LUA_CONTEXT_ACCESS
424
| NGX_HTTP_LUA_CONTEXT_CONTENT
425
| NGX_HTTP_LUA_CONTEXT_TIMER
426
| NGX_HTTP_LUA_CONTEXT_HEADER_FILTER,
434
&& status != NGX_ERROR
435
&& status != NGX_HTTP_CLOSE
436
&& status != NGX_HTTP_REQUEST_TIME_OUT
437
&& status != NGX_HTTP_CLIENT_CLOSED_REQUEST)
439
*errlen = ngx_snprintf(err, *errlen,
440
"attempt to abort with pending subrequests")
446
&& status >= NGX_HTTP_SPECIAL_RESPONSE
447
&& status != NGX_HTTP_REQUEST_TIME_OUT
448
&& status != NGX_HTTP_CLIENT_CLOSED_REQUEST
449
&& status != NGX_HTTP_CLOSE)
451
if (status != (ngx_int_t) r->headers_out.status) {
452
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "attempt to "
453
"set status %i via ngx.exit after sending out the "
454
"response status %ui", status,
455
r->headers_out.status);
458
status = NGX_HTTP_OK;
461
ctx->exit_code = status;
464
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
465
"lua exit with code %i", ctx->exit_code);
467
if (ctx->context & NGX_HTTP_LUA_CONTEXT_HEADER_FILTER) {
473
#endif /* NGX_HTTP_LUA_NO_FFI_API */
420
475
/* vi:set ft=c ts=4 sw=4 et fdm=marker: */