diff options
author | Dmitry Volyntsev <xeioex@nginx.com> | 2018-05-30 15:07:04 +0300 |
---|---|---|
committer | Dmitry Volyntsev <xeioex@nginx.com> | 2018-05-30 15:07:04 +0300 |
commit | d8d0245877f69eb1ace3baac776ba0d2273d7b0b (patch) | |
tree | 659e2c19ffd1ace4b37dd6cefc4fccb182c582d8 /nginx/ngx_http_js_module.c | |
parent | 373175bfb7a1f564580c654f8ea517320abf7c15 (diff) | |
download | njs-d8d0245877f69eb1ace3baac776ba0d2273d7b0b.tar.gz njs-d8d0245877f69eb1ace3baac776ba0d2273d7b0b.zip |
Setting status code to 500 by default in js_content handler.
This helps to debug incorrectly written content handlers.
Diffstat (limited to 'nginx/ngx_http_js_module.c')
-rw-r--r-- | nginx/ngx_http_js_module.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/nginx/ngx_http_js_module.c b/nginx/ngx_http_js_module.c index 645f811c..45689094 100644 --- a/nginx/ngx_http_js_module.c +++ b/nginx/ngx_http_js_module.c @@ -671,6 +671,13 @@ ngx_http_js_content_event_handler(ngx_http_request_t *r) return; } + /* + * status is expected to be overriden by finish() or return() methods, + * otherwise the content handler is considered invalid. + */ + + ctx->status = NGX_HTTP_INTERNAL_SERVER_ERROR; + if (njs_vm_call(ctx->vm, func, njs_value_arg(ctx->args), 2) != NJS_OK) { njs_vm_retval_to_ext_string(ctx->vm, &exception); @@ -1269,6 +1276,7 @@ static njs_ret_t ngx_http_js_ext_finish(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs, njs_index_t unused) { + ngx_http_js_ctx_t *ctx; ngx_http_request_t *r; r = njs_value_data(njs_argument(args, 0)); @@ -1277,6 +1285,10 @@ ngx_http_js_ext_finish(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs, return NJS_ERROR; } + ctx = ngx_http_get_module_ctx(r, ngx_http_js_module); + + ctx->status = NGX_OK; + return NJS_OK; } |